github-pages-deploy-action/node_modules/damerau-levenshtein
2020-03-31 08:40:00 -04:00
..
scripts Dependencies 2020-03-06 22:45:40 -05:00
test Dependencies 2020-03-06 22:45:40 -05:00
CHANGELOG.md Dependencies 2020-03-06 22:45:40 -05:00
index.js Dependencies 2020-03-06 22:45:40 -05:00
LICENSE Dependencies 2020-03-06 22:45:40 -05:00
package.json 3.4.3 2020-03-31 08:40:00 -04:00
README.md Dependencies 2020-03-06 22:45:40 -05:00

NPM

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
}

Install

npm install damerau-levenshtein

Use with ES6 modules

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.

Use with TypeScript

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'.