Skip to content

Latest commit

 

History

History
94 lines (63 loc) · 1.52 KB

.verb.md

File metadata and controls

94 lines (63 loc) · 1.52 KB

Heads up!

See the release history to learn about breaking changes in the [v1.0.0 release]({%= homepage %}/releases/tag/1.0.0).

Usage

var isMatch = require('{%= name %}');

Create matchers:

from a string:

var isMatch = matcher('a')

isMatch('a');
//=> true

isMatch('b');
//=> false

from a glob pattern:

var isMatch = matcher('*')
isMatch('a'); //=> true

var isMatch = matcher('!b')
isMatch('a'); //=> true

var isMatch = matcher('!b')
isMatch('b'); //=> false

from an array of glob patterns:

var isMatch = matcher(['b'])
isMatch('a'); //=> false

var isMatch = matcher(['b', 'a'])
isMatch('a'); //=> true

var isMatch = matcher(['b', 'c', '*'])
isMatch('a'); //=> true

from a regex:

var isMatch = matcher(/a/);

isMatch('a');
//=> true

isMatch('b');
//=> false

from a function:

var isMatch = matcher(function  (val) {
  return val === 'a';
});
isMatch('a');
//=> true

isMatch('b');
//=> false

from an object:

var isMatch = matcher({a: 'b'});

isMatch({a: 'b'}); //=> true
isMatch({a: 'b', c: 'd'}); //=> false
isMatch({e: 'f', c: 'd'}); //=> false

Release history

v1.0.0

Potentially breaking changes

  • prior to 1.0, when an array of globs was passed, isMatch() would return true if any of the globs matched. As of 1.0, isMatch() only returns true when all globs match.
  • now does number comparisons. there are several ways to compare numbers, I'm open to a discussion or changes if necessary.