8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** nlcst** ] [ nlcst ] utility to search for patterns in a tree.
11
+ [ nlcst] [ ] utility to search for patterns in a tree.
12
12
13
- ## Install
13
+ ## Contents
14
+
15
+ * [ What is this?] ( #what-is-this )
16
+ * [ When should I use this?] ( #when-should-i-use-this )
17
+ * [ Install] ( #install )
18
+ * [ Use] ( #use )
19
+ * [ API] ( #api )
20
+ * [ ` search(tree, patterns, handler[, allowApostrophes|options]) ` ] ( #searchtree-patterns-handler-allowapostrophesoptions )
21
+ * [ ` function handler(nodes, index, parent, pattern) ` ] ( #function-handlernodes-index-parent-pattern )
22
+ * [ Types] ( #types )
23
+ * [ Compatibility] ( #compatibility )
24
+ * [ Related] ( #related )
25
+ * [ Contribute] ( #contribute )
26
+ * [ License] ( #license )
27
+
28
+ ## What is this?
14
29
15
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
16
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
30
+ This utility can search for patterns (words and phrases) in trees.
17
31
18
- [ npm] [ ] :
32
+ ## When should I use this?
33
+
34
+ This package is a tiny utility that helps when you’re searching for words
35
+ and phrases.
36
+
37
+ ## Install
38
+
39
+ This package is [ ESM only] [ esm ] .
40
+ In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [ npm] [ ] :
19
41
20
42
``` sh
21
43
npm install nlcst-search
22
44
```
23
45
46
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
47
+
48
+ ``` js
49
+ import {search } from " https://esm.sh/nlcst-search@3"
50
+ ```
51
+
52
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
53
+
54
+ ``` html
55
+ <script type =" module" >
56
+ import {search } from " https://esm.sh/nlcst-search@3?bundle"
57
+ </script >
58
+ ```
59
+
24
60
## Use
25
61
26
62
``` js
@@ -68,7 +104,7 @@ search(tree, ['do blocklevel'], function(nodes) {
68
104
69
105
## API
70
106
71
- This package exports the following identifiers: ` search ` .
107
+ This package exports the identifier ` search ` .
72
108
There is no default export.
73
109
74
110
### ` search(tree, patterns, handler[, allowApostrophes|options]) `
@@ -93,7 +129,7 @@ asterisk), that matches any word in a pattern (`alpha * charlie`).
93
129
94
130
###### ` handler `
95
131
96
- Handler invoked when a match is found ([ ` Function ` ] [ fn-handler ] ).
132
+ Handler called when a match is found ([ ` Handler ` ] [ fn-handler ] ).
97
133
98
134
###### ` allowApostrophes `
99
135
@@ -113,7 +149,7 @@ Include [literal][] phrases (`boolean`, default: `false`).
113
149
114
150
### ` function handler(nodes, index, parent, pattern) `
115
151
116
- Handler invoked when a match is found.
152
+ Handler called when a match is found.
117
153
118
154
##### Parameters
119
155
@@ -133,17 +169,30 @@ List of [sibling][]s that match `pattern` ([`Array<Node>`][node]).
133
169
134
170
The matched pattern (` string ` ).
135
171
172
+ ## Types
173
+
174
+ This package is fully typed with [ TypeScript] [ ] .
175
+ It exports the additional types ` Options ` , ` PhrasesList ` , ` PhrasesMap ` , and
176
+ ` Handler ` .
177
+
178
+ ## Compatibility
179
+
180
+ Projects maintained by the unified collective are compatible with all maintained
181
+ versions of Node.js.
182
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
183
+ Our projects sometimes work with older versions, but this is not guaranteed.
184
+
136
185
## Related
137
186
138
187
* [ ` nlcst-normalize ` ] ( https://github.com/syntax-tree/nlcst-normalize )
139
- — Normalize a word for easier comparison
188
+ — normalize a word for easier comparison
140
189
* [ ` nlcst-is-literal ` ] ( https://github.com/syntax-tree/nlcst-is-literal )
141
- — Check whether a node is meant literally
190
+ — check whether a node is meant literally
142
191
143
192
## Contribute
144
193
145
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
146
- started.
194
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
195
+ ways to get started.
147
196
See [ ` support.md ` ] [ support ] for ways to get help.
148
197
149
198
This project has a [ code of conduct] [ coc ] .
@@ -184,15 +233,23 @@ abide by its terms.
184
233
185
234
[ npm ] : https://docs.npmjs.com/cli/install
186
235
236
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
237
+
238
+ [ esmsh ] : https://esm.sh
239
+
240
+ [ typescript ] : https://www.typescriptlang.org
241
+
187
242
[ license ] : license
188
243
189
244
[ author ] : https://wooorm.com
190
245
191
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
246
+ [ health ] : https://github.com/syntax-tree/.github
247
+
248
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
192
249
193
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
250
+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
194
251
195
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD /code-of-conduct.md
252
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main /code-of-conduct.md
196
253
197
254
[ nlcst ] : https://github.com/syntax-tree/nlcst
198
255
0 commit comments