{"name":"nlcst-search","version":"1.5.1","description":"Search for patterns in an NLCST tree","license":"MIT","keywords":["pattern","search","nlcst","retext","utility"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/nlcst-search.git"},"bugs":{"url":"https://github.com/syntax-tree/nlcst-search/issues"},"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"}],"dependencies":{"nlcst-is-literal":"^1.1.0","nlcst-normalize":"^2.1.0","unist-util-visit":"^1.0.0"},"devDependencies":{"browserify":"^16.0.0","nyc":"^14.0.0","prettier":"^1.0.0","remark-cli":"^6.0.0","remark-preset-wooorm":"^5.0.0","tape":"^4.0.0","tinyify":"^2.0.0","xo":"^0.24.0"},"scripts":{"format":"remark . -qfo && prettier --write \"**/*.js\" && xo --fix","build-bundle":"browserify . -s nlcstSearch > nlcst-search.js","build-mangle":"browserify . -s nlcstSearch -p tinyify > nlcst-search.min.js","build":"npm run build-bundle && npm run build-mangle","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run format && npm run build && npm run test-coverage"},"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,"rules":{"guard-for-in":"off","unicorn/prefer-type-error":"off"},"ignore":["nlcst-search.js"]},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"1ebf2b07be97f5eac9f2f52dc0b3962aeb369580","homepage":"https://github.com/syntax-tree/nlcst-search#readme","_id":"nlcst-search@1.5.1","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-G3ws0fgNlVsUvHvA2G1PTjyxzGOJ0caI0+WOvlZzev5iSUTX+R1q4lnlL4Y7E+he4ZMUW/0FMn9rYwdYon/13g==","shasum":"86791990b9b8785bb6d5a910d49b9ec4a7e81801","tarball":"http://registry-npm.ywwl.com/nlcst-search/download/nlcst-search-1.5.1.tgz","fileCount":4,"unpackedSize":10947,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc56StCRA9TVsSAnZWagAAmmoP/ixS2nettezjsJAbENhN\nnVO7Gr31EmK69llsxMOMSmvRBMFn58OV6U3k4GR8kjro955zu4YsUp+nN+Q4\nodyLEI1HbqiDnFNT4p981HI9CkifN6EeZcwV1WsPWA0w6KVt7dXpmUHnW4aT\n6xmm3C1uAEaxPARvOZxAtcxwbVPaLMCX/m1+W6Nom73LB45o6Tx/oHbXK8kM\nCSrWG8cJeCtKaRX3O7CDDDGZr2pCOgjs79kFUidBNbjNu8+KO/0++8NC3ukO\n+P4imjgQYx5a8mU7pS2jH53iEOCQ8me5Dm4cRuKUQy1BpSewXsXoIxYGQfgb\nYvKcir1eb4nKpi/1JQgNUuhaAhave9BNjQu7KqqI4uRwB5rq0HjOY1UIHMwu\nv8fumziXjrvp73OMgiwh+K9xC/dOwHH6ai/tUMgJ+xauJ68WNqHaPCdcfxJ6\nNNrqskdyoTCxJiUimAnqACTcet0GfuBZxtdiPkaG4gTGeBrpeWuUV4r7iijT\nBffOoYuL/98lfbEhV9Sj0++gcJNsEGiPcVuIO3ZlTBzvESFeREMWbLUovfR1\n0ZRZYNz7og8ISRvof3jUGihPaknt4Xnc5AObcFQSnQm9Jyyy1EfxYeO6AEL6\na1cAYzoon5Y6/o+GxcuGZAHLL3yqoq0NmW2YcKDvw62etFrHXtQN08O4asMZ\n2pS5\r\n=uIi8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBipSEfbnFuRzx6TKtiovtY+c+4qPCtH0Se70ADTQfHRAiAKqv6lTFPZd8LcNf7Q4G9lHgpmAZGLFB4NIfR0/2GbGw=="}],"size":4208,"noattachment":false,"key":"/nlcst-search/-/nlcst-search-1.5.1.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nlcst-search_1.5.1_1558684845053_0.667498637117105"},"_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":1558684845177,"_cnpm_publish_time":1558684845177,"dist-tags":{"latest":"4.0.0"}}