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

js-levenshtein

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-levenshtein - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

30

index.js
'use strict';
module.exports = (function()
{
function _min(d0, d1, d2, bx, ay)

@@ -45,8 +44,6 @@ {

if (la === 0) {
if (la === 0 || lb === 1) {
return lb;
}
var dist = new Array(la);
var x;

@@ -66,7 +63,12 @@ var y;

for (y = 0; y < la;) {
dist[y] = ++y;
var vector = new Array(la << 1);
bx0 = b.charCodeAt(offset);
dd = 1;
for (y = 0; y < la; y++) {
vector[la + y] = a.charCodeAt(offset + y);
vector[y] = dd = dd < y ? dd + 1 : bx0 === vector[la + y] ? y : y + 1;
}
for (x = 0; (x + 3) < lb;) {
for (x = 1; (x + 3) < lb;) {
bx0 = b.charCodeAt(offset + (d0 = x));

@@ -78,4 +80,4 @@ bx1 = b.charCodeAt(offset + (d1 = x + 1));

for (y = 0; y < la;) {
ay = a.charCodeAt(offset + y);
dy = dist[y];
ay = vector[la + y];
dy = vector[y];
d0 = _min(dy, d0, d1, bx0, ay);

@@ -85,3 +87,3 @@ d1 = _min(d0, d1, d2, bx1, ay);

dd = _min(d2, d3, dd, bx3, ay);
dist[y++] = dd;
vector[y++] = dd;
d3 = d2;

@@ -98,6 +100,6 @@ d2 = d1;

for (y = 0; y < la; y++) {
dy = dist[y];
dist[y] = dd = dy < d0 || dd < d0
? (dy > dd ? dd + 1 : dy + 1)
: bx0 === a.charCodeAt(offset + y)
dy = vector[y];
vector[y] = dd = dy < d0 || dd < d0
? dy > dd ? dd + 1 : dy + 1
: bx0 === vector[la + y]
? d0

@@ -104,0 +106,0 @@ : d0 + 1;

{
"name": "js-levenshtein",
"version": "1.0.0",
"version": "1.1.0",
"description": "An efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -1,2 +0,2 @@

# js-levenshtein
# js-levenshtein [![Build Status](https://travis-ci.org/gustf/js-levenshtein.svg?branch=master)](https://travis-ci.org/gustf/js-levenshtein)

@@ -32,16 +32,16 @@ An efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.

$ npm run bench
```
js-levenshtein
745,590 op/s » js-levenshtein/cached
667,378 op/s » js-levenshtein
533,400 op/s » leven
525,475 op/s » talisman
381,433 op/s » levenshtein-edit-distance
287,224 op/s » fast-levenshtein
80,848 op/s » levenshtein-component
24,762 op/s » levdist
27,333 op/s » ld
19,505 op/s » natural
13,413 op/s » levenshtein
```
655,992 op/s » js-levenshtein
542,796 op/s » leven
497,966 op/s » talisman
386,839 op/s » levenshtein-edit-distance
254,941 op/s » fast-levenshtein
69,857 op/s » levenshtein-component
21,688 op/s » levdist
24,631 op/s » ld
21,834 op/s » natural
13,984 op/s » levenshtein
```

@@ -48,0 +48,0 @@

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