did-you-mean

0.0.1 • Public • Published

Did You Mean ...

Fuzzy match a word from your list of commands or keywords in Node.js to provide a friendly typo-safe human prompt.

You can use it in:

  • your CLI
  • a web application
  • URLs
  • etc.

Installation

npm install did-you-mean

Usage

var Matcher = require('did-you-mean');

// Create a matcher with a list of values
var m = new Matcher('init install update upgrade');

// Get the closest match
m.get('udpate');   // 'update'

// Set the threshold (the maximum Levenshtein distance)
m.setThreshold(3);

// List all matches
m.list('udpate');    // [ { value: 'update', distance: 2 }, { value: 'upgrade', distance: 3 } ]

// Set ignore case
m.ignoreCase();

// Set match case
m.matchCase();

// Add more values
m.add('merge', 'checkout', 'commit');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    23,878
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    23,878
  • 0.0.0
    0

Package Sidebar

Install

npm i did-you-mean

Weekly Downloads

23,878

Version

0.0.1

License

ISC

Last publish

Collaborators

  • inca