Gathering detailed insights and metrics for cached-levenshtein
Gathering detailed insights and metrics for cached-levenshtein
npm install cached-levenshtein
Typescript
Module System
Node Version
NPM Version
63
Supply Chain
74.1
Quality
75
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
214
Last Day
1
Last Week
3
Last Month
7
Last Year
71
7 Commits
1 Watching
1 Branches
1 Contributors
Latest Version
1.0.0
Package Id
cached-levenshtein@1.0.0
Unpacked Size
4.02 kB
Size
1.83 kB
File Count
4
NPM Version
8.15.0
Node Version
16.17.1
Publised On
25 Apr 2023
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
200%
3
Compared to previous week
Last month
250%
7
Compared to previous month
Last year
-50.3%
71
Compared to previous year
3
4
cached-levenshtein is a package that provides a sometimes faster implementation of the Levenshtein distance algorithm by using caching. It is based on fastest-levenshtein, which is known for its impressive performance. If you need to find distances for a LOT of often repeated strings - this is your choice.
You can install cached-levenshtein via npm:
npm install cached-levenshtein
To use cached-levenshtein, you can simply import it and use the distance
method:
1const { distance } = require('cached-levenshtein'); 2 3const str1 = 'hello'; 4const str2 = 'world'; 5 6const result = distance(str1, str2); 7console.log(result); // Output: 4
This implementation of the Levenshtein distance algorithm uses caching to improve performance. If you have a lot of long strings to compare, this package can be more than 80 times faster than a regular Levenshtein distance implementation.
However, caching has an overhead, so if you know that your strings will always be different, using caching may be redundant.
The performance of cached-levenshtein is impressive, especially when compared to a regular Levenshtein distance implementation. Below is a chart that shows the performance difference between cached-levenshtein and a regular implementation for 1000 RANDOM strings. The more exact strings dataset contains, the better performance cached-based implementation will give.
string length | fastest-levenstein (op/sec) | cached-levenstein (op/sec) |
---|---|---|
4 | 40,121 | 7,856 |
8 | 20,671 | 7,927 |
16 | 10,605 | 6,862 |
32 | 4,872 | 6,142 |
64 | 1,008 | 3,983 |
128 | 328 | 2,636 |
256 | 98 | 1,762 |
512 | 22 | 993 |
1024 | 6 | 538 |
This package is based on fastest-levenshtein, which provides a fast implementation of the Levenshtein distance algorithm.
No vulnerabilities found.
No security vulnerabilities found.