Miss any of our Open RFC calls?Watch the recordings here! »

matched

0.1.2 • Public • Published

matched NPM version

Extends minimatch with support for multiple patterns. Similar to multimatch, but returns expected results and passes all tests (see readme). Also similar to globule.match but more compact (and passes all globule.match tests).

Install

Install with npm:

npm i matched --save-dev

Usage

var matched = require('matched');
matched(['foo', 'bar', 'baz'], ['!*a*', '*z'])
// => ['baz']

Tests

In the command line, run:

mocha

All of the unit tests include tests for multimatch, the .match() method from globule, and this library, matched.

Comparison

The following comparison summarizes (part of) the motivation for creating this lib.

Given that we have an array of files:

var files = [
    'vendor/js/foo.js', 
    'vendor/js/bar.js', 
    'vendor/js/baz.js'
];

Using this glob pattern: ['!**/*z.js', '**/foo.js'], what should the results be? Here is the each lib would handle them.

Lib Result Notes
matched ['vendor/js/foo.js'] correct
globule.match ['vendor/js/foo.js'] correct
multimatch ['vendor/js/foo.js', 'vendor/js/bar.js'] incorrect, since we didn't ask for vendor/js/bar.js

See the tests for more examples.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on June 14, 2014.