1.0.2 • Published 10 years ago
damerau-levenshtein-git v1.0.2
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-gitExample
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
| Argument | Req? | Description | 
|---|---|---|
| source | yes | First string to compare | 
| target | yes | Second string to compare | 
| callback | no | If present, run async and call callback(result, source, target) | 
| w | no | Swap cost multiplier | 
| s | no | Substitution cost multiplier | 
| a | no | Insertion (add) cost multiplier | 
| d | no | Deletion 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