Did-you-mean

did-you-mean

Fuzzy match a command from a list (typo-safety)

This module does a Fuzzy match a word from your list of commands or keywords from node.js/io.js to provide a friendly typo-safe human prompt.

Install it: npm install --save did-you-mean

API:

  • get -> Get the closest match.

  • setThreshold(3) -> Set the threshold (the maximum Levenshtein distance)

  • list('key') -> List all matches.

  • ignoreCase() -> Set ignore case.

  • matchCase() -> Set match case.

  • add('key1','key2',...); -> Add more values.

Usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
var Matcher = require('did-you-mean');

var m = new Matcher('init install update upgrade npm brew apt-get');

m.get('upgarde'); // "upgrade"

m.get('brwe'); // "brew"

m.get('atp-get'); // "apt-get"

m.values; // ["npm", "brew", "upgrade", "update", "apt-get"]

m.list('upgarde'); // {distance: 2, value: "upgrade"}

GIF FTW!

did-you-mean

Thanks to Boris Okunskiy for bringing did-you-mean to web and CLI.

Suggest a module

Comments