{"library":"nlcst-search","title":"NLCST Phrase Search Utility","description":"nlcst-search is a utility designed to locate specific word patterns and phrases within Natural Language Concrete Syntax Tree (NLCST) structures. It provides a programmatic way to search text that has been parsed into an NLCST tree, useful for linguistic analysis, linting, or text transformation tasks. The package currently sits at a stable version 4.0.0 and is actively maintained as part of the `unified` collective. Major versions typically signify significant shifts, such as environment compatibility updates (e.g., Node.js versions) or module system changes (e.g., ESM adoption). Key differentiators include its tight integration with the `nlcst` ecosystem, robust pattern matching with normalization options (casing, apostrophes, dashes), and support for wildcards. It ships with full TypeScript type definitions, ensuring a strong developer experience.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install nlcst-search"],"cli":null},"imports":["import { search } from 'nlcst-search'","import type { Handler } from 'nlcst-search'","import type { Options } from 'nlcst-search'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { 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\nconsole.log('Searching for \"dont\":')\nsearch(tree, ['dont'], function(nodes) {\n  console.log(`Found: \"${toString(nodes)}\"`);\n});\n\nconsole.log('\\nSearching for \"do blocklevel\" with a wildcard:')\nsearch(tree, ['do *level'], function(nodes) {\n  console.log(`Found: \"${toString(nodes)}\"`);\n});","lang":"typescript","description":"This quickstart demonstrates how to import `search` and `toString` (from `nlcst-to-string`), define an example NLCST tree, and then use `search` to find single words and multi-word phrases, including patterns with wildcards, logging the matched text.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}