{"name":"nlcst-search","version":"3.0.0","description":"nlcst utility to search for patterns in a tree","license":"MIT","keywords":["unist","nlcst","nlcst-util","util","utility","pattern","search"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/nlcst-search.git"},"bugs":{"url":"https://github.com/syntax-tree/nlcst-search/issues"},"funding":{"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"},{"name":"Dave Newton","email":"dave.newton@shopify.com"},{"name":"Tom MacWright","email":"tom@macwright.org"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"@types/unist":"^2.0.0","nlcst-is-literal":"^2.0.0","nlcst-normalize":"^3.0.0","unist-util-visit":"^3.0.0"},"devDependencies":{"@types/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^9.0.0","remark-preset-wooorm":"^8.0.0","rimraf":"^3.0.0","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.39.0"},"scripts":{"prepack":"npm run build && npm run format","build":"rimraf \"*.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":"039a020ed178d5e0dafd6c83c5ec167aac8b3821","homepage":"https://github.com/syntax-tree/nlcst-search#readme","_id":"nlcst-search@3.0.0","_nodeVersion":"15.11.0","_npmVersion":"7.9.0","dist":{"integrity":"sha512-QE4bLflS86Oa+Si2n8RoXE8U/IL9WxRA72mvztWFNnPqjg2uF//+d6stG0Di24S4ITDAl4+/u4Jt5MpII5I81Q==","shasum":"671a16128784d5463c7825ee17a9bf9a96a723bf","tarball":"http://registry-npm.ywwl.com/nlcst-search/download/nlcst-search-3.0.0.tgz","fileCount":5,"unpackedSize":13302,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfyW6CRA9TVsSAnZWagAA91gP/3dYy+DO1nQogA0/ABmh\nssXPBvq5Vmren8uKptJabT0JAgB2R2ZMbKzTH+tAi+h8XxIvT0C/Pl8OXNEj\nGjFuGU2SGO391k+EfZHDHXHsDBdD2udDmSDLMHB6tclqhPSHMgK0+Sxyl16p\nz2IwPRxOyf4TDI9/Zt28k2hEL+khKvw3zyWW94yuYzJ8b088XNdHUbJo9zjd\nBzNvJYT7DnjzD3u5kUlee4+R2Vts6D+NoL7iP62Vj2NzrptEN29pWZBTmOKd\nOW/Z+ALd81UKeeSNosXN97w4EilgmVYSamNB5wiscGzecRB6oQ1aG9bAw9ei\nqVb9vgxzuILVeKmNXvJiPjhipL+BsOO62/DeCPmxoT1AnrjlZnIaogAtqumj\nlTjjN/cp5irxaZs+fifufZXRoeDWbPXKMressY8rrvbT8AYY6MMTtEbcfBFB\nSy+2zreM4/dsG7dCMUVP3r3knNUyvwPDbwByHmw0cfq0kzDRaVYRc1+GsTnL\nLmQsvjbbiUuStXLp2/xpuyuxkdeBPWpTi4sjHnuYQbYvqPTPivRTlBWaGq0d\nF3CLaMQ1kCkLyDUjiUv/xAwvAtwSivRmVvHJH1IUm2NGe/z+LyvsrYMm2GSf\nGAmaxY/59mawr6tShNYsKH1Femjk3V7v5FIZQWoPll1mMi5KJbcpFcFfdJvf\nJva+\r\n=SktN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFA6ia0ulEhQLQK1cy8qyt3Bb0G5bkHJs6avEbd38dUQAiBZPR/1v6QxHyrZrY40oHl89sOTlgdy7G3Z1/m1wU96MQ=="}],"size":4866,"noattachment":false,"key":"/nlcst-search/-/nlcst-search-3.0.0.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/nlcst-search_3.0.0_1618945466043_0.5128996261231102"},"_hasShrinkwrap":false,"readme":"# nlcst-search\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[nlcst][] utility to search for phrases in a tree.\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    *   [`search(tree, phrases, handler[, options])`](#searchtree-phrases-handler-options)\n    *   [`Handler`](#handler)\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 utility can search for phrases (words and phrases) in trees.\n\n## When should I use this?\n\nThis package is a tiny utility that helps when you’re searching for words\nand phrases.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install nlcst-search\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {search} from 'https://esm.sh/nlcst-search@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {search} from 'https://esm.sh/nlcst-search@4?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {search} from 'nlcst-search'\nimport {toString} from 'nlcst-to-string'\n\nconst tree = {\n  type: 'SentenceNode',\n  children: [\n    {\n      type: 'WordNode',\n      children: [\n        {type: 'TextNode', value: 'Don'},\n        {type: 'PunctuationNode', value: '’'},\n        {type: 'TextNode', value: 't'}\n      ]\n    },\n    {type: 'WhiteSpaceNode', value: ' '},\n    {\n      type: 'WordNode',\n      children: [{type: 'TextNode', value: 'do'}]\n    },\n    {type: 'WhiteSpaceNode', value: ' '},\n    {\n      type: 'WordNode',\n      children: [\n        {type: 'TextNode', value: 'Block'},\n        {type: 'PunctuationNode', value: '-'},\n        {type: 'TextNode', value: 'level'}\n      ]\n    }\n  ]\n}\n\nsearch(tree, ['dont'], function(nodes) {\n  console.log(toString(nodes))\n})\n// `Don’t`\n\nsearch(tree, ['do blocklevel'], function(nodes) {\n  console.log(toString(nodes))\n})\n// `do Block-level`\n```\n\n## API\n\nThis package exports the identifier [`search`][api-search].\nThere is no default export.\n\n### `search(tree, phrases, handler[, options])`\n\nSearch for phrases in a tree.\n\nEach phrase is a space-separated list of words, where each word will be\n[normalized][nlcst-normalize] to remove casing, apostrophes, and dashes.\nSpaces in a pattern mean one or more whitespace nodes in the tree.\nInstead of a word with letters, it’s also possible to use a wildcard symbol\n(`*`, an asterisk) which will match any word in a pattern (`alpha * charlie`).\n\n##### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to search\n*   `phrases` (`Array<string>`)\n    — phrases to search for\n*   `handler` ([`Handler`][api-handler])\n    — handle a match\n*   `options` ([`Options`][api-options])\n    — configuration\n\n###### Returns\n\nNothing (`undefined`).\n\n### `Handler`\n\nHandle a match (TypeScript type).\n\n###### Parameters\n\n*   `nodes` ([`Array<Node>`][node])\n    — match\n*   `index` (`number`)\n    — index of first node of `nodes` in `parent`\n*   `parent` ([`Node`][node])\n    — parent of `nodes`\n*   `phrase` (`string`)\n    — the phrase that matched\n\n###### Returns\n\nNothing (`undefined`).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `allowApostrophes` (`boolean`, default: `false`)\n    — passed to [`nlcst-normalize`][nlcst-normalize]\n*   `allowDashes` (`boolean`, default: `false`)\n    — passed to [`nlcst-normalize`][nlcst-normalize]\n*   `allowLiterals` (`boolean`, default: `false`)\n    — include [literal][] phrases\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Handler`][api-handler] and\n[`Options`][api-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, `nlcst-search@^4`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`nlcst-normalize`](https://github.com/syntax-tree/nlcst-normalize)\n    — normalize a word for easier comparison\n*   [`nlcst-is-literal`](https://github.com/syntax-tree/nlcst-is-literal)\n    — check whether a node is meant literally\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] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/nlcst-search/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/nlcst-search/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/nlcst-search.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/nlcst-search\n\n[downloads-badge]: https://img.shields.io/npm/dm/nlcst-search.svg\n\n[downloads]: https://www.npmjs.com/package/nlcst-search\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=nlcst-search\n\n[size]: https://bundlejs.com/?q=nlcst-search\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://wooorm.com\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[nlcst]: https://github.com/syntax-tree/nlcst\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[literal]: https://github.com/syntax-tree/nlcst-is-literal\n\n[nlcst-normalize]: https://github.com/syntax-tree/nlcst-normalize\n\n[api-search]: #searchtree-phrases-handler-options\n\n[api-handler]: #handler\n\n[api-options]: #options\n","publish_time":1618945466157,"_cnpm_publish_time":1618945466157,"dist-tags":{"latest":"4.0.0"}}