Irina Glushko 2389e7160b HW1 done | 3 år sedan | |
---|---|---|
.. | ||
scripts | 3 år sedan | |
test | 3 år sedan | |
CHANGELOG.md | 3 år sedan | |
LICENSE | 3 år sedan | |
README.md | 3 år sedan | |
index.js | 3 år sedan | |
package.json | 3 år sedan |
It provides a function that takes two string arguments and returns a hash like this:
{
steps: 5, // Levenstein demerau distance
relative: 0.7, // steps / length of the longer string
similarity: 0.3 // 1 - relative
}
npm install damerau-levenshtein
import * as levenshtien from 'damerau-levenshtein';
const lev = levenshtien('hello world', 'Hello World!');
// { steps: 4, relative: 0.3076923076923077, similarity: 0.6923076923076923 }
Please see tests for more insights.
import * as levenshtien from 'damerau-levenshtein';
interface LevenshteinResponse {
steps: number;
relative: number;
similarity: number;
}
const lev: LevenshteinResponse = levenshtien('hello world', 'Hello World!');
console.log(lev.steps);
// 2
console.log(lev.foo);
// TypeScript Error: Property 'foo' does not exist on type 'LevenshteinResponse'.