How to use the levenshtein function from underscore.string

Find comprehensive JavaScript underscore.string.levenshtein code examples handpicked from public code repositorys.

32
33
34
35
36
37
38
39
40
41
// Read in the content
var expectedContent = fs.readFileSync('expected/' + filename, 'binary');
var actualContent = fs.readFileSync('actual/' + filename, 'binary');

// Calculate the difference in bits (accounts for random bits)
var difference = _.levenshtein(expectedContent, actualContent);

// Assert that we are under our threshold
var underThreshold = difference <= distance;
assert.ok(underThreshold, 'Bitwise difference of zip files "' + difference + '" should be under ' + distance + ' (' + filename + ')');
fork icon15
star icon90
watch icon0

306
307
308
309
310
311
312
313
314
315
latinize() {
  return new NyxString(v.latinise(this.__value__));
}

levenshtein(other) {
  const res = s.levenshtein(this.__value__, other.__value__);
  return new NyxDecimal(res);
}

lines() {
fork icon0
star icon0
watch icon0

+ 7 other calls in file