{"name":"nlcst-search","version":"1.0.0","description":"Search for patterns in an NLCST tree","license":"MIT","keywords":["pattern","search","nlcst","retext","utility"],"files":["index.js"],"repository":{"type":"git","url":"https://github.com/wooorm/nlcst-search.git"},"bugs":{"url":"https://github.com/wooorm/nlcst-search/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"dependencies":{"nlcst-is-literal":"^1.0.0","nlcst-normalize":"^1.0.0","unist-util-visit":"^1.0.0"},"devDependencies":{"browserify":"^13.0.0","eslint":"^1.0.0","esmangle":"^1.0.0","istanbul":"^0.4.0","jscs":"^2.0.0","jscs-jsdoc":"^1.0.0","remark":"^3.0.0","remark-comment-config":"^2.0.2","remark-github":"^2.0.0","remark-lint":"^2.0.2","remark-slug":"^3.0.1","remark-validate-links":"^2.0.2","remark-yaml-config":"^2.0.0","tape":"^4.0.0"},"scripts":{"build-md":"remark . --quiet --frail","build-bundle":"browserify index.js --bare -s nlcstSearch > nlcst-search.js","build-mangle":"esmangle nlcst-search.js > nlcst-search.min.js","build":"npm run build-md && npm run build-bundle && npm run build-mangle","lint-api":"eslint .","lint-style":"jscs --reporter inline .","lint":"npm run lint-api && npm run lint-style","test-api":"node test.js","test-coverage":"istanbul cover test.js","test":"npm run build && npm run lint && npm run test-coverage"},"gitHead":"26ab8ccc757116f49e4a113277c96708e2537b9a","homepage":"https://github.com/wooorm/nlcst-search","_id":"nlcst-search@1.0.0","_shasum":"ecbb78543c88861f36606af0b87755d76d370a91","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.11.16","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"ecbb78543c88861f36606af0b87755d76d370a91","tarball":"http://registry-npm.ywwl.com/nlcst-search/download/nlcst-search-1.0.0.tgz","integrity":"sha512-XU8+SFdYaZwRgz5NF+HjElOpkYp+qkvCrgY+Syg1wnvEfLQcs9WE5XFvuPx8YvjzXrKD1aVXGQ1Q07r/n2tiRg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDDXuCFCr7Kggqg36bjUufxlKJtjy7zrDULDFcDOKLtHAiEA0Uaf/tCicSQLfsoDfnYiT8u319dWJprqZOELl6JH8YA="}],"size":3899,"noattachment":false,"key":"/nlcst-search/-/nlcst-search-1.0.0.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"directories":{},"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":1452809877233,"_cnpm_publish_time":1452809877233,"dist-tags":{"latest":"4.0.0"}}