{"name":"unist-util-filter","version":"2.0.0","description":"Create a new Unist tree with all nodes that pass the test implemented by the provided function","license":"MIT","keywords":["ast","clone","filter","immutable","node","test","tree","unist","util"],"repository":{"type":"git","url":"git+https://github.com/eush77/unist-util-filter.git"},"bugs":{"url":"https://github.com/eush77/unist-util-filter/issues"},"author":{"name":"Eugene Sharygin","email":"eush77@gmail.com"},"contributors":[{"name":"Eugene Sharygin","email":"eush77@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":{"flatmap":"0.0.3","unist-util-is":"^4.0.0"},"devDependencies":{"@types/mdast":"^3.0.3","dtslint":"^0.9.9","nyc":"^14.0.0","prettier":"^1.0.0","remark-cli":"^7.0.0","remark-preset-wooorm":"^6.0.0","tape":"^4.0.0","unist-builder":"^1.0.0","xo":"^0.25.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,"ignores":["unist-util-position.js"]},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"a43498ce342f07f5cd0d803acc1aa6ac739cc315","homepage":"https://github.com/eush77/unist-util-filter#readme","_id":"unist-util-filter@2.0.0","_nodeVersion":"13.0.1","_npmVersion":"6.12.0","dist":{"integrity":"sha512-N/c0IFRKiGKfAYtrCIe+CssNo6u3jUBx4a1i2G+IP0YCXZmw7HtuhMpGm6M9YsLFMHEQE2R5FMQPtY9IHCqydw==","shasum":"93a80cf0cf0ec6dbaef5b7bfd196f65bfd4f3d75","tarball":"http://registry-npm.ywwl.com/unist-util-filter/download/unist-util-filter-2.0.0.tgz","fileCount":5,"unpackedSize":8640,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdtqRjCRA9TVsSAnZWagAA328P/iTMXt4vir8JLkjtvha8\ncBrgYYeISoX2qrKsZkOFrUo4+c5bCqOCuY9Fh84PDeHguD/LEkFEytveuLGU\nURm9hvQXju1blWg6OCCMVm3GLxxcaY6qdjykMBxmCJ2EwG7fVJ/wkwUDtzZE\nEiGiyW9y8QM1gzEnVfg4K/yVH8AywqQxn3aV/YHsuxBheENDzxJY/liFLYg4\npGIGVjcZoTsCwWADcSMOjzWy4gcJPoFm1Hsrfzgb/1fhmeaa/WzIio2V8c/6\n9Az40elT2uapGhgVmBWMhvgSkF5oQzIaF4AH4DDKYif0ayzgVjgJlobf5MfG\nm/IKhC0CSLmxAYvI8l2ajru/3qDEVkMpLRHQdbMKxr0FwyW5kbF22U4Qh4xZ\ne2KYTU9bm8idJyyCfnMxL1HkVa8JLMyDy29151eiiybF6EbIdjGGHz6+YMfC\nvRy2cQpr8uVKnX6eJXIp9nSnlRScVm7l/5ViaC2nYw7yjOpf6JejAjFjeMIR\nUa6tISd2Cl7Kgb5MO4A5p8cCEV+IgmER0Tasue8AJF2sdCffE883ScG0TJwO\nMAP/kPCz8ftdMAC1hlet+bXJWfQWzNoZXoNbsfjWMNJYnIP1VpEy7rnjMVbt\nfEifqN8tS2Oq6lpMjslCWx52WXLoJ6fiUm+1P55uEMwNv6aEH6qEwYTGg0jK\nYaGI\r\n=jrwk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaN/uWQO+lHUiu+SghXTDB+vNhMmB/40MdTVcLjqzR7gIgfh/H9/qusz7WK2/ZKzCV+QZqoxFzITlLi5KNoj8aBZ8="}],"size":3586,"noattachment":false,"key":"/unist-util-filter/-/unist-util-filter-2.0.0.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-filter_2.0.0_1572250722767_0.6440251357341706"},"_hasShrinkwrap":false,"readme":"# unist-util-filter\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 with only nodes that pass a test.\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    *   [`filter(tree[, options][, test])`](#filtertree-options-test)\n    *   [`Options`](#options)\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 clean a tree.\n\n## When should I use this?\n\nYou can use this utility to remove things from a tree.\nThis utility is very similar to [`unist-util-remove`][unist-util-remove], which\nchanges the given tree.\nModifying a tree like that utility does is much faster on larger documents.\n\nYou can also walk the tree with [`unist-util-visit`][unist-util-visit] to remove\nnodes.\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-filter\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {filter} from 'https://esm.sh/unist-util-filter@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {filter} from 'https://esm.sh/unist-util-filter@5?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {u} from 'unist-builder'\nimport {filter} from 'unist-util-filter'\n\nconst tree = u('root', [\n  u('leaf', '1'),\n  u('parent', [u('leaf', '2'), u('parent', [u('leaf', '3')])]),\n  u('leaf', '4')\n])\n\nconst newTree = filter(tree, node => node.type !== 'leaf' || node.value % 2 === 0)\n\nconsole.dir(newTree, {depth: null})\n```\n\nYields:\n\n```js\n{\n  type: 'root',\n  children: [\n    {type: 'parent', children: [{type: 'leaf', value: '2'}]},\n    {type: 'leaf', value: '4'}\n  ]\n}\n```\n\n## API\n\nThis package exports the identifier [`filter`][filter].\nThere is no default export.\n\n### `filter(tree[, options][, test])`\n\nCreate a new `tree` of copies of all nodes that pass `test`.\n\nThe tree is walked in *[preorder][]* (NLR), visiting the node itself, then its\nhead, etc.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to filter\n*   `options` ([`Options`][options], optional)\n    — configuration\n*   `test` ([`Test`][test], optional)\n    — `unist-util-is` compatible test\n\n###### Returns\n\nNew filtered tree ([`Node`][node] or `undefined`).\n\n`undefined` is returned if `tree` itself didn’t pass the test, or is cascaded\naway.\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `cascade` (`boolean`, default: `true`)\n    — whether to drop parent nodes if they had children, but all their\n    children were filtered out\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][options].\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-filter@^5`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)\n    — walk the tree\n*   [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents)\n    — walk the tree with a stack of parents\n*   [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)\n    — create a new tree with all nodes mapped by a given function\n*   [`unist-util-flatmap`](https://gitlab.com/staltz/unist-util-flatmap)\n    — create a new tree by mapping (to an array) by a given function\n*   [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove)\n    — remove nodes from a tree that pass a test\n*   [`unist-util-select`](https://github.com/syntax-tree/unist-util-select)\n    — select nodes with CSS-like selectors\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] © Eugene Sharygin\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/unist-util-filter/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-filter/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-filter.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-filter\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-filter.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-filter\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-filter\n\n[size]: https://bundlejs.com/?q=unist-util-filter\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[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/HEAD/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[preorder]: https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/\n\n[unist-util-remove]: https://github.com/syntax-tree/unist-util-remove\n\n[unist-util-visit]: https://github.com/syntax-tree/unist-util-visit\n\n[unist-builder]: https://github.com/syntax-tree/unist-builder\n\n[test]: https://github.com/syntax-tree/unist-util-is#test\n\n[filter]: #filtertree-options-test\n\n[options]: #options\n","publish_time":1572250722937,"_cnpm_publish_time":1572250722937,"dist-tags":{"latest":"5.0.1"}}