diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/micromatch/README.md | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/micromatch/README.md')
-rw-r--r-- | node_modules/micromatch/README.md | 1151 |
1 files changed, 806 insertions, 345 deletions
diff --git a/node_modules/micromatch/README.md b/node_modules/micromatch/README.md index 8fb391910..5dfa1498a 100644 --- a/node_modules/micromatch/README.md +++ b/node_modules/micromatch/README.md @@ -1,12 +1,58 @@ -# micromatch [](https://www.npmjs.com/package/micromatch) [](https://npmjs.org/package/micromatch) [](https://travis-ci.org/jonschlinkert/micromatch) +# micromatch [](https://www.npmjs.com/package/micromatch) [](https://npmjs.org/package/micromatch) [](https://npmjs.org/package/micromatch) [](https://travis-ci.org/micromatch/micromatch) [](https://ci.appveyor.com/project/micromatch/micromatch) > Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. -Micromatch supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch). - -* [mm()](#usage) is the same as [multimatch()](https://github.com/sindresorhus/multimatch) -* [mm.match()](#match) is the same as [minimatch.match()](https://github.com/isaacs/minimatch) -* use [mm.isMatch()](#ismatch) instead of [minimatch()](https://github.com/isaacs/minimatch) +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. + +## Table of Contents + +<details> +<summary><strong>Details</strong></summary> + +- [Install](#install) +- [Quickstart](#quickstart) +- [Why use micromatch?](#why-use-micromatch) + * [Matching features](#matching-features) +- [Switching to micromatch](#switching-to-micromatch) + * [From minimatch](#from-minimatch) + * [From multimatch](#from-multimatch) +- [API](#api) +- [Options](#options) + * [options.basename](#optionsbasename) + * [options.bash](#optionsbash) + * [options.cache](#optionscache) + * [options.dot](#optionsdot) + * [options.failglob](#optionsfailglob) + * [options.ignore](#optionsignore) + * [options.matchBase](#optionsmatchbase) + * [options.nobrace](#optionsnobrace) + * [options.nocase](#optionsnocase) + * [options.nodupes](#optionsnodupes) + * [options.noext](#optionsnoext) + * [options.nonegate](#optionsnonegate) + * [options.noglobstar](#optionsnoglobstar) + * [options.nonull](#optionsnonull) + * [options.nullglob](#optionsnullglob) + * [options.snapdragon](#optionssnapdragon) + * [options.sourcemap](#optionssourcemap) + * [options.unescape](#optionsunescape) + * [options.unixify](#optionsunixify) +- [Extended globbing](#extended-globbing) + * [extglobs](#extglobs) + * [braces](#braces) + * [regex character classes](#regex-character-classes) + * [regex groups](#regex-groups) + * [POSIX bracket expressions](#posix-bracket-expressions) +- [Notes](#notes) + * [Bash 4.3 parity](#bash-43-parity) + * [Backslashes](#backslashes) +- [Contributing](#contributing) +- [Benchmarks](#benchmarks) + * [Running benchmarks](#running-benchmarks) + * [Latest results](#latest-results) +- [About](#about) + +</details> ## Install @@ -16,65 +62,75 @@ Install with [npm](https://www.npmjs.com/): $ npm install --save micromatch ``` -## Start matching! +## Quickstart ```js var mm = require('micromatch'); -console.log(mm([''])) +mm(list, patterns[, options]); ``` -*** +The [main export](#micromatch) takes a list of strings and one or more glob patterns: -### Features +```js +console.log(mm(['foo', 'bar', 'qux'], ['f*', 'b*'])); +//=> ['foo', 'bar'] +``` -* [Drop-in replacement](#switch-from-minimatch) for [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch) -* Built-in support for multiple glob patterns, like `['foo/*.js', '!bar.js']` -* [Brace Expansion](https://github.com/jonschlinkert/braces) (`foo/bar-{1..5}.md`, `one/{two,three}/four.md`) -* Typical glob patterns, like `**/*`, `a/b/*.js`, or `['foo/*.js', '!bar.js']` -* Methods like `.isMatch()`, `.contains()` and `.any()` +Use [.isMatch()](#ismatch) to get true/false: -**Extended globbing features:** +```js +console.log(mm.isMatch('foo', 'f*')); +//=> true +``` -* Logical `OR` (`foo/bar/(abc|xyz).js`) -* Regex character classes (`foo/bar/baz-[1-5].js`) -* POSIX [bracket expressions](https://github.com/jonschlinkert/expand-brackets) (`**/[[:alpha:][:digit:]]/`) -* [extglobs](https://github.com/jonschlinkert/extglob) (`**/+(x|y)`, `!(a|b)`, etc). +[Switching](#switching-to-micromatch) from minimatch and multimatch is easy! -You can combine these to create whatever matching patterns you need. +## Why use micromatch? -**Example** +> micromatch is a [drop-in replacement](#switching-to-micromatch) for minimatch and multimatch -```js -// double-negation! -mm(['fa', 'fb', 'f', 'fo'], '!(f!(o))'); -//=> ['fo'] -``` +* Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch) +* Micromatch uses [snapdragon](https://github.com/jonschlinkert/snapdragon) for parsing and compiling globs, which provides granular control over the entire conversion process in a way that is easy to understand, reason about, and maintain. +* More consistently accurate matching [than minimatch](https://github.com/yarnpkg/yarn/pull/3339), with more than 36,000 [test assertions](./test) to prove it. +* More complete support for the Bash 4.3 specification than minimatch and multimatch. In fact, micromatch passes _all of the spec tests_ from bash, including some that bash still fails. +* [Faster matching](#benchmarks), from a combination of optimized glob patterns, faster algorithms, and regex caching. +* [Micromatch is safer](https://github.com/micromatch/braces#braces-is-safe), and is not subject to DoS with brace patterns, like minimatch and multimatch. +* More reliable windows support than minimatch and multimatch. + +### Matching features + +* Support for multiple glob patterns (no need for wrappers like multimatch) +* Wildcards (`**`, `*.js`) +* Negation (`'!a/*.js'`, `'*!(b).js']`) +* [extglobs](https://github.com/micromatch/extglob) (`+(x|y)`, `!(a|b)`) +* [POSIX character classes](https://github.com/micromatch/expand-brackets) (`[[:alpha:][:digit:]]`) +* [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`) +* regex character classes (`foo-[1-5].js`) +* regex logical "or" (`foo/(abc|xyz).js`) + +You can mix and match these features to create whatever patterns you need! -## Why switch to micromatch? +## Switching to micromatch -* Native support for multiple glob patterns, no need for wrappers like [multimatch](https://github.com/sindresorhus/multimatch) -* [10-55x faster](#benchmarks) and more performant than [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch). This is achieved through a combination of caching and regex optimization strategies, a fundamentally different approach than minimatch. -* More extensive support for the Bash 4.3 specification -* More complete extglob support -* Extensive [unit tests](./test) (approx. 1,300 tests). Minimatch fails many of the tests. +There is one notable difference between micromatch and minimatch in regards to how backslashes are handled. See [the notes about backslashes](#backslashes) for more information. -### Switch from minimatch +### From minimatch -Use `mm.isMatch()` instead of `minimatch()`: +Use [mm.isMatch()](#ismatch) instead of `minimatch()`: ```js mm.isMatch('foo', 'b*'); //=> false ``` -Use `mm.match()` instead of `minimatch.match()`: +Use [mm.match()](#match) instead of `minimatch.match()`: ```js mm.match(['foo', 'bar'], 'b*'); //=> 'bar' ``` -### Switch from multimatch +### From multimatch Same signature: @@ -83,436 +139,756 @@ mm(['foo', 'bar', 'baz'], ['f*', '*z']); //=> ['foo', 'baz'] ``` -*** +## API + +### [micromatch](index.js#L41) -## Usage +The main function takes a list of strings and one or more glob patterns to use for matching. + +**Params** -Add micromatch to your node.js project: +* `list` **{Array}**: A list of strings to match +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Array}**: Returns an array of matches + +**Example** ```js var mm = require('micromatch'); +mm(list, patterns[, options]); + +console.log(mm(['a.js', 'a.txt'], ['*.js'])); +//=> [ 'a.js' ] ``` -**Signature** +### [.match](index.js#L93) -```js -mm(array_of_strings, glob_patterns[, options]); -``` +Similar to the main function, but `pattern` must be a string. + +**Params** + +* `list` **{Array}**: Array of strings to match +* `pattern` **{String}**: Glob pattern to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Array}**: Returns an array of matches **Example** ```js -mm(['foo', 'bar', 'baz'], 'b*'); -//=> ['bar', 'baz'] +var mm = require('micromatch'); +mm.match(list, pattern[, options]); + +console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a')); +//=> ['a.a', 'a.aa'] ``` -### Usage examples +### [.isMatch](index.js#L154) + +Returns true if the specified `string` matches the given glob `pattern`. + +**Params** -**Brace expansion** +* `string` **{String}**: String to match +* `pattern` **{String}**: Glob pattern to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if the string matches the glob pattern. -Match files with `.js` or `.txt` extensions. +**Example** ```js -mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); -//=> ['a.js', 'c.txt'] +var mm = require('micromatch'); +mm.isMatch(string, pattern[, options]); + +console.log(mm.isMatch('a.a', '*.a')); +//=> true +console.log(mm.isMatch('a.b', '*.a')); +//=> false ``` -**Extglobs** +### [.some](index.js#L192) + +Returns true if some of the strings in the given `list` match any of the given glob `patterns`. + +**Params** + +* `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found. +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if any patterns match `str` -Match anything except for files with the `.md` extension. +**Example** ```js -mm(files, '**/*.!(md)'); +var mm = require('micromatch'); +mm.some(list, patterns[, options]); -//=> ['a.js', 'c.txt'] +console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); +// true +console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); +// false ``` -**Multiple patterns** +### [.every](index.js#L228) -Match using an array of patterns. +Returns true if every string in the given `list` matches any of the given glob `patterns`. + +**Params** + +* `list` **{String|Array}**: The string or array of strings to test. +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if any patterns match `str` + +**Example** ```js -mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); -//=> ['a.md', 'c.txt'] +var mm = require('micromatch'); +mm.every(list, patterns[, options]); + +console.log(mm.every('foo.js', ['foo.js'])); +// true +console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); +// true +console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); +// false +console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); +// false ``` -**Negation patterns:** +### [.any](index.js#L260) + +Returns true if **any** of the given glob `patterns` match the specified `string`. + +**Params** -Behavior is designed to be what users would expect, based on conventions that are already well-established. +* `str` **{String|Array}**: The string to test. +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if any patterns match `str` -* [minimatch](https://github.com/isaacs/minimatch) behavior is used when the pattern is a string, so patterns are **inclusive by default**. -* [multimatch](https://github.com/sindresorhus/multimatch) behavior is used when an array of patterns is passed, so patterns are **exclusive by default**. +**Example** ```js -mm(['a.js', 'b.md', 'c.txt'], '!*.{js,txt}'); -//=> ['b.md'] +var mm = require('micromatch'); +mm.any(string, patterns[, options]); -mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.*', '!*.{js,txt}']); -//=> ['a.md', 'd.json'] +console.log(mm.any('a.a', ['b.*', '*.a'])); +//=> true +console.log(mm.any('a.a', 'b.*')); +//=> false ``` -*** +### [.all](index.js#L308) + +Returns true if **all** of the given `patterns` match the specified string. + +**Params** + +* `str` **{String|Array}**: The string to test. +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if any patterns match `str` -## API methods +**Example** ```js var mm = require('micromatch'); -``` +mm.all(string, patterns[, options]); -### .match +console.log(mm.all('foo.js', ['foo.js'])); +// true -```js -mm.match(array, globString); +console.log(mm.all('foo.js', ['*.js', '!foo.js'])); +// false + +console.log(mm.all('foo.js', ['*.js', 'foo.js'])); +// true + +console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); +// true ``` -Return an array of files that match the given glob pattern. Useful if you only need to use a single glob pattern. +### [.not](index.js#L340) + +Returns a list of strings that _**do not match any**_ of the given `patterns`. + +**Params** + +* `list` **{Array}**: Array of strings to match. +* `patterns` **{String|Array}**: One or more glob pattern to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns. **Example** ```js -mm.match(['ab', 'a/b', 'bb', 'b/c'], '?b'); -//=> ['ab', 'bb'] +var mm = require('micromatch'); +mm.not(list, patterns[, options]); -mm.match(['ab', 'a/b', 'bb', 'b/c'], '*/b'); -//=> ['a/b'] +console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); +//=> ['b.b', 'c.c'] ``` -### .isMatch +### [.contains](index.js#L376) -```js -mm.isMatch(filepath, globString); -``` +Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string. + +**Params** -Returns true if a file path matches the given glob pattern. +* `str` **{String}**: The string to match. +* `patterns` **{String|Array}**: Glob pattern to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns true if the patter matches any part of `str`. **Example** ```js -mm.isMatch('.verb.md', '*.md'); -//=> false +var mm = require('micromatch'); +mm.contains(string, pattern[, options]); -mm.isMatch('.verb.md', '*.md', {dot: true}); +console.log(mm.contains('aa/bb/cc', '*b')); //=> true +console.log(mm.contains('aa/bb/cc', '*d')); +//=> false ``` -### .contains +### [.matchKeys](index.js#L432) + +Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead. -Returns true if any part of a file path matches the given glob pattern. Think of this is "has path" versus "is path". +**Params** + +* `object` **{Object}**: The object with keys to filter. +* `patterns` **{String|Array}**: One or more glob patterns to use for matching. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Object}**: Returns an object with only keys that match the given patterns. **Example** -`.isMatch()` would return false for both of the following: +```js +var mm = require('micromatch'); +mm.matchKeys(object, patterns[, options]); + +var obj = { aa: 'a', ab: 'b', ac: 'c' }; +console.log(mm.matchKeys(obj, '*b')); +//=> { ab: 'b' } +``` + +### [.matcher](index.js#L461) + +Returns a memoized matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match. + +**Params** + +* `pattern` **{String}**: Glob pattern +* `options` **{Object}**: See available [options](#options) for changing how matches are performed. +* `returns` **{Function}**: Returns a matcher function. + +**Example** ```js -mm.contains('a/b/c', 'a/b'); -//=> true +var mm = require('micromatch'); +mm.matcher(pattern[, options]); -mm.contains('a/b/c', 'a/*'); +var isMatch = mm.matcher('*.!(*a)'); +console.log(isMatch('a.a')); +//=> false +console.log(isMatch('a.b')); //=> true ``` -### .matcher +### [.capture](index.js#L536) -Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of this method is that the pattern can be compiled outside of a loop. +Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match. -**Pattern** - -Can be any of the following: +**Params** -* `glob/string` -* `regex` -* `function` +* `pattern` **{String}**: Glob pattern to use for matching. +* `string` **{String}**: String to match +* `options` **{Object}**: See available [options](#options) for changing how matches are performed +* `returns` **{Boolean}**: Returns an array of captures if the string matches the glob pattern, otherwise `null`. **Example** ```js -var isMatch = mm.matcher('*.md'); -var files = []; +var mm = require('micromatch'); +mm.capture(pattern, string[, options]); -['a.md', 'b.txt', 'c.md'].forEach(function(fp) { - if (isMatch(fp)) { - files.push(fp); - } -}); +console.log(mm.capture('test/*.js', 'test/foo.js')); +//=> ['foo'] +console.log(mm.capture('test/*.js', 'foo/bar.css')); +//=> null ``` -### .filter +### [.makeRe](index.js#L571) -Returns a function that can be passed to `Array#filter()`. +Create a regular expression from the given glob `pattern`. **Params** -* `patterns` **{String|Array}**: +* `pattern` **{String}**: A glob pattern to convert to regex. +* `options` **{Object}**: See available [options](#options) for changing how matches are performed. +* `returns` **{RegExp}**: Returns a regex created from the given pattern. -**Examples** - -Single glob: +**Example** ```js -var fn = mm.filter('*.md'); -['a.js', 'b.txt', 'c.md'].filter(fn); -//=> ['c.md'] +var mm = require('micromatch'); +mm.makeRe(pattern[, options]); -var fn = mm.filter('[a-c]'); -['a', 'b', 'c', 'd', 'e'].filter(fn); -//=> ['a', 'b', 'c'] +console.log(mm.makeRe('*.js')); +//=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ ``` -Array of glob patterns: +### [.braces](index.js#L618) + +Expand the given brace `pattern`. + +**Params** + +* `pattern` **{String}**: String with brace pattern to expand. +* `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options. +* `returns` **{Array}** + +**Example** ```js -var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; +var mm = require('micromatch'); +console.log(mm.braces('foo/{a,b}/bar')); +//=> ['foo/(a|b)/bar'] -var fn = mm.filter(['{1..10}', '![7-9]', '!{3..4}']); -arr.filter(fn); -//=> [1, 2, 5, 6, 10] +console.log(mm.braces('foo/{a,b}/bar', {expand: true})); +//=> ['foo/(a|b)/bar'] ``` -_(Internally this function generates the matching function by using the [matcher](#matcher) method. You can use the [matcher](#matcher) method directly to create your own filter function)_ +### [.create](index.js#L685) + +Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST. + +**Params** -### .any +* `pattern` **{String}**: Glob pattern to parse and compile. +* `options` **{Object}**: Any [options](#options) to change how parsing and compiling is performed. +* `returns` **{Object}**: Returns an object with the parsed AST, compiled string and optional source map. -Returns true if a file path matches any of the given patterns. +**Example** ```js -mm.any(filepath, patterns, options); +var mm = require('micromatch'); +mm.create(pattern[, options]); + +console.log(mm.create('abc/*.js')); +// [{ options: { source: 'string', sourcemap: true }, +// state: {}, +// compilers: +// { ... }, +// output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js', +// ast: +// { type: 'root', +// errors: [], +// nodes: +// [ ... ], +// dot: false, +// input: 'abc/*.js' }, +// parsingErrors: [], +// map: +// { version: 3, +// sources: [ 'string' ], +// names: [], +// mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE', +// sourcesContent: [ 'abc/*.js' ] }, +// position: { line: 1, column: 28 }, +// content: {}, +// files: {}, +// idx: 6 }] ``` +### [.parse](index.js#L732) + +Parse the given `str` with the given `options`. + **Params** -* filepath `{String}`: The file path to test. -* patterns `{String|Array}`: One or more glob patterns -* options: `{Object}`: options to pass to the `.matcher()` method. +* `str` **{String}** +* `options` **{Object}** +* `returns` **{Object}**: Returns an AST **Example** ```js -mm.any('abc', ['!*z']); -//=> true -mm.any('abc', ['a*', 'z*']); -//=> true -mm.any('abc', 'a*'); -//=> true -mm.any('abc', ['z*']); -//=> false +var mm = require('micromatch'); +mm.parse(pattern[, options]); + +var ast = mm.parse('a/{b,c}/d'); +console.log(ast); +// { type: 'root', +// errors: [], +// input: 'a/{b,c}/d', +// nodes: +// [ { type: 'bos', val: '' }, +// { type: 'text', val: 'a/' }, +// { type: 'brace', +// nodes: +// [ { type: 'brace.open', val: '{' }, +// { type: 'text', val: 'b,c' }, +// { type: 'brace.close', val: '}' } ] }, +// { type: 'text', val: '/d' }, +// { type: 'eos', val: '' } ] } ``` -### .expand +### [.compile](index.js#L780) -Returns an object with a regex-compatible string and tokens. +Compile the given `ast` or string with the given `options`. -```js -mm.expand('*.js'); +**Params** -// when `track` is enabled (for debugging), the `history` array is used -// to record each mutation to the glob pattern as it's converted to regex -{ options: { track: false, dot: undefined, makeRe: true, negated: false }, - pattern: '(.*\\/|^)bar\\/(?:(?!(?:^|\\/)\\.).)*?', - history: [], - tokens: - { path: - { whole: '**/bar/**', - dirname: '**/bar/', - filename: '**', - basename: '**', - extname: '', - ext: '' }, - is: - { glob: true, - negated: false, - globstar: true, - dotfile: false, - dotdir: false }, - match: {}, - original: '**/bar/**', - pattern: '**/bar/**', - base: '' } } +* `ast` **{Object|String}** +* `options` **{Object}** +* `returns` **{Object}**: Returns an object that has an `output` property with the compiled string. + +**Example** + +```js +var mm = require('micromatch'); +mm.compile(ast[, options]); + +var ast = mm.parse('a/{b,c}/d'); +console.log(mm.compile(ast)); +// { options: { source: 'string' }, +// state: {}, +// compilers: +// { eos: [Function], +// noop: [Function], +// bos: [Function], +// brace: [Function], +// 'brace.open': [Function], +// text: [Function], +// 'brace.close': [Function] }, +// output: [ 'a/(b|c)/d' ], +// ast: +// { ... }, +// parsingErrors: [] } ``` -### .makeRe +### [.clearCache](index.js#L801) + +Clear the regex cache. -Create a regular expression for matching file paths based on the given pattern: +**Example** ```js -mm.makeRe('*.js'); -//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ +mm.clearCache(); ``` ## Options -### options.unixify +* [basename](#optionsbasename) +* [bash](#optionsbash) +* [cache](#optionscache) +* [dot](#optionsdot) +* [failglob](#optionsfailglob) +* [ignore](#optionsignore) +* [matchBase](#optionsmatchBase) +* [nobrace](#optionsnobrace) +* [nocase](#optionsnocase) +* [nodupes](#optionsnodupes) +* [noext](#optionsnoext) +* [noglobstar](#optionsnoglobstar) +* [nonull](#optionsnonull) +* [nullglob](#optionsnullglob) +* [snapdragon](#optionssnapdragon) +* [sourcemap](#optionssourcemap) +* [unescape](#optionsunescape) +* [unixify](#optionsunixify) + +### options.basename + +Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`. + +**Type**: `Boolean` + +**Default**: `false` -Normalize slashes in file paths and glob patterns to forward slashes. +**Example** + +```js +mm(['a/b.js', 'a/c.md'], '*.js'); +//=> [] + +mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true}); +//=> ['a/b.js'] +``` -Type: `{Boolean}` +### options.bash -Default: `undefined` on non-windows, `true` on windows. +Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**. Instead, the star is treated the same as an other star. + +**Type**: `Boolean` + +**Default**: `true` + +**Example** + +```js +var files = ['abc', 'ajz']; +console.log(mm(files, '[a-c]*')); +//=> ['abc', 'ajz'] + +console.log(mm(files, '[a-c]*', {bash: false})); +``` + +### options.cache + +Disable regex and function memoization. + +**Type**: `Boolean` + +**Default**: `undefined` ### options.dot -Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch). +Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`. -Type: `{Boolean}` +**Type**: `Boolean` -Default: `false` +**Default**: `false` -### options.unescape +### options.failglob -Unescape slashes in glob patterns. Use cautiously, especially on windows. +Similar to the `--failglob` behavior in Bash, throws an error when no matches are found. -Type: `{Boolean}` +**Type**: `Boolean` -Default: `undefined` +**Default**: `undefined` -**Example** +### options.ignore -```js -mm.isMatch('abc', '\\a\\b\\c', {unescape: true}); -//=> true -``` +String or array of glob patterns to match files to ignore. + +**Type**: `String|Array` + +**Default**: `undefined` + +### options.matchBase + +Alias for [options.basename](#options-basename). + +### options.nobrace + +Disable expansion of brace patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nobrace`. + +**Type**: `Boolean` + +**Default**: `undefined` + +See [braces](https://github.com/micromatch/braces) for more information about extended brace expansion. + +### options.nocase + +Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch). + +**Type**: `Boolean` + +**Default**: `undefined` ### options.nodupes Remove duplicate elements from the result array. -Type: `{Boolean}` +**Type**: `Boolean` -Default: `undefined` +**Default**: `undefined` **Example** Example of using the `unescape` and `nodupes` options together: ```js -mm.match(['abc', '\\a\\b\\c'], '\\a\\b\\c', {unescape: true}); -//=> ['abc', 'abc'] +mm.match(['a/b/c', 'a/b/c'], 'a/b/c'); +//=> ['a/b/c', 'a/b/c'] -mm.match(['abc', '\\a\\b\\c'], '\\a\\b\\c', {unescape: true, nodupes: true}); +mm.match(['a/b/c', 'a/b/c'], 'a/b/c', {nodupes: true}); //=> ['abc'] ``` -### options.matchBase +### options.noext -Allow glob patterns without slashes to match a file path based on its basename. . Same behavior as [minimatch](https://github.com/isaacs/minimatch). +Disable extglob support, so that extglobs are regarded as literal characters. -Type: `{Boolean}` +**Type**: `Boolean` -Default: `false` +**Default**: `undefined` -**Example** +**Examples** ```js -mm(['a/b.js', 'a/c.md'], '*.js'); -//=> [] +mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)'); +//=> ['a/b', 'a/!(z)'] -mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true}); -//=> ['a/b.js'] +mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', {noext: true}); +//=> ['a/!(z)'] (matches only as literal characters) ``` -### options.nobraces +### options.nonegate -Don't expand braces in glob patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) `nobrace`. +Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match. -Type: `{Boolean}` +**Type**: `Boolean` -Default: `undefined` +**Default**: `undefined` -See [braces](https://github.com/jonschlinkert/braces) for more information about extended brace expansion. +### options.noglobstar -### options.nobrackets +Disable matching with globstars (`**`). -Don't expand POSIX bracket expressions. +**Type**: `Boolean` -Type: `{Boolean}` +**Default**: `undefined` -Default: `undefined` +```js +mm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**'); +//=> ['a/b', 'a/b/c', 'a/b/c/d'] -See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about extended bracket expressions. +mm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**', {noglobstar: true}); +//=> ['a/b'] +``` -### options.noextglob +### options.nonull -Don't expand extended globs. +Alias for [options.nullglob](#options-nullglob). -Type: `{Boolean}` +### options.nullglob -Default: `undefined` +If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`. -See [extglob](https://github.com/jonschlinkert/extglob) for more information about extended globs. +**Type**: `Boolean` -### options.nocase +**Default**: `undefined` -Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch). +### options.snapdragon -Type: `{Boolean}` +Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon), to customize parsers or compilers. -Default: `false` +**Type**: `Object` -### options.nonegate +**Default**: `undefined` -Disallow negation (`!`) patterns. +### options.sourcemap -Type: `{Boolean}` +Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods. -Default: `false` +_(Note that sourcemaps are currently not enabled for brace patterns)_ -### options.nonull +**Examples** -If `true`, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch). +``` js +var mm = require('micromatch'); +var pattern = '*(*(of*(a)x)z)'; + +var res = mm.create('abc/*.js', {sourcemap: true}); +console.log(res.map); +// { version: 3, +// sources: [ 'string' ], +// names: [], +// mappings: 'AAAA,GAAG,EAAC,iBAAC,EAAC,EAAE', +// sourcesContent: [ 'abc/*.js' ] } + +var ast = mm.parse('abc/**/*.js'); +var res = mm.compile(ast, {sourcemap: true}); +console.log(res.map); +// { version: 3, +// sources: [ 'string' ], +// names: [], +// mappings: 'AAAA,GAAG,EAAC,2BAAE,EAAC,iBAAC,EAAC,EAAE', +// sourcesContent: [ 'abc/**/*.js' ] } + +var ast = mm.parse(pattern); +var res = mm.compile(ast, {sourcemap: true}); +console.log(res.map); +// { version: 3, +// sources: [ 'string' ], +// names: [], +// mappings: 'AAAA,CAAE,CAAE,EAAE,CAAE,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC', +// sourcesContent: [ '*(*(of*(a)x)z)' ] } +``` -Type: `{Boolean}` +### options.unescape -Default: `false` +Remove backslashes from returned matches. -### options.cache +**Type**: `Boolean` -Cache the platform (e.g. `win32`) to prevent this from being looked up for every filepath. +**Default**: `undefined` -Type: `{Boolean}` +**Example** -Default: `true` +In this example we want to match a literal `*`: -*** +```js +mm.match(['abc', 'a\\*c'], 'a\\*c'); +//=> ['a\\*c'] -## Other features +mm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true}); +//=> ['a*c'] +``` -Micromatch also supports the following. +### options.unixify -### Extended globbing +Convert path separators on returned files to posix/unix-style forward slashes. -#### extglobs +**Type**: `Boolean` -Extended globbing, as described by the bash man page: +**Default**: `true` on windows, `false` everywhere else -| **pattern** | **regex equivalent** | **description** | -| --- | --- | --- | -| `?(pattern-list)` | `(... | ...)?` | Matches zero or one occurrence of the given patterns | -| `*(pattern-list)` | `(... | ...)*` | Matches zero or more occurrences of the given patterns | -| `+(pattern-list)` | `(... | ...)+` | Matches one or more occurrences of the given patterns | -| `@(pattern-list)` | `(... | ...)` <sup>*</sup> | Matches one of the given patterns | -| `!(pattern-list)` | N/A | Matches anything except one of the given patterns | +**Example** -<sup><strong>*</strong></sup> `@` isn't a RegEx character. +```js +mm.match(['a\\b\\c'], 'a/**'); +//=> ['a/b/c'] + +mm.match(['a\\b\\c'], {unixify: false}); +//=> ['a\\b\\c'] +``` + +## Extended globbing -Powered by [extglob](https://github.com/jonschlinkert/extglob). Visit that library for the full range of options or to report extglob related issues. +Micromatch also supports extended globbing features. -See [extglob](https://github.com/jonschlinkert/extglob) for more information about extended globs. +### extglobs + +Extended globbing, as described by the bash man page: + +| **pattern** | **regex equivalent** | **description** | +| --- | --- | --- | +| `?(pattern)` | `(pattern)?` | Matches zero or one occurrence of the given patterns | +| `*(pattern)` | `(pattern)*` | Matches zero or more occurrences of the given patterns | +| `+(pattern)` | `(pattern)+` | Matches one or more occurrences of the given patterns | +| `@(pattern)` | `(pattern)` <sup>*</sup> | Matches one of the given patterns | +| `!(pattern)` | N/A (equivalent regex is much more complicated) | Matches anything except one of the given patterns | -#### brace expansion +<sup><strong>*</strong></sup> Note that `@` isn't a RegEx character. -In simple cases, brace expansion appears to work the same way as the logical `OR` operator. For example, `(a|b)` will achieve the same result as `{a,b}`. +Powered by [extglob](https://github.com/micromatch/extglob). Visit that library for the full range of options or to report extglob related issues. -Here are some powerful features unique to brace expansion (versus character classes): +### braces -* range expansion: `a{1..3}b/*.js` expands to: `['a1b/*.js', 'a2b/*.js', 'a3b/*.js']` -* nesting: `a{c,{d,e}}b/*.js` expands to: `['acb/*.js', 'adb/*.js', 'aeb/*.js']` +Brace patterns can be used to match specific ranges or sets of characters. For example, the pattern `*/{1..3}/*` would match any of following strings: -Visit [braces](https://github.com/jonschlinkert/braces) to ask questions and create an issue related to brace-expansion, or to see the full range of features and options related to brace expansion. +``` +foo/1/bar +foo/2/bar +foo/3/bar +baz/1/qux +baz/2/qux +baz/3/qux +``` -#### regex character classes +Visit [braces](https://github.com/micromatch/braces) to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues. -With the exception of brace expansion (`{a,b}`, `{1..5}`, etc), most of the special characters convert directly to regex, so you can expect them to follow the same rules and produce the same results as regex. +### regex character classes -For example, given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: +Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']` * `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']` @@ -521,7 +897,7 @@ For example, given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: Learn about [regex character classes](http://www.regular-expressions.info/charclass.html). -#### regex groups +### regex groups Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: @@ -529,161 +905,246 @@ Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`: * `(b|d).js`: would match either `b` or `d`, returning `['b.js', 'd.js']` * `(b|[A-Z]).js`: would match either `b` or an uppercase letter, returning `['b.js', 'E.js']` -As with regex, parenthese can be nested, so patterns like `((a|b)|c)/b` will work. But it might be easier to achieve your goal using brace expansion. +As with regex, parens can be nested, so patterns like `((a|b)|c)/b` will work. Although brace expansion might be friendlier to use, depending on preference. + +### POSIX bracket expressions -#### POSIX bracket expressions +POSIX brackets are intended to be more user-friendly than regex character classes. This of course is in the eye of the beholder. **Example** ```js mm.isMatch('a1', '[[:alpha:][:digit:]]'); //=> true + +mm.isMatch('a1', '[[:alpha:][:alpha:]]'); +//=> false ``` -See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about extended bracket expressions. +See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about bracket expressions. *** ## Notes -Whenever possible parsing behavior for patterns is based on globbing specifications in Bash 4.3. Patterns that aren't described by Bash follow wildmatch spec (used by git). +### Bash 4.3 parity -## Benchmarks +Whenever possible matching behavior is based on behavior Bash 4.3, which is mostly consistent with minimatch. -Run the [benchmarks](./benchmark): +However, it's suprising how many edge cases and rabbit holes there are with glob matching, and since there is no real glob specification, and micromatch is more accurate than both Bash and minimatch, there are cases where best-guesses were made for behavior. In a few cases where Bash had no answers, we used wildmatch (used by git) as a fallback. -```bash -node benchmark -``` +### Backslashes -As of July 15, 2016: +There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns. -```bash -#1: basename-braces - micromatch x 26,420 ops/sec ±0.89% (91 runs sampled) - minimatch x 3,507 ops/sec ±0.64% (97 runs sampled) +* Micromatch exclusively and explicitly reserves backslashes for escaping characters in a glob pattern, even on windows. This is consistent with bash behavior. +* Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns. -#2: basename - micromatch x 25,315 ops/sec ±0.82% (93 runs sampled) - minimatch x 4,398 ops/sec ±0.86% (94 runs sampled) +We made this decision for micromatch for a couple of reasons: -#3: braces-no-glob - micromatch x 341,254 ops/sec ±0.78% (93 runs sampled) - minimatch x 30,197 ops/sec ±1.12% (91 runs sampled) +* consistency with bash conventions. +* glob patterns are not filepaths. They are a type of [regular language](https://en.wikipedia.org/wiki/Regular_language) that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine. -#4: braces - micromatch x 54,649 ops/sec ±0.74% (94 runs sampled) - minimatch x 3,095 ops/sec ±0.82% (95 runs sampled) +**A note about joining paths to globs** -#5: immediate - micromatch x 16,719 ops/sec ±0.79% (95 runs sampled) - minimatch x 4,348 ops/sec ±0.86% (96 runs sampled) +Note that when you pass something like `path.join('foo', '*')` to micromatch, you are creating a filepath and expecting it to still work as a glob pattern. This causes problems on windows, since the `path.sep` is `\\`. -#6: large - micromatch x 721 ops/sec ±0.77% (94 runs sampled) - minimatch x 17.73 ops/sec ±1.08% (50 runs sampled) +In other words, since `\\` is reserved as an escape character in globs, on windows `path.join('foo', '*')` would result in `foo\\*`, which tells micromatch to match `*` as a literal character. This is the same behavior as bash. -#7: long - micromatch x 5,051 ops/sec ±0.87% (97 runs sampled) - minimatch x 628 ops/sec ±0.83% (94 runs sampled) +## Contributing -#8: mid - micromatch x 51,280 ops/sec ±0.80% (95 runs sampled) - minimatch x 1,923 ops/sec ±0.84% (95 runs sampled) +All contributions are welcome! Please read [the contributing guide](.github/contributing.md) to get started. -#9: multi-patterns - micromatch x 22,440 ops/sec ±0.97% (94 runs sampled) - minimatch x 2,481 ops/sec ±1.10% (94 runs sampled) +**Bug reports** -#10: no-glob - micromatch x 722,823 ops/sec ±1.30% (87 runs sampled) - minimatch x 52,967 ops/sec ±1.09% (94 runs sampled) +Please create an issue if you encounter a bug or matching behavior that doesn't seem correct. If you find a matching-related issue, please: -#11: range - micromatch x 243,471 ops/sec ±0.79% (94 runs sampled) - minimatch x 11,736 ops/sec ±0.82% (96 runs sampled) +* [research existing issues first](../../issues) (open and closed) +* visit the [GNU Bash documentation](https://www.gnu.org/software/bash/manual/) to see how Bash deals with the pattern +* visit the [minimatch](https://github.com/isaacs/minimatch) documentation to cross-check expected behavior in node.js +* if all else fails, since there is no real specification for globs we will probably need to discuss expected behavior and decide how to resolve it. which means any detail you can provide to help with this discussion would be greatly appreciated. -#12: shallow - micromatch x 190,874 ops/sec ±0.98% (95 runs sampled) - minimatch x 21,699 ops/sec ±0.81% (97 runs sampled) +**Platform issues** -#13: short - micromatch x 496,393 ops/sec ±3.86% (90 runs sampled) - minimatch x 53,765 ops/sec ±0.75% (95 runs sampled) -``` +It's important to us that micromatch work consistently on all platforms. If you encounter any platform-specific matching or path related issues, please let us know (pull requests are also greatly appreciated). -## Tests +## Benchmarks -### Running tests +### Running benchmarks Install dev dependencies: -```sh -$ npm install -d && npm test +```bash +npm i -d && npm run benchmark ``` -### Coverage +### Latest results -As of July 15, 2016: +As of February 18, 2018 (longer bars are better): ```sh -Statements : 100% (441/441) -Branches : 100% (270/270) -Functions : 100% (54/54) -Lines : 100% (429/429) -``` +# braces-globstar-large-list (485691 bytes) + micromatch ██████████████████████████████████████████████████ (517 ops/sec ±0.49%) + minimatch █ (18.92 ops/sec ±0.54%) + multimatch █ (18.94 ops/sec ±0.62%) -## Contributing + micromatch is faster by an avg. of 2,733% -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). +# braces-multiple (3362 bytes) + micromatch ██████████████████████████████████████████████████ (33,625 ops/sec ±0.45%) + minimatch (2.92 ops/sec ±3.26%) + multimatch (2.90 ops/sec ±2.76%) -Please be sure to run the benchmarks before/after any code changes to judge the impact before you do a PR. thanks! + micromatch is faster by an avg. of 1,156,935% -## Related +# braces-range (727 bytes) + micromatch █████████████████████████████████████████████████ (155,220 ops/sec ±0.56%) + minimatch ██████ (20,186 ops/sec ±1.27%) + multimatch ██████ (19,809 ops/sec ±0.60%) -* [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) | [homepage](https://github.com/jonschlinkert/braces "Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification.") -* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.") -* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.") -* [extglob](https://www.npmjs.com/package/extglob): Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to… [more](https://github.com/jonschlinkert/extglob) | [homepage](https://github.com/jonschlinkert/extglob "Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.") -* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.") -* [gulp-micromatch](https://www.npmjs.com/package/gulp-micromatch): Filter vinyl files with glob patterns, string, regexp, array, object or matcher function. micromatch stream. | [homepage](https://github.com/tunnckocore/gulp-micromatch#readme "Filter vinyl files with glob patterns, string, regexp, array, object or matcher function. micromatch stream.") -* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") -* [parse-glob](https://www.npmjs.com/package/parse-glob): Parse a glob pattern into an object of tokens. | [homepage](https://github.com/jonschlinkert/parse-glob "Parse a glob pattern into an object of tokens.") + micromatch is faster by an avg. of 776% -## Contributing +# braces-set (2858 bytes) + micromatch █████████████████████████████████████████████████ (24,354 ops/sec ±0.92%) + minimatch █████ (2,566 ops/sec ±0.56%) + multimatch ████ (2,431 ops/sec ±1.25%) + + micromatch is faster by an avg. of 975% + +# globstar-large-list (485686 bytes) + micromatch █████████████████████████████████████████████████ (504 ops/sec ±0.45%) + minimatch ███ (33.36 ops/sec ±1.08%) + multimatch ███ (33.19 ops/sec ±1.35%) + + micromatch is faster by an avg. of 1,514% + +# globstar-long-list (90647 bytes) + micromatch ██████████████████████████████████████████████████ (2,694 ops/sec ±1.08%) + minimatch ████████████████ (870 ops/sec ±1.09%) + multimatch ████████████████ (862 ops/sec ±0.84%) + + micromatch is faster by an avg. of 311% + +# globstar-short-list (182 bytes) + micromatch ██████████████████████████████████████████████████ (328,921 ops/sec ±1.06%) + minimatch █████████ (64,808 ops/sec ±1.42%) + multimatch ████████ (57,991 ops/sec ±2.11%) + + micromatch is faster by an avg. of 536% + +# no-glob (701 bytes) + micromatch █████████████████████████████████████████████████ (415,935 ops/sec ±0.36%) + minimatch ███████████ (92,730 ops/sec ±1.44%) + multimatch █████████ (81,958 ops/sec ±2.13%) + + micromatch is faster by an avg. of 476% + +# star-basename-long (12339 bytes) + micromatch █████████████████████████████████████████████████ (7,963 ops/sec ±0.36%) + minimatch ███████████████████████████████ (5,072 ops/sec ±0.83%) + multimatch ███████████████████████████████ (5,028 ops/sec ±0.40%) + + micromatch is faster by an avg. of 158% + +# star-basename-short (349 bytes) + micromatch ██████████████████████████████████████████████████ (269,552 ops/sec ±0.70%) + minimatch ██████████████████████ (122,457 ops/sec ±1.39%) + multimatch ████████████████████ (110,788 ops/sec ±1.99%) + + micromatch is faster by an avg. of 231% + +# star-folder-long (19207 bytes) + micromatch █████████████████████████████████████████████████ (3,806 ops/sec ±0.38%) + minimatch ████████████████████████████ (2,204 ops/sec ±0.32%) + multimatch ██████████████████████████ (2,020 ops/sec ±1.07%) + + micromatch is faster by an avg. of 180% + +# star-folder-short (551 bytes) + micromatch ██████████████████████████████████████████████████ (249,077 ops/sec ±0.40%) + minimatch ███████████ (59,431 ops/sec ±1.67%) + multimatch ███████████ (55,569 ops/sec ±1.43%) + + micromatch is faster by an avg. of 433% +``` + +## About + +<details> +<summary><strong>Contributing</strong></summary> Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). -## Building docs +Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards. -_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ +</details> -To generate the readme and API documentation with [verb](https://github.com/verbose/verb): +<details> +<summary><strong>Running Tests</strong></summary> + +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh -$ npm install -g verb verb-generate-readme && verb +$ npm install && npm test ``` -## Running tests +</details> -Install dev dependencies: +<details> +<summary><strong>Building docs</strong></summary> + +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ + +To generate the readme, run the following command: ```sh -$ npm install -d && npm test +$ npm install -g verbose/verb#dev verb-generate-readme && verb ``` -## Author +</details> + +### Related projects + +You might also be interested in these projects: + +* [braces](https://www.npmjs.com/package/braces): Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.") +* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.") +* [extglob](https://www.npmjs.com/package/extglob): Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob… [more](https://github.com/micromatch/extglob) | [homepage](https://github.com/micromatch/extglob "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.") +* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`") +* [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash… [more](https://github.com/micromatch/nanomatch) | [homepage](https://github.com/micromatch/nanomatch "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)") + +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 457 | [jonschlinkert](https://github.com/jonschlinkert) | +| 12 | [es128](https://github.com/es128) | +| 8 | [doowb](https://github.com/doowb) | +| 3 | [paulmillr](https://github.com/paulmillr) | +| 2 | [TrySound](https://github.com/TrySound) | +| 2 | [MartinKolarik](https://github.com/MartinKolarik) | +| 2 | [charlike-old](https://github.com/charlike-old) | +| 1 | [amilajack](https://github.com/amilajack) | +| 1 | [mrmlnc](https://github.com/mrmlnc) | +| 1 | [devongovett](https://github.com/devongovett) | +| 1 | [DianeLooney](https://github.com/DianeLooney) | +| 1 | [UltCombo](https://github.com/UltCombo) | +| 1 | [tomByrer](https://github.com/tomByrer) | +| 1 | [fidian](https://github.com/fidian) | + +### Author **Jon Schlinkert** +* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert) * [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) +* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) -## License +### License -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](https://github.com/jonschlinkert/micromatch/blob/master/LICENSE). +Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). *** -_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 15, 2016._
\ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 18, 2018._
\ No newline at end of file |