Skip to content

Commit b39150b

Browse files
committed
fix: speed up NonAsciiExtractionRule
1 parent 1ff16a7 commit b39150b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/extraction/rules/non-ascii-characters.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export class NonAsciiExtractionRule extends ExtractionRule {
66
shouldExtract(str: string) {
77
// [^\u{0}-\u{7F}] -- non Latin script,see https://unicode.org/reports/tr18/#General_Category_Property
88
const words = str.match(/\p{Letter}*/ug) ?? []
9-
const wordsWithNonAsciiChars = words.filter(word => word.match(/[^\u{0}-\u{7F}]/u))
9+
const containsWordWithNonAsciiChar = words.some(word => word.match(/[^\u{0}-\u{7F}]/u))
1010

11-
if (wordsWithNonAsciiChars.length > 0)
11+
if (containsWordWithNonAsciiChar)
1212
return ExtractionScore.MustInclude
1313
}
1414
}

0 commit comments

Comments
 (0)