Comparing version 0.0.1 to 0.0.2
module.exports = distance; | ||
function distance(a, b) { | ||
var table = []; | ||
var table = [], diag = 0, left, top; | ||
if (a.length === 0 || b.length === 0) return Math.max(a.length, b.length); | ||
for (var ii = 0, ilen = a.length + 1; ii !== ilen; ++ii) { | ||
table[ii] = []; | ||
for (var jj = 0, jlen = b.length + 1; jj !== jlen; ++jj) { | ||
if (ii === 0 || jj === 0) table[ii][jj] = Math.max(ii, jj); | ||
if (ii === 0 || jj === 0) table[jj] = Math.max(ii, jj); | ||
else { | ||
var diagPenalty = Number(a[ii-1] !== b[jj-1]); | ||
var diag = table[ii - 1][jj - 1] + diagPenalty; | ||
var top = table[ii - 1][jj] + 1; | ||
var left = table[ii][jj - 1] + 1; | ||
table[ii][jj] = Math.min(left, top, diag); | ||
diag += Number(a[ii-1] !== b[jj-1]); | ||
left = table[jj - 1] + 1; | ||
top = table[jj] + 1; | ||
table[jj] = Math.min(left, top, diag); | ||
diag = top - 1; | ||
} | ||
} | ||
} | ||
return table[a.length][b.length]; | ||
return table[b.length]; | ||
} | ||
@@ -5,3 +5,3 @@ { | ||
"description": "Given a dictionary, give spelling suggestions. ", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/CrypticSwarm/suggest-it", | ||
@@ -13,6 +13,4 @@ "repository": { | ||
"main": "lib/suggest-it.js", | ||
"licence": "MIT", | ||
"scripts": { "test": "tap test/*.js" }, | ||
"engines": { | ||
"node": "~0.6.9" | ||
}, | ||
"dependencies": {}, | ||
@@ -19,0 +17,0 @@ "devDependencies": { "tap": "~0.2.3" }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
4363
9
0
64
1