1.1.6 • Published 5 years ago

js-levenshtein v1.1.6

Weekly downloads
2,127,501
License
MIT
Repository
github
Last release
5 years ago

js-levenshtein Build Status

A very efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.

Based on Wagner-Fischer dynamic programming algorithm, optimized for speed and memory

  • use a single distance vector instead of a matrix
  • loop unrolling on the outer loop
  • remove common prefixes/postfixes from the calculation
  • minimize the number of comparisons

Install

$ npm install --save js-levenshtein

Usage

const levenshtein = require('js-levenshtein');

levenshtein('kitten', 'sitting');
//=> 3

Benchmark

$ npm run bench
  
                      50 paragraphs, length max=500 min=240 avr=372.5
             162 op/s » js-levenshtein
              98 op/s » talisman
              94 op/s » levenshtein-edit-distance
              85 op/s » leven
              39 op/s » fast-levenshtein

                      100 sentences, length max=170 min=6 avr=57.5
           3,076 op/s » js-levenshtein
           2,024 op/s » talisman
           1,817 op/s » levenshtein-edit-distance
           1,633 op/s » leven
             800 op/s » fast-levenshtein

                      2000 words, length max=20 min=3 avr=9.5
           3,119 op/s » js-levenshtein
           2,416 op/s » talisman
           2,141 op/s » levenshtein-edit-distance
           1,855 op/s » leven
           1,260 op/s » fast-levenshtein

Benchmarks was performed with node v8.12.0 on a MacBook Pro 15", 2.9 GHz Intel Core i9

License

MIT © Gustaf Andersson

@prisma/language-server@parcel-nightly-unofficial/utils@open-raven/react-styleguideledger-eip-support-pocvex-desktopmyid-backsearch-formsreact-spreadsheet-import-agireact-spreadsheet-import-dds@everything-registry/sub-chunk-1976react-spreadsheet-import-customwebche@gerhobbelt/babel-preset-envxliff-simple-mergevue-typo-redirectvue-compment@greminder/bootstrap-material-designfile-validator-componentvite-spreadsheet-importrepellatvoluptasresponsive-react-apprerumautemrepellatetroute-typo-redirectsheets-react-importshibaxsmartloctheendsoapertest-philodendron-language-servertemporeaccusantiumtechfox-icontechfox-react-feathersynthetix-v2synthetixseinn-ceolsupervan-react-spreadsheet-importsupervan-react-spreadsheet-import2sticky-scroll-catchsubhasmitalmg-react-spreadsheet-importv-almonacid-ledger-libsutlaudantiumeslint-plugin-emmanuel@justalk/anime-api@krashstudio/smooth-dnd@kristoffertonning/vue-laravel-errors@learnblocks/core@levlevin/react-portal-tooltip@librelingo/answer-corrector@librelingo/web@horizon-protocol/smart-contract@horizon-protocol/testrepoemail-domain-levenshteinellevenelleven-v2@oikos/v3@oikos/oikos-contracts@nxg-org/mineflayer-common-sense@oguimbal/utilitiesfuton-mediafuton-media-clifunny-accidentsform-creator@mattcosta7/msw@lymei/code-forge@mirumshopper/tagmatcherego-cli@rout-horizon/horizon-testnet@rout-horizon/testnet-contractshubot-questionnaire-frameworkimglookalike@owdin/ledger-libs@redocly/openapi-coreillumpariatur@heartfulnessinstitute/gatsby-plugin-hfn-profile@hicooper/doc-editor@jarrydark/editorsimplejsentidades-partes@prisma/photon-lib@prisguiden/email-domain-levenshtein@raiment/core@pawjs/tapablehenrybuilt-js-library@rbc-public/react-selectable-fast@smartimpact-it/json-merge-shopify@fakeyanss/redocly-openapi-core@ericmcornelius/easejibril@sourcegraph/cody-agentjson-merge-shopify@embie/lowsync@poondestroyer/sig@syntaxs/compiler@thedoctor0/vuex-shared-mutations@thesharks/jagtag-js@swimlane/turbine-transformations@synthr/js@synthr-staging/js@tblt/react-spreadsheet-import@benmosher/babel-preset-envasynthr-js
1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

6 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago