Newton's Programmatic Measurements

    levenshtein-edit-distance
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    levenshtein-edit-distance

    Build Coverage Downloads Size

    Levenshtein edit distance (by Vladimir Levenshtein). No cruft. Real fast.

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

    npm:

    npm install levenshtein-edit-distance

    API

    This package exports the following identifiers: levenshteinEditDistance. There is no default export.

    import {levenshteinEditDistance} from 'levenshtein-edit-distance'
    
    levenshteinEditDistance('levenshtein', 'levenshtein') // => 0
    levenshteinEditDistance('sitting', 'kitten') // => 3
    levenshteinEditDistance('gumbo', 'gambol') // => 2
    levenshteinEditDistance('saturday', 'sunday') // => 3
    
    // Case sensitive!
    levenshteinEditDistance('DwAyNE', 'DUANE') !== levenshtein('dwayne', 'DuAnE') // => true
    
    // Insensitive
    levenshteinEditDistance('DwAyNE', 'DUANE', true) === levenshtein('dwayne', 'DuAnE', true) // => true
    
    // Order insensitive
    levenshteinEditDistance('aarrgh', 'aargh') === levenshtein('aargh', 'aarrgh') // => true

    CLI

    Usage: levenshtein-edit-distance [options] word word
    
    Levenshtein edit distance. No cruft. Real fast.
    
    Options:
    
      -h, --help           output usage information
      -v, --version        output version number
      -i, --insensitive    ignore casing
    
    Usage:
    
    # output distance
    $ levenshtein-edit-distance sitting kitten
    # 3
    
    # output distance from stdin
    $ echo "saturday,sunday" | levenshtein-edit-distance
    # 3
    

    Related

    License

    MIT © Titus Wormer

    Install

    npm i levenshtein-edit-distance

    DownloadsWeekly Downloads

    75,448

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    10.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • wooorm
    • zeke