Détail du package

tiny-levenshtein

fabiospampinato100.8kMIT1.1.0

A tiny implementation of the Levenshtein edit distance algorithm.

tiny, levenshtein, edit, distance

readme

Tiny Levenshtein

A tiny implementation of the Levenshtein edit distance algorithm.

Install

npm install tiny-levenshtein

Usage

import levenshtein from 'tiny-levenshtein';

// Let's compute the Levenshtein edit distance between two strings
// Strings are compared at the byte level

levenshtein ( 'kitten', 'sitting' ); // => 3
levenshtein ( '🤣', '😂' ); // => 2

// Let's compute the Levenshtein edit distance between two arrays
// Arrays are compared at the element level
// This can double-down as Unicode-aware string comparison too

levenshtein ( [1, 2, 3], [1, 4, 3] ); // => 1
levenshtein ( [...'🤣'], [...'😂'] ); // => 1

License

MIT © Fabio Spampinato