{"name":"unist-util-map","version":"2.0.1","description":"unist utility to create a new tree by mapping all nodes","license":"MIT","keywords":["unist","unist-util","util","utility","node","tree","map","walk","visit"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/unist-util-map.git"},"bugs":{"url":"https://github.com/syntax-tree/unist-util-map/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"azu","email":"azuciao@gmail.com"},"contributors":[{"name":"azu","email":"azuciao@gmail.com"},{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},{"name":"Christian Murphy","email":"christian.murphy.42@gmail.com"}],"types":"types/index.d.ts","dependencies":{"@types/mdast":"^3.0.0","object-assign":"^4.0.0"},"devDependencies":{"dtslint":"^0.9.0","nyc":"^15.0.0","prettier":"^1.0.0","remark-cli":"^7.0.0","remark-preset-wooorm":"^6.0.0","tape":"^4.0.0","unist-builder":"^2.0.0","unist-util-is":"^4.0.0","xo":"^0.26.0"},"scripts":{"format":"remark . -qfo && prettier --write \"**/*.js\" && xo --fix","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test-types":"dtslint types","test":"npm run format && npm run test-coverage && npm run test-types"},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"ec414a43e8d2c8afa7b952f9bf3e3aa5d686b908","homepage":"https://github.com/syntax-tree/unist-util-map#readme","_id":"unist-util-map@2.0.1","_nodeVersion":"13.0.1","_npmVersion":"6.13.7","dist":{"integrity":"sha512-VdNvk4BQUUU9Rgr8iUOvclHa/iN9O+6Dt66FKij8l9OVezGG37gGWCPU5KSax1R2degqXFvl3kWTkvzL79e9tQ==","shasum":"c3fca064486d3937c4dad8b39c64974faae7c7c4","tarball":"http://registry-npm.ywwl.com/unist-util-map/download/unist-util-map-2.0.1.tgz","fileCount":5,"unpackedSize":8367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSVxYCRA9TVsSAnZWagAApM8P/0mfv6SSTGmqRsNXo4Yo\nWd1NlzD1y/J9SjdP6tNJWULPNwGxusFz5/AC9Y+/5mtMAXoTa+Q5mTwc0dl7\n4jnl1A3C2oBJEO3a1OqQDBXqpSW7FLHHJXs0d6EfUGiFEu6R3HOtetPbPQFf\nSlUXLXKRz2q0BdGoh8PnhY6Kbg4QHtIAcLIjxvjk540oNTMFMQaoAbFDQXM+\nApgkouOUw076XQXFD1CsVcWW1WaVaEYqZA95XTYMcU1gc1TxlqXj1T3hYR6L\nbZqU/dSVVAEDOle7ejRaqr3fI9zYEErhKvJcdd0s/0t+HDkLENdTYqE3fIsH\noqCE39YqqjhtGFnwNovfi5gAI6S0myc5jf+JFvhud/aCQ/Q+rpN3JpbQvpqB\n3Pi7CgEv0ApU8BojsVu0UwiVveI93tWTgENAXcg8DU64PgsP0zcRZnXPaM0c\n31XpIwtuNZKFMPc8ym4Peo8lbuzHs54D/LGOo83GNO1YjYRNQFlz4ksQ5Jwy\nv1POi2GKesrGDWGHG4FU5BU3NPHBRoAhdd4hradE0UuDqwaGKX0fxpwGgdnk\nT8pQdOrPteF6tAKODemVMHbZLlg4QtvCh8rAsKV/Y9QCYgaOBiW7UhWHkStd\n5D6aQSFEGSQ0Y+3lVXooq4sYVVIOt0qhN7RgtR7x6Z+Xh8E2q2nBw3cd3pBh\ne3Cf\r\n=jl4C\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuT2Y7d90DUE0PV+TKrdcy0N6SQPNSteAFlWSfUKuKtAIgBbuVV01nq2XlOYhboFX+tvEThnrkHkCJcLEPimfutjI="}],"size":3417,"noattachment":false,"key":"/unist-util-map/-/unist-util-map-2.0.1.tgz"},"maintainers":[{"email":"keith@mcknig.ht","name":"kmck"},{"email":"tituswormer@gmail.com","name":"wooorm"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unist-util-map_2.0.1_1581866072054_0.8753271001521417"},"_hasShrinkwrap":false,"readme":"# unist-util-map\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[unist][] utility to create a new tree by mapping all nodes with a given\nfunction.\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    *   [`map(tree, mapFunction)`](#maptree-mapfunction)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis is a small utility that helps you make new trees.\n\n## When should I use this?\n\nYou can use this utility to create a new tree by mapping all nodes with a given\nfunction.\nCreating new trees like this can lead to performance problems, as it creates\nnew objects for every node.\nWhen dealing with potentially large trees, and relatively few changes, use\n[`unist-util-visit`][unist-util-visit] (or\n[`unist-util-visit-parents`][unist-util-visit-parents]) instead.\n\nTo remove certain nodes, you can also walk the tree with `unist-util-visit`, or\nuse [`unist-util-filter`][unist-util-filter] (clones the tree instead of\nmutating) or [`unist-util-remove`][unist-util-remove] (mutates).\nTo create trees, use [`unist-builder`][unist-builder].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unist-util-map\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {map} from 'https://esm.sh/unist-util-map@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {map} from 'https://esm.sh/unist-util-map@4?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {u} from 'unist-builder'\nimport {map} from 'unist-util-map'\n\nconst tree = u('tree', [\n  u('leaf', 'leaf 1'),\n  u('node', [u('leaf', 'leaf 2')]),\n  u('void'),\n  u('leaf', 'leaf 3')\n])\n\nconst next = map(tree, function (node) {\n  return node.type === 'leaf'\n    ? Object.assign({}, node, {value: 'CHANGED'})\n    : node\n})\n\nconsole.dir(next, {depth: undefined})\n```\n\nYields:\n\n```js\n{\n  type: 'tree',\n  children: [\n    {type: 'leaf', value: 'CHANGED'},\n    {type: 'node', children: [{type: 'leaf', value: 'CHANGED'}]},\n    {type: 'void'},\n    {type: 'leaf', value: 'CHANGED'}\n  ]\n}\n```\n\n> 👉 **Note**: `next` is a changed clone and `tree` is not mutated.\n\n## API\n\nThis package exports the identifier [`map`][api-map].\nThere is no default export.\n\n### `map(tree, mapFunction)`\n\nCreate a new tree by mapping all nodes with the given function.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to map\n*   `mapFunction` ([`MapFunction`][api-mapfunction])\n    — function called with a node, its index, and its parent to produce a new\n    node\n\n###### Returns\n\nNew mapped tree ([`Node`][node]).\n\n#### `MapFunction`\n\nFunction called with a node, its index, and its parent to produce a new\nnode (TypeScript type).\n\n###### Parameters\n\n*   `node` ([`Node`][node])\n    — node to map\n*   `index` (`number` or `undefined`)\n    — index of `node` in `parent` (if any)\n*   `parent` ([`Node`][node] or `undefined`)\n    — parent of `node`\n\n###### Returns\n\nNew mapped node ([`Node`][node]).\n\nThe children on the returned node are not used.\nIf the original node has children, those are mapped instead.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`MapFunction`][api-mapfunction].\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, `unist-util-map@^4`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter)\n    — create a new tree with all nodes that pass the given function\n*   [`unist-util-flatmap`](https://gitlab.com/staltz/unist-util-flatmap)\n    — create a new tree by expanding a node into many\n*   [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove)\n    — remove nodes from trees\n*   [`unist-util-select`](https://github.com/syntax-tree/unist-util-select)\n    — select nodes with CSS-like selectors\n*   [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)\n    — walk trees\n*   [`unist-builder`](https://github.com/syntax-tree/unist-builder)\n    — create trees\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to 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, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [azu][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/unist-util-map/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-map/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-map.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-map\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-map.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-map\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=unist-util-map\n\n[size]: https://bundlejs.com/?q=unist-util-map\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://efcl.info\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[unist]: https://github.com/syntax-tree/unist\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[unist-util-visit]: https://github.com/syntax-tree/unist-util-visit\n\n[unist-util-visit-parents]: https://github.com/syntax-tree/unist-util-visit-parents\n\n[unist-util-filter]: https://github.com/syntax-tree/unist-util-filter\n\n[unist-util-remove]: https://github.com/syntax-tree/unist-util-remove\n\n[unist-builder]: https://github.com/syntax-tree/unist-builder\n\n[api-map]: #maptree-mapfunction\n\n[api-mapfunction]: #mapfunction\n","publish_time":1581866072184,"_cnpm_publish_time":1581866072184,"dist-tags":{"latest":"4.0.0"}}