tiny-levenshtein

A tiny implementation of the Levenshtein edit distance algorithm.

MIT 3 个版本
安装
npm install tiny-levenshtein
yarn add tiny-levenshtein
pnpm add tiny-levenshtein
bun add tiny-levenshtein
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

版本列表
1.1.0 2025-06-29
1.0.1 2025-01-12
1.0.0 2022-06-21