Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-levenshtein

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-levenshtein - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

15

index.js

@@ -102,3 +102,3 @@ const peq = new Uint32Array(65535);

module.exports = (a, b) => {
exports.compare = (a, b) => {
if (a.length > b.length) {

@@ -117,1 +117,14 @@ const tmp = b;

exports.compare_many = (str, arr) => {
let min_distance = Infinity
let min_index = 0
for (let i = 0; i < arr.length; i++) {
const distance = this.compare(str, arr[i])
if (distance < min_distance) {
min_distance = distance
min_index = i
}
}
return arr[min_index]
}

2

package.json
{
"name": "node-levenshtein",
"version": "3.0.0",
"version": "3.0.1",
"description": "Fastest Levenshtein distance implementation in JS.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,5 +17,7 @@ # node-levenshtein :rocket:

console.log(levenshtein('lorem', 'ipsum'))
console.log(levenshtein.compare('fast', 'faster'))
//=> 4
console.log(levenshtein.compare_many('fast', ['slow', 'faster', 'fastest']))
//=> 'faster'
```

@@ -22,0 +24,0 @@

@@ -67,3 +67,3 @@ const levenshtein = (a, b) => {

while (i < words.length - 1) {
if (nodeLevenshtein(words[i], words[i + 1]) !== levenshtein(words[i], words[i + 1])) {
if (nodeLevenshtein.compare(words[i], words[i + 1]) !== levenshtein(words[i], words[i + 1])) {
errors++;

@@ -87,3 +87,3 @@ }

if (nodeLevenshtein(str1, str2) !== levenshtein(str1, str2)) {
if (nodeLevenshtein.compare(str1, str2) !== levenshtein(str1, str2)) {
errors++;

@@ -103,3 +103,3 @@ console.log('Randomized test:');

while (k < ps2.length) {
if (nodeLevenshtein(ps1[j].join(''), ps2[k].join('')) !== levenshtein(ps1[j].join(''), ps2[k].join(''))) {
if (nodeLevenshtein.compare(ps1[j].join(''), ps2[k].join('')) !== levenshtein(ps1[j].join(''), ps2[k].join(''))) {
const shrink = `${ps1[j].join('')} ${ps2[k].join('')}`;

@@ -106,0 +106,0 @@ if (shrink.length < shrinked.length) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc