Gathering detailed insights and metrics for approx-string-match
Gathering detailed insights and metrics for approx-string-match
Gathering detailed insights and metrics for approx-string-match
Gathering detailed insights and metrics for approx-string-match
ukkonen
Ukkonens approximate string matching algorithm for finding edit distance similar to Levenshtein
alif
Tool for fuzzy word search and approximate matching by AF-pairs
@a-s8h/liblevenshtein
Various utilities regarding Levenshtein transducers.
bitap
an approximate string matching algorithm
Fast approximate string matching library for JavaScript
npm install approx-string-match
Typescript
Module System
80
Supply Chain
95.7
Quality
75.7
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
53 Stars
69 Commits
4 Forks
3 Watchers
2 Branches
2 Contributors
Updated on Jun 12, 2025
Latest Version
2.0.0
Package Id
approx-string-match@2.0.0
Unpacked Size
19.04 kB
Size
6.95 kB
File Count
9
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
6
A library for approximate string matching.
This can be used to find occurrences of a pattern P (of length m) in a text T (of length n) allowing for up to a given number of errors (k), where errors may include insertions, substitutions or deletions of characters from the pattern.
For example the pattern "annd" occurs in the string "four score and seven" with one error.
The implementation uses a bit-parallel algorithm by G. Myers [1] which, to the best of my knowledge, is the state of the art algorithm for the online version of the problem (where the text and pattern cannot be preprocessed in advance). It runs in O((k/w) * n) expected-time where k <= m and w is the word size (32 in JavaScript). It also includes some additional optimizations suggested in [3]. See comments in the code for more details.
npm install --save approx-string-match
1import search from "approx-string-match";
2
3const text = "Four score and seven";
4const pattern = "annd";
5const matches = search(text, pattern, 2 /* max errors */);
6console.log(matches);
7
8// Outputs `[{ start: 11, end: 14, errors: 1 }]`
The library exports a single function search(text, pattern, maxErrors)
which
returns an array of the closest matches for pattern in text allowing up to
maxErrors errors.
1interface Match { 2 start: number; 3 end: number; 4 errors: number; 5} 6 7search(text: string, pattern: string, maxErrors: number): Match[]
The algorithm uses bitwise operations on integers. Since JavaScript only supports bitwise operations on 32-bit integers, that is the word size, regardless of the platform.
If JS gains support for bitwise operations on larger integers in future, that support could be used to speed up this library.
The library currently works on code units rather than code points, where the
code unit is a UTF-16 value. What this means is that a change to a unicode
character which requires multiple characters to represent in a JavaScript
string, such as emoji, would actually count as two changes rather than one. This
is because such chars require two elements to represent in a string (eg.
"😊".length
is 2).
For an overview of the different approaches to approximate string matching and the history of the development of solutions, there is a good survey paper [2].
[1] G. Myers, “A Fast Bit-Vector Algorithm for Approximate String Matching Based on Dynamic Programming,” vol. 46, no. 3, pp. 395–415, 1999.
[2] G. Navarro, “A guided tour to approximate string matching,” ACM Comput. Surv., vol. 33, no. 1, pp. 31–88, 2001.
[3] Šošić, M. (2014). "An SIMD dynamic programming c/c++ library" (Doctoral dissertation, Fakultet Elektrotehnike i računarstva, Sveučilište u Zagrebu).
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More