{"_id":"micromark-util-edit-map","name":"micromark-util-edit-map","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"micromark-util-edit-map","version":"1.0.0","description":"micromark utility to batch changes to lists of events","license":"MIT","keywords":["micromark","util","utility","edit","map","splice"],"repository":{"type":"git","url":"git+https://github.com/micromark/micromark.git#main"},"bugs":{"url":"https://github.com/micromark/micromark/issues"},"funding":[{"type":"GitHub Sponsors","url":"https://github.com/sponsors/unifiedjs"},{"type":"OpenCollective","url":"https://opencollective.com/unified"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","exports":{"development":"./dev/index.js","default":"./index.js"},"dependencies":{"micromark-util-types":"^2.0.0"},"scripts":{"build":"micromark-build"},"gitHead":"21cd4c321a325131c39736b210eea425cae0d1e8","types":"./index.d.ts","_id":"micromark-util-edit-map@1.0.0","homepage":"https://github.com/micromark/micromark/tree/main#readme","_nodeVersion":"26.3.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==","shasum":"0b5dd9ab4295f7389472c5fee2b61ffd45774cb2","tarball":"https://registry.npmjs.org/micromark-util-edit-map/-/micromark-util-edit-map-1.0.0.tgz","fileCount":9,"unpackedSize":25903,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCbkR5xpy4ONZyHi57iWX4vzYxTVuh74mtU7himxNBNkgIgVtmya/XAjVnViLLeFJU+rhDI9Yb1SE09XmvMvSes/sQ="}]},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/micromark-util-edit-map_1.0.0_1790437096822_0.07969404105281974"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-26T15:38:16.745Z","1.0.0":"2026-09-26T15:38:17.088Z","modified":"2026-09-26T15:38:17.238Z"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"description":"micromark utility to batch changes to lists of events","homepage":"https://github.com/micromark/micromark/tree/main#readme","keywords":["micromark","util","utility","edit","map","splice"],"repository":{"type":"git","url":"git+https://github.com/micromark/micromark.git#main"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"bugs":{"url":"https://github.com/micromark/micromark/issues"},"license":"MIT","readme":"# micromark-util-edit-map\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][bundle-size-badge]][bundle-size]\n[![Sponsors][sponsors-badge]][opencollective]\n[![Backers][backers-badge]][opencollective]\n[![Chat][chat-badge]][chat]\n\n[micromark][] utility to batch changes to lists of events.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`EditMap()`](#editmap)\n  * [`EditMap#add(index, remove, add)`](#editmapaddindex-remove-add)\n  * [`EditMap#addBefore(index, remove, add)`](#editmapaddbeforeindex-remove-add)\n  * [`EditMap#consume(events)`](#editmapconsumeevents)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package exposes an algorithm to batch changes to lists of events,\nneeded when authoring complex resolvers, such as for tables or lists.\n\n## When should I use this?\n\nThis package is only useful when you are making your own micromark extensions\nthat need to change many places in lists of events,\nsuch as injecting the result of parsing subcontent,\nor cleaning up how a construct is represented.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install micromark-util-edit-map\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {EditMap} from 'https://esm.sh/micromark-util-edit-map@1'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {EditMap} from 'https://esm.sh/micromark-util-edit-map@1?bundle'\n</script>\n```\n\n## Use\n\n```js\n/**\n * @import {Event} from 'micromark-util-types'\n */\n\nimport {EditMap} from 'micromark-util-edit-map'\n\n/** @type {Array<Event>} */\nconst events = [] // Assume this is filled.\n\nconst editMap = new EditMap()\n\neditMap.add(1, 0, [['enter', events[2][1], events[2][2]]])\neditMap.add(2, 1, [])\n\neditMap.consume(events)\n```\n\n## API\n\nThis module exports the identifier [`EditMap`][api-edit-map].\nThere is no default export.\n\n### `EditMap()`\n\nCreate a new edit map.\n\n###### Returns\n\nNew instance (`EditMap`).\n\n### `EditMap#add(index, remove, add)`\n\nCreate an edit: a remove and/or add at a certain place.\n\n###### Parameters\n\n* `index` (`number`)\n  — index at which to apply the edit\n* `remove` (`number`)\n  — count of items to remove at the index\n* `add` (`Array<Event>`)\n  — items to add at the index\n\n###### Returns\n\nNothing (`undefined`).\n\n### `EditMap#addBefore(index, remove, add)`\n\nCreate an edit: but insert `add` before existing additions at `index`,\ninstead of after them.\n\n###### Parameters\n\n* `index` (`number`)\n  — index at which to apply the edit\n* `remove` (`number`)\n  — count of items to remove at the index\n* `add` (`Array<Event>`)\n  — items to add at the index\n\n###### Returns\n\nNothing (`undefined`).\n\n### `EditMap#consume(events)`\n\nDone, change the events.\n\n###### Parameters\n\n* `events` (`Array<Event>`)\n  — list of events to apply the edits to\n\n###### Returns\n\nNothing (`undefined`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`micromark-util-edit-map@1`, compatible with Node.js 16.\nThis package works with `micromark@4`.\n\n## Security\n\nThis package is safe.\nSee [`security.md`][securitymd] in [`micromark/.github`][health] for how to\nsubmit a security report.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`micromark/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organisation, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[api-edit-map]: #editmap\n\n[author]: https://wooorm.com\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[build]: https://github.com/micromark/micromark/actions\n\n[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg\n\n[bundle-size]: https://bundlejs.com/?q=micromark-util-edit-map\n\n[bundle-size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-edit-map\n\n[chat]: https://github.com/micromark/micromark/discussions\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md\n\n[contributing]: https://github.com/micromark/.github/blob/main/contributing.md\n\n[coverage]: https://codecov.io/github/micromark/micromark\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg\n\n[downloads]: https://www.npmjs.com/package/micromark-util-edit-map\n\n[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-edit-map.svg\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[health]: https://github.com/micromark/.github\n\n[license]: https://github.com/micromark/micromark/blob/main/license\n\n[micromark]: https://github.com/micromark/micromark\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[opencollective]: https://opencollective.com/unified\n\n[securitymd]: https://github.com/micromark/.github/blob/main/security.md\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[support]: https://github.com/micromark/.github/blob/main/support.md\n\n[typescript]: https://www.typescriptlang.org\n","readmeFilename":"readme.md","_rev":"1-adcf9c627a5ad76e2baac754741619da"}