1.0.2 • Published 8 years ago

damerau-levenshtein-git v1.0.2

Weekly downloads
8
License
GPL-2.0
Repository
github
Last release
8 years ago

damerau-levenshtein-git

A fast, flexible and easy JavaScript port of the Damerau-Levenshtein string distance calculation algorithm used in Git.

Installing

npm install --save damerau-levenshtein-git

Example

const dl = require('damerau-levenshtein-git');

// Simplest invocation
console.log(dl("Floor", "Flower"))
// <= 3

// Run async
dl("Floor", "Flower", function(distance, source, target) {
    console.log(`${source} to ${target}: ${distance} steps`);
});
// "Floor to Flower: 3 steps"

Arguments

ArgumentReq?Description
sourceyesFirst string to compare
targetyesSecond string to compare
callbacknoIf present, run async and call callback(result, source, target)
wnoSwap cost multiplier
snoSubstitution cost multiplier
anoInsertion (add) cost multiplier
dnoDeletion cost multiplier

Return: Number indicating the steps needed to transform source into target.

Notes and license

This project is available on GitHub and npm.

The project is licensed as GPLv2, the license file is included in the project directory.

Original C source and work copyright Git. JavaScript port copyright 2016 Stefan Hamminga - prjct.net