Levenshtein edit distance. No cruft. Real fast.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

readme.md

levenshtein-edit-distance Build Status Coverage Status

Levenshtein edit distance (by Vladimir Levenshtein). No cruft. Real fast.

API

Install:

npm install levenshtein-edit-distance

Use:

var levenshtein = require('levenshtein-edit-distance')

levenshtein('levenshtein', 'levenshtein') // => 0
levenshtein('sitting', 'kitten') // => 3
levenshtein('gumbo', 'gambol') // => 2
levenshtein('saturday', 'sunday') // => 3

/* Case sensitive! */
levenshtein('DwAyNE', 'DUANE') !== levenshtein('dwayne', 'DuAnE') // => true

/* Insensitive: */
levenshtein('DwAyNE', 'DUANE', true) === levenshtein('dwayne', 'DuAnE', true) // => true

/* Order insensitive */
levenshtein('aarrgh', 'aargh') === levenshtein('aargh', 'aarrgh') // => true

CLI

Install:

npm install -g levenshtein-edit-distance

Use:

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