{"name":"unist-util-map","version":"3.1.2","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"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"@types/unist":"^2.0.0"},"devDependencies":{"@types/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","rimraf":"^3.0.0","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","unist-builder":"^3.0.0","xo":"^0.52.0"},"scripts":{"prepack":"npm run build && npm run format","build":"rimraf \"{index,test}.d.ts\" && tsc && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node test.js","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"rules":{"no-var":"off","prefer-arrow-callback":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true},"gitHead":"913737d206bf5ce620fc962e85281edc0f74247d","homepage":"https://github.com/syntax-tree/unist-util-map#readme","_id":"unist-util-map@3.1.2","_nodeVersion":"18.2.0","_npmVersion":"8.19.1","dist":{"integrity":"sha512-WLA2R6x/UaopedG2poaWLShf5LCi+BNa6mMkACdjft23PHou4v85PvZItjbO2XgXvukMP365PlL/DrbuMgr3eg==","shasum":"c389677fd6ce5c0cc10af44115acaca7944a3569","tarball":"http://registry-npm.ywwl.com/unist-util-map/download/unist-util-map-3.1.2.tgz","fileCount":6,"unpackedSize":12817,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAcKRD5CJ6udCCl5+oZafsqN/RSXUYMXfrZXbgj0g8srAiBdI8ZqWplmzWwCzn8mVheBP2KeE+2LBGoaBPIf7Vb+SQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjNICQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmot9Q/9EjHCAlkSKtDgKaWur2Ia+53xOjP6j6LPVY2/9ZLjLwY0iiga\r\nGvItoICeozgGoiqLvRP45xV6VpEzcf2am1r+5beRUfLoTLABDShZBzc5m0HP\r\naC+p1TLNxpX+HPnKNyr7j4Sm438voXE1mktIuwMMwTl8kIULqnQg1QPBk4Vk\r\nYrdpCycoLEDHQaLp57Wi0mevuCggvrPLE9l54Fb5maHe6Jj/LxlPQKkJXAUG\r\nlXeUAobYHElZX0m6SNiBMPqp1pEdUnqRBtSBGdiXqKPBrlOnJMzmwtYnFT7B\r\nq70mbTqOdkESJ96cDwvQR4DkPA0K8V2DNiBS+YcKrBdlgFxnMaucOCIsXxMe\r\n7tSMJsElZ2yZwblFeCaR5E1kb4M/ULpSeUknLay62vPSZCU6qcaz7NXBCTVq\r\nldg2/B54iUOqrC8ghBU762Afb/ANRz1sUSrUfHQsYktIW4FzjUibtAV17Puu\r\nf9RpELhOnOl2vrtZ1oDqgS9D9fdX4wbYKhlwrNi9REz+hZE1rulmALcnc1dq\r\nmmLMcquc4uAFGStkcAS1YRqHbSuAZgUbu0lI9Oy/oozQ+68KPNqyQMw8m2xt\r\nMcO8R1hbjXnsA3yL6afN6NYaU//FcIQoJSmXehy0SSSL2tvG1KUzCQThx2J5\r\nbSpx8vkCdmwX3eTi/fGd/GAl6YE1UaGcOAM=\r\n=4t0M\r\n-----END PGP SIGNATURE-----\r\n","size":4588,"noattachment":false,"key":"/unist-util-map/-/unist-util-map-3.1.2.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unist-util-map_3.1.2_1664385167929_0.7863128242421571"},"_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":1664385168118,"_cnpm_publish_time":1664385168118,"dist-tags":{"latest":"4.0.0"}}