levenshtein-edit-distance
Levenshtein edit distance (by Vladimir Levenshtein).
No cruft.
Real fast.
Install
This package is ESM only: Node 12+ is needed to use it and it must be import
ed
instead of require
d.
npm:
npm install levenshtein-edit-distance
API
This package exports the following identifiers: levenshteinEditDistance
.
There is no default export.
import {levenshteinEditDistance} from 'levenshtein-edit-distance'
levenshteinEditDistance('levenshtein', 'levenshtein')
levenshteinEditDistance('sitting', 'kitten')
levenshteinEditDistance('gumbo', 'gambol')
levenshteinEditDistance('saturday', 'sunday')
levenshteinEditDistance('DwAyNE', 'DUANE') !== levenshtein('dwayne', 'DuAnE')
levenshteinEditDistance('DwAyNE', 'DUANE', true) === levenshtein('dwayne', 'DuAnE', true)
levenshteinEditDistance('aarrgh', 'aargh') === levenshtein('aargh', 'aarrgh')
CLI
Usage: levenshtein-edit-distance [options] word word
Levenshtein edit distance. No cruft. Real fast.
Options:
-h, --help output usage information
-v, --version output version number
-i, --insensitive ignore casing
Usage:
# output distance
$ levenshtein-edit-distance sitting kitten
# 3
# output distance from stdin
$ echo "saturday,sunday" | levenshtein-edit-distance
# 3
Related
License
MIT © Titus Wormer