is-match

Create a matching function from a glob pattern, regex, string, array, object or function.
Install
Install with npm
$ npm i is-match --save
Usage
var isMatch = require('is-match');
Create matchers:
from a string:
var isMatch = matcher('a')
isMatch('a');
isMatch('b');
from a glob pattern:
var isMatch = matcher('*')
isMatch('a');
var isMatch = matcher('!b')
isMatch('a');
var isMatch = matcher('!b')
isMatch('b');
from an array of glob patterns:
var isMatch = matcher(['b'])
isMatch('a');
var isMatch = matcher(['b', 'a'])
isMatch('a');
var isMatch = matcher(['b', 'c', '*'])
isMatch('a');
from a regex:
var isMatch = matcher(/a/);
isMatch('a');
isMatch('b');
from a function:
var isMatch = matcher(function (val) {
return val === 'a';
});
isMatch('a');
isMatch('b');
from an object:
var isMatch = matcher({a: 'b'});
isMatch({a: 'b'});
isMatch({a: 'b', c: 'd'});
isMatch({e: 'f', c: 'd'});
Related projects
- has-glob: Returns
true
if an array has a glob pattern. | homepage
- is-glob: Returns
true
if the given string looks like a glob pattern. | homepage
- micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… more | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on September 08, 2015.