Textwalker with optional filter func parameter (#77)

This commit is contained in:
Huang Xin
2025-06-10 12:45:43 +00:00
committed by GitHub
parent d7affcf969
commit 4ee127d88f
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -109,7 +109,7 @@ export const search = (strs, query, options) => {
}
export const searchMatcher = (textWalker, opts) => {
const { defaultLocale, matchCase, matchDiacritics, matchWholeWords } = opts
const { defaultLocale, matchCase, matchDiacritics, matchWholeWords, acceptNode } = opts
return function* (doc, query) {
const iter = textWalker(doc, function* (strs, makeRange) {
for (const result of search(strs, query, {
@@ -124,7 +124,7 @@ export const searchMatcher = (textWalker, opts) => {
result.range = makeRange(startIndex, startOffset, endIndex, endOffset)
yield result
}
})
}, acceptNode)
for (const result of iter) yield result
}
}