1717* [ Install] ( #install )
1818* [ Use] ( #use )
1919* [ API] ( #api )
20- * [ ` findAndReplace(tree, find, replace[, options]) ` ] ( #findandreplacetree-find-replace-options )
2120 * [ ` defaultIgnore ` ] ( #defaultignore )
21+ * [ ` findAndReplace(tree, find, replace[, options]) ` ] ( #findandreplacetree-find-replace-options )
2222 * [ ` Find ` ] ( #find )
2323 * [ ` FindAndReplaceList ` ] ( #findandreplacelist )
2424 * [ ` FindAndReplaceSchema ` ] ( #findandreplaceschema )
@@ -49,7 +49,7 @@ One example is when you have some form of “mentions” (such as
4949## Install
5050
5151This package is [ ESM only] [ esm ] .
52- In Node.js (version 14.14+ and or 16.0 +), install with [ npm] [ ] :
52+ In Node.js (version 16 +), install with [ npm] [ ] :
5353
5454``` sh
5555npm install hast-util-find-and-replace
@@ -127,10 +127,16 @@ element<p>[9]
127127
128128## API
129129
130- This package exports the identifiers [ ` defaultIgnore ` ] [ defaultignore ] and
131- [ ` findAndReplace ` ] [ findandreplace ] .
130+ This package exports the identifiers [ ` defaultIgnore ` ] [ api-default-ignore ] and
131+ [ ` findAndReplace ` ] [ api-find-and-replace ] .
132132There is no default export.
133133
134+ ### ` defaultIgnore `
135+
136+ Default tag names to ignore (` Array<string> ` ).
137+
138+ The defaults are ` math ` , ` script ` , ` style ` , ` svg ` , and ` title ` .
139+
134140### ` findAndReplace(tree, find, replace[, options]) `
135141
136142Find patterns in a tree and replace them.
@@ -148,32 +154,20 @@ Partial matches are not supported.
148154
149155* ` tree ` ([ ` Node ` ] [ node ] )
150156 — tree to change
151- * ` find ` ([ ` Find ` ] [ find ] )
157+ * ` find ` ([ ` Find ` ] [ api- find] )
152158 — value to find and remove
153- * ` replace ` ([ ` Replace ` ] [ replace ] )
159+ * ` replace ` ([ ` Replace ` ] [ api- replace] )
154160 — thing to replace with
155- * ` search ` ([ ` FindAndReplaceSchema ` ] [ findandreplaceschema ] or
156- [ ` FindAndReplaceList ` ] [ findandreplacelist ] )
161+ * ` search ` ([ ` FindAndReplaceSchema ` ] [ api-find-and-replace-schema ] or
162+ [ ` FindAndReplaceList ` ] [ api-find-and-replace-list ] )
157163 — several find and replaces
158- * ` options ` ([ ` Options ` ] [ options ] )
164+ * ` options ` ([ ` Options ` ] [ api- options] )
159165 — configuration
160166
161167###### Returns
162168
163169Nothing (` undefined ` ).
164170
165- ### ` defaultIgnore `
166-
167- Default tag names to ignore.
168-
169- The defaults are ` math ` , ` script ` , ` style ` , ` svg ` , and ` title ` .
170-
171- ###### Type
172-
173- ``` ts
174- type defaultIgnore = Array <string >
175- ` ` `
176-
177171### ` Find `
178172
179173Pattern to find (TypeScript type).
@@ -183,7 +177,7 @@ Strings are escaped and then turned into global expressions.
183177###### Type
184178
185179``` ts
186- type Find = string | RegExp
180+ type Find = RegExp | string
187181` ` `
188182
189183### ` FindAndReplaceList `
@@ -196,7 +190,7 @@ Several find and replaces, in array form (TypeScript type).
196190type FindAndReplaceList = Array <FindAndReplaceTuple >
197191` ` `
198192
199- See [ ` FindAndReplaceTuple ` ][findandreplacetuple ].
193+ See [ ` FindAndReplaceTuple ` ][api-find-and-replace-tuple ].
200194
201195### ` FindAndReplaceSchema `
202196
@@ -208,7 +202,7 @@ Several find and replaces, in object form (TypeScript type).
208202type FindAndReplaceSchema = Record <string , Replace >
209203` ` `
210204
211- See [ ` Replace ` ][replace].
205+ See [ ` Replace ` ][api- replace].
212206
213207### ` FindAndReplaceTuple `
214208
@@ -220,7 +214,7 @@ Find and replace in tuple form (TypeScript type).
220214type FindAndReplaceTuple = [Find , Replace ]
221215` ` `
222216
223- See [ ` Find ` ][find] and [ ` Replace ` ][replace].
217+ See [ ` Find ` ][api- find] and [ ` Replace ` ][api- replace].
224218
225219### ` Options `
226220
@@ -251,10 +245,10 @@ Thing to replace with (TypeScript type).
251245###### Type
252246
253247` ` ` ts
254- type Replace = string | ReplaceFunction
248+ type Replace = ReplaceFunction | string
255249` ` `
256250
257- See [ ` ReplaceFunction ` ][replacefunction ].
251+ See [ ` ReplaceFunction ` ][api-replace-function ].
258252
259253### ` ReplaceFunction `
260254
@@ -268,7 +262,7 @@ The parameters are the result of corresponding search expression:
268262 — whole match
269263* ` ...capture ` ( ` Array <string >` )
270264 — matches from regex capture groups
271- * ` match ` ([ ` RegExpMatchObject ` ][regexpmatchobject ])
265+ * ` match ` ([ ` RegExpMatchObject ` ][api-regexp-match-object ])
272266 — info on the match
273267
274268###### Returns
@@ -278,26 +272,29 @@ Thing to replace with:
278272* when ` null ` , ` undefined ` , ` ' ' ` , remove the match
279273* …or when ` false ` , do not replace at all
280274* …or when ` string ` , replace with a text node of that value
281- * …or when ` Node ` or ` Array < Node > ` , replace with those nodes
275+ * …or when ` Array < Node > ` or ` Node ` , replace with those nodes
282276
283277## Types
284278
285279This package is fully typed with [TypeScript][].
286- It exports the additional types [ ` Find ` ][find],
287- [ ` FindAndReplaceList ` ][findandreplacelist ],
288- [ ` FindAndReplaceSchema ` ][findandreplaceschema ],
289- [ ` FindAndReplaceTuple ` ][findandreplacetuple ],
290- [ ` Options ` ][options],
291- [ ` RegExpMatchObject ` ][regexpmatchobject ],
292- [ ` Replace ` ][replace], and
293- [ ` ReplaceFunction ` ][replacefunction ].
280+ It exports the additional types [ ` Find ` ][api- find],
281+ [ ` FindAndReplaceList ` ][api-find-and-replace-list ],
282+ [ ` FindAndReplaceSchema ` ][api-find-and-replace-schema ],
283+ [ ` FindAndReplaceTuple ` ][api-find-and-replace-tuple ],
284+ [ ` Options ` ][api- options],
285+ [ ` RegExpMatchObject ` ][api-regexp-match-object ],
286+ [ ` Replace ` ][api- replace], and
287+ [ ` ReplaceFunction ` ][api-replace-function ].
294288
295289## Compatibility
296290
297- Projects maintained by the unified collective are compatible with all maintained
291+ Projects maintained by the unified collective are compatible with maintained
298292versions of Node.js.
299- As of now, that is Node.js 14.14+ and 16.0+.
300- Our projects sometimes work with older versions, but this is not guaranteed.
293+
294+ When we cut a new major release, we drop support for unmaintained versions of
295+ Node.
296+ This means we try to keep the current release line,
297+ ` hast -util -find -and -replace @^4 ` , compatible with Node.js 12.
301298
302299## Security
303300
@@ -359,9 +356,9 @@ abide by its terms.
359356
360357[ downloads ] : https://www.npmjs.com/package/hast-util-find-and-replace
361358
362- [ size-badge ] : https://img.shields.io/bundlephobia/minzip/ hast-util-find-and-replace.svg
359+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-find-and-replace
363360
364- [ size ] : https://bundlephobia .com/result?p =hast-util-find-and-replace
361+ [ size ] : https://bundlejs .com/?q =hast-util-find-and-replace
365362
366363[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
367364
@@ -407,22 +404,22 @@ abide by its terms.
407404
408405[ test ] : https://github.com/syntax-tree/hast-util-is-element#test
409406
410- [ defaultignore ] : #defaultignore
407+ [ api-default-ignore ] : #defaultignore
411408
412- [ findandreplace ] : #findandreplacetree-find-replace-options
409+ [ api-find-and-replace ] : #findandreplacetree-find-replace-options
413410
414- [ options ] : #options
411+ [ api- options] : #options
415412
416- [ find ] : #find
413+ [ api- find] : #find
417414
418- [ replace ] : #replace
415+ [ api- replace] : #replace
419416
420- [ replacefunction ] : #replacefunction
417+ [ api-replace-function ] : #replacefunction
421418
422- [ findandreplacelist ] : #findandreplacelist
419+ [ api-find-and-replace-list ] : #findandreplacelist
423420
424- [ findandreplaceschema ] : #findandreplaceschema
421+ [ api-find-and-replace-schema ] : #findandreplaceschema
425422
426- [ findandreplacetuple ] : #findandreplacetuple
423+ [ api-find-and-replace-tuple ] : #findandreplacetuple
427424
428- [ regexpmatchobject ] : #regexpmatchobject
425+ [ api-regexp-match-object ] : #regexpmatchobject
0 commit comments