1 # nanomatch [![NPM version](https://img.shields.io/npm/v/nanomatch.svg?style=flat)](https://www.npmjs.com/package/nanomatch) [![NPM monthly downloads](https://img.shields.io/npm/dm/nanomatch.svg?style=flat)](https://npmjs.org/package/nanomatch) [![NPM total downloads](https://img.shields.io/npm/dt/nanomatch.svg?style=flat)](https://npmjs.org/package/nanomatch) [![Linux Build Status](https://img.shields.io/travis/micromatch/nanomatch.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/nanomatch) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/nanomatch.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/nanomatch)
3 > 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)
5 Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
10 <summary><strong>Details</strong></summary>
13 - [What is nanomatch?](#what-is-nanomatch)
14 - [Getting started](#getting-started)
15 * [Installing nanomatch](#installing-nanomatch)
17 - [Documentation](#documentation)
18 * [Escaping](#escaping)
21 * [options.basename](#optionsbasename)
22 * [options.bash](#optionsbash)
23 * [options.cache](#optionscache)
24 * [options.dot](#optionsdot)
25 * [options.failglob](#optionsfailglob)
26 * [options.ignore](#optionsignore)
27 * [options.matchBase](#optionsmatchbase)
28 * [options.nocase](#optionsnocase)
29 * [options.nodupes](#optionsnodupes)
30 * [options.noglobstar](#optionsnoglobstar)
31 * [options.nonegate](#optionsnonegate)
32 * [options.nonull](#optionsnonull)
33 * [options.nullglob](#optionsnullglob)
34 * [options.slash](#optionsslash)
35 * [options.star](#optionsstar)
36 * [options.snapdragon](#optionssnapdragon)
37 * [options.sourcemap](#optionssourcemap)
38 * [options.unescape](#optionsunescape)
39 * [options.unixify](#optionsunixify)
40 - [Features](#features)
41 - [Bash expansion libs](#bash-expansion-libs)
42 - [Benchmarks](#benchmarks)
43 * [Running benchmarks](#running-benchmarks)
44 * [Nanomatch vs. Minimatch vs. Multimatch](#nanomatch-vs-minimatch-vs-multimatch)
51 Install with [npm](https://www.npmjs.com/):
54 $ npm install --save nanomatch
58 <summary><strong>Release history</strong></summary>
64 Changelog entries are classified using the following labels _(from [keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog)_):
66 * `added`: for new features
67 * `changed`: for changes in existing functionality
68 * `deprecated`: for once-stable features removed in upcoming releases
69 * `removed`: for deprecated features removed in this release
70 * `fixed`: for any bug fixes
71 * `bumped`: updated dependencies, only minor or higher will be listed.
73 ### [1.1.0](https://github.com/micromatch/nanomatch/compare/1.0.4...1.1.0) - 2017-04-11
77 * adds support for unclosed quotes
81 * adds support for `options.noglobstar`
83 ### [1.0.4](https://github.com/micromatch/nanomatch/compare/1.0.3...1.0.4) - 2017-04-06
85 Housekeeping updates. Adds documentation section about escaping, cleans up utils.
87 ### [1.0.3](https://github.com/micromatch/nanomatch/compare/1.0.1...1.0.3) - 2017-04-06
89 This release includes fixes for windows path edge cases and other improvements for stricter adherence to bash spec.
93 * More windows path edge cases
97 * Support for bash-like quoted strings for escaping sequences of characters, such as `foo/"**"/bar` where `**` should be matched literally and not evaluated as special characters.
99 ### [1.0.1](https://github.com/micromatch/nanomatch/compare/1.0.0...1.0.1) - 2016-12-12
103 * Support for windows path edge cases where backslashes are used in brackets or other unusual combinations.
105 ### [1.0.0](https://github.com/micromatch/nanomatch/compare/0.1.0...1.0.0) - 2016-12-12
109 ### [0.1.0] - 2016-10-08
115 ## What is nanomatch?
117 Nanomatch is a fast and accurate glob matcher with full support for standard Bash glob features, including the following "metacharacters": `*`, `**`, `?` and `[...]`.
121 * [Getting started](#getting-started): learn how to install and begin using nanomatch
122 * [Features](#features): jump to info about supported patterns, and a glob matching reference
123 * [API documentation](#api): jump to available options and methods
124 * [Unit tests](test): visit unit tests. there is no better way to learn a code library than spending time the unit tests. Nanomatch has 36,000 unit tests - go become a glob matching ninja!
127 <summary><strong>How is this different?</strong></summary>
129 **Speed and accuracy**
131 Nanomatch uses [snapdragon](https://github.com/jonschlinkert/snapdragon) for parsing and compiling globs, which results in:
133 * Granular control over the entire conversion process in a way that is easy to understand, reason about, and customize.
134 * Faster matching, from a combination of optimized glob patterns and (optional) caching.
135 * Much greater accuracy than minimatch. In fact, nanomatch passes _all of the spec tests_ from bash, including some that bash still fails. However, since there is no real specification for globs, if you encounter a pattern that yields unexpected match results [after researching previous issues](../../issues), [please let us know](../../issues/new).
137 **Basic globbing only**
139 Nanomatch supports [basic globbing only](#features), which is limited to `*`, `**`, `?` and regex-like brackets.
141 If you need support for the other [bash "expansion" types](#bash-expansion-libs) (in addition to the wildcard matching provided by nanomatch), consider using [micromatch](https://github.com/micromatch/micromatch) instead. _(micromatch >=3.0.0 uses the nanomatch parser and compiler for basic glob matching)_
147 ### Installing nanomatch
149 **Install with [yarn](https://yarnpkg.com/)**
155 **Install with [npm](https://npmjs.com)**
158 $ npm install nanomatch
163 Add nanomatch to your project using node's `require()` system:
166 var nanomatch = require('nanomatch');
168 // the main export is a function that takes an array of strings to match
169 // and a string or array of patterns to use for matching
170 nanomatch(list, patterns[, options]);
175 * `list` **{String|Array}**: List of strings to perform matches against. This is often a list of file paths.
176 * `patterns` **{String|Array}**: One or more [glob paterns](#features) to use for matching.
177 * `options` **{Object}**: Any [supported options](#options) may be passed
182 var nm = require('nanomatch');
183 console.log(nm(['a', 'b/b', 'c/c/c'], '*'));
186 console.log(nm(['a', 'b/b', 'c/c/c'], '*/*'));
189 console.log(nm(['a', 'b/b', 'c/c/c'], '**'));
190 //=> ['a', 'b/b', 'c/c/c']
193 See the [API documentation](#api) for available methods and [options](https://github.com/einaros/options.js).
199 _Backslashes and quotes_ can be used to escape characters, forcing nanomatch to regard those characters as a literal characters.
203 Use backslashes to escape single characters. For example, the following pattern would match `foo/*/bar` exactly:
209 The following pattern would match `foo/` followed by a literal `*`, followed by zero or more of any characters besides `/`, followed by `/bar`.
217 Use single or double quotes to escape sequences of characters. For example, the following patterns would match `foo/**/bar` exactly:
225 **Matching literal quotes**
227 If you need to match quotes literally, you can escape them as well. For example, the following will match `foo/"*"/bar`, `foo/"a"/bar`, `foo/"b"/bar`, or `foo/"c"/bar`:
233 And the following will match `foo/'*'/bar`, `foo/'a'/bar`, `foo/'b'/bar`, or `foo/'c'/bar`:
241 ### [nanomatch](index.js#L40)
243 The main function takes a list of strings and one or more glob patterns to use for matching.
247 * `list` **{Array}**: A list of strings to match
248 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
249 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
250 * `returns` **{Array}**: Returns an array of matches
255 var nm = require('nanomatch');
256 nm(list, patterns[, options]);
258 console.log(nm(['a.js', 'a.txt'], ['*.js']));
262 ### [.match](index.js#L106)
264 Similar to the main function, but `pattern` must be a string.
268 * `list` **{Array}**: Array of strings to match
269 * `pattern` **{String}**: Glob pattern to use for matching.
270 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
271 * `returns` **{Array}**: Returns an array of matches
276 var nm = require('nanomatch');
277 nm.match(list, pattern[, options]);
279 console.log(nm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'));
283 ### [.isMatch](index.js#L167)
285 Returns true if the specified `string` matches the given glob `pattern`.
289 * `string` **{String}**: String to match
290 * `pattern` **{String}**: Glob pattern to use for matching.
291 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
292 * `returns` **{Boolean}**: Returns true if the string matches the glob pattern.
297 var nm = require('nanomatch');
298 nm.isMatch(string, pattern[, options]);
300 console.log(nm.isMatch('a.a', '*.a'));
302 console.log(nm.isMatch('a.b', '*.a'));
306 ### [.some](index.js#L205)
308 Returns true if some of the elements in the given `list` match any of the given glob `patterns`.
312 * `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
313 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
314 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
315 * `returns` **{Boolean}**: Returns true if any patterns match `str`
320 var nm = require('nanomatch');
321 nm.some(list, patterns[, options]);
323 console.log(nm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
325 console.log(nm.some(['foo.js'], ['*.js', '!foo.js']));
329 ### [.every](index.js#L243)
331 Returns true if every element in the given `list` matches at least one of the given glob `patterns`.
335 * `list` **{String|Array}**: The string or array of strings to test.
336 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
337 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
338 * `returns` **{Boolean}**: Returns true if any patterns match `str`
343 var nm = require('nanomatch');
344 nm.every(list, patterns[, options]);
346 console.log(nm.every('foo.js', ['foo.js']));
348 console.log(nm.every(['foo.js', 'bar.js'], ['*.js']));
350 console.log(nm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
352 console.log(nm.every(['foo.js'], ['*.js', '!foo.js']));
356 ### [.any](index.js#L277)
358 Returns true if **any** of the given glob `patterns` match the specified `string`.
362 * `str` **{String|Array}**: The string to test.
363 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
364 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
365 * `returns` **{Boolean}**: Returns true if any patterns match `str`
370 var nm = require('nanomatch');
371 nm.any(string, patterns[, options]);
373 console.log(nm.any('a.a', ['b.*', '*.a']));
375 console.log(nm.any('a.a', 'b.*'));
379 ### [.all](index.js#L325)
381 Returns true if **all** of the given `patterns` match the specified string.
385 * `str` **{String|Array}**: The string to test.
386 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
387 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
388 * `returns` **{Boolean}**: Returns true if any patterns match `str`
393 var nm = require('nanomatch');
394 nm.all(string, patterns[, options]);
396 console.log(nm.all('foo.js', ['foo.js']));
399 console.log(nm.all('foo.js', ['*.js', '!foo.js']));
402 console.log(nm.all('foo.js', ['*.js', 'foo.js']));
405 console.log(nm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
409 ### [.not](index.js#L359)
411 Returns a list of strings that _**do not match any**_ of the given `patterns`.
415 * `list` **{Array}**: Array of strings to match.
416 * `patterns` **{String|Array}**: One or more glob pattern to use for matching.
417 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
418 * `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns.
423 var nm = require('nanomatch');
424 nm.not(list, patterns[, options]);
426 console.log(nm.not(['a.a', 'b.b', 'c.c'], '*.a'));
430 ### [.contains](index.js#L394)
432 Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
436 * `str` **{String}**: The string to match.
437 * `patterns` **{String|Array}**: Glob pattern to use for matching.
438 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
439 * `returns` **{Boolean}**: Returns true if the patter matches any part of `str`.
444 var nm = require('nanomatch');
445 nm.contains(string, pattern[, options]);
447 console.log(nm.contains('aa/bb/cc', '*b'));
449 console.log(nm.contains('aa/bb/cc', '*d'));
453 ### [.matchKeys](index.js#L450)
455 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.
459 * `object` **{Object}**: The object with keys to filter.
460 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
461 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
462 * `returns` **{Object}**: Returns an object with only keys that match the given patterns.
467 var nm = require('nanomatch');
468 nm.matchKeys(object, patterns[, options]);
470 var obj = { aa: 'a', ab: 'b', ac: 'c' };
471 console.log(nm.matchKeys(obj, '*b'));
475 ### [.matcher](index.js#L479)
477 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.
481 * `pattern` **{String}**: Glob pattern
482 * `options` **{Object}**: See available [options](#options) for changing how matches are performed.
483 * `returns` **{Function}**: Returns a matcher function.
488 var nm = require('nanomatch');
489 nm.matcher(pattern[, options]);
491 var isMatch = nm.matcher('*.!(*a)');
492 console.log(isMatch('a.a'));
494 console.log(isMatch('a.b'));
498 ### [.capture](index.js#L560)
500 Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
504 * `pattern` **{String}**: Glob pattern to use for matching.
505 * `string` **{String}**: String to match
506 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
507 * `returns` **{Boolean}**: Returns an array of captures if the string matches the glob pattern, otherwise `null`.
512 var nm = require('nanomatch');
513 nm.capture(pattern, string[, options]);
515 console.log(nm.capture('test/*.js', 'test/foo.js'));
517 console.log(nm.capture('test/*.js', 'foo/bar.css'));
521 ### [.makeRe](index.js#L595)
523 Create a regular expression from the given glob `pattern`.
527 * `pattern` **{String}**: A glob pattern to convert to regex.
528 * `options` **{Object}**: See available [options](#options) for changing how matches are performed.
529 * `returns` **{RegExp}**: Returns a regex created from the given pattern.
534 var nm = require('nanomatch');
535 nm.makeRe(pattern[, options]);
537 console.log(nm.makeRe('*.js'));
538 //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
541 ### [.create](index.js#L658)
543 Parses the given glob `pattern` and returns an object with the compiled `output` and optional source `map`.
547 * `pattern` **{String}**: Glob pattern to parse and compile.
548 * `options` **{Object}**: Any [options](#options) to change how parsing and compiling is performed.
549 * `returns` **{Object}**: Returns an object with the parsed AST, compiled string and optional source map.
554 var nm = require('nanomatch');
555 nm.create(pattern[, options]);
557 console.log(nm.create('abc/*.js'));
558 // { options: { source: 'string', sourcemap: true },
562 // output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js',
569 // input: 'abc/*.js' },
570 // parsingErrors: [],
573 // sources: [ 'string' ],
575 // mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE',
576 // sourcesContent: [ 'abc/*.js' ] },
577 // position: { line: 1, column: 28 },
583 ### [.parse](index.js#L697)
585 Parse the given `str` with the given `options`.
590 * `options` **{Object}**
591 * `returns` **{Object}**: Returns an AST
596 var nm = require('nanomatch');
597 nm.parse(pattern[, options]);
599 var ast = nm.parse('a/{b,c}/d');
603 // input: 'a/{b,c}/d',
605 // [ { type: 'bos', val: '' },
606 // { type: 'text', val: 'a/' },
609 // [ { type: 'brace.open', val: '{' },
610 // { type: 'text', val: 'b,c' },
611 // { type: 'brace.close', val: '}' } ] },
612 // { type: 'text', val: '/d' },
613 // { type: 'eos', val: '' } ] }
616 ### [.compile](index.js#L745)
618 Compile the given `ast` or string with the given `options`.
622 * `ast` **{Object|String}**
623 * `options` **{Object}**
624 * `returns` **{Object}**: Returns an object that has an `output` property with the compiled string.
629 var nm = require('nanomatch');
630 nm.compile(ast[, options]);
632 var ast = nm.parse('a/{b,c}/d');
633 console.log(nm.compile(ast));
634 // { options: { source: 'string' },
637 // { eos: [Function],
640 // brace: [Function],
641 // 'brace.open': [Function],
643 // 'brace.close': [Function] },
644 // output: [ 'a/(b|c)/d' ],
647 // parsingErrors: [] }
650 ### [.clearCache](index.js#L768)
652 Clear the regex cache.
663 <summary><strong>basename</strong></summary>
667 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`.
676 nm(['a/b.js', 'a/c.md'], '*.js');
679 nm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true});
686 <summary><strong>bash</strong></summary>
690 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.
699 var files = ['abc', 'ajz'];
700 console.log(nm(files, '[a-c]*'));
703 console.log(nm(files, '[a-c]*', {bash: false}));
709 <summary><strong>cache</strong></summary>
713 Disable regex and function memoization.
722 <summary><strong>dot</strong></summary>
726 Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`.
735 <summary><strong>failglob</strong></summary>
739 Similar to the `--failglob` behavior in Bash, throws an error when no matches are found.
748 <summary><strong>ignore</strong></summary>
752 String or array of glob patterns to match files to ignore.
761 <summary><strong>matchBase</strong></summary>
763 ### options.matchBase
765 Alias for [options.basename](#options-basename).
770 <summary><strong>nocase</strong></summary>
774 Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch).
783 <summary><strong>nodupes</strong></summary>
787 Remove duplicate elements from the result array.
791 Default: `true` (enabled by default)
795 Example of using the `unescape` and `nodupes` options together:
798 nm.match(['a/b/c', 'a/b/c'], '**');
801 nm.match(['a/b/c', 'a/b/c'], '**', {nodupes: false});
802 //=> ['a/b/c', 'a/b/c']
808 <summary><strong>nonegate</strong></summary>
810 ### options.noglobstar
812 Disable matching with globstars (`**`).
819 nm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**');
820 //=> ['a/b', 'a/b/c', 'a/b/c/d']
822 nm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**', {noglobstar: true});
829 <summary><strong>nonegate</strong></summary>
833 Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match.
842 <summary><strong>nonull</strong></summary>
846 Alias for [options.nullglob](#options-nullglob).
851 <summary><strong>nullglob</strong></summary>
855 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`.
864 <summary><strong><a name="slash">slash</a></strong></summary>
868 Customize the slash character(s) to use for matching.
870 Type: `string|function`
872 Default: `[/\\]` (forward slash and backslash)
877 <summary><strong><a name="star">star</a></strong></summary>
881 Customize the star character(s) to use for matching. It's not recommended that you modify this unless you have advanced knowledge of the compiler and matching rules.
883 Type: `string|function`
890 <summary><strong><a name="snapdragon">snapdragon</a></strong></summary>
892 ### options.snapdragon
894 Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon) to customize parsers or compilers.
903 <summary><strong>snapdragon</strong></summary>
905 ### options.sourcemap
907 Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods.
912 var nm = require('nanomatch');
914 var res = nm.create('abc/*.js', {sourcemap: true});
915 console.log(res.map);
917 // sources: [ 'string' ],
919 // mappings: 'AAAA,GAAG,EAAC,iBAAC,EAAC,EAAE',
920 // sourcesContent: [ 'abc/*.js' ] }
922 var ast = nm.parse('abc/**/*.js');
923 var res = nm.compile(ast, {sourcemap: true});
924 console.log(res.map);
926 // sources: [ 'string' ],
928 // mappings: 'AAAA,GAAG,EAAC,2BAAE,EAAC,iBAAC,EAAC,EAAE',
929 // sourcesContent: [ 'abc/**/*.js' ] }
935 <summary><strong>unescape</strong></summary>
939 Remove backslashes from returned matches.
947 In this example we want to match a literal `*`:
950 nm.match(['abc', 'a\\*c'], 'a\\*c');
953 nm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true});
960 <summary><strong>unixify</strong></summary>
964 Convert path separators on returned files to posix/unix-style forward slashes.
973 nm.match(['a\\b\\c'], 'a/**');
976 nm.match(['a\\b\\c'], {unixify: false});
984 Nanomatch has full support for standard Bash glob features, including the following "metacharacters": `*`, `**`, `?` and `[...]`.
986 Here are some examples of how they work:
988 | **Pattern** | **Description** |
990 | `*` | Matches any string except for `/`, leading `.`, or `/.` inside a path |
991 | `**` | Matches any string including `/`, but not a leading `.` or `/.` inside a path. More than two stars (e.g. `***` is treated the same as one star, and `**` loses its special meaning | when it's not the only thing in a path segment, per Bash specifications) |
992 | `foo*` | Matches any string beginning with `foo` |
993 | `*bar*` | Matches any string containing `bar` (beginning, middle or end) |
994 | `*.min.js` | Matches any string ending with `.min.js` |
995 | `[abc]*.js` | Matches any string beginning with `a`, `b`, or `c` and ending with `.js` |
996 | `abc?` | Matches `abcd` or `abcz` but not `abcde` |
998 The exceptions noted for `*` apply to all patterns that contain a `*`.
1002 The following extended-globbing features are not supported:
1004 * [brace expansion](https://github.com/jonschlinkert/braces) (e.g. `{a,b,c}`)
1005 * [extglobs](https://github.com/jonschlinkert/extglob) (e.g. `@(a|!(c|d))`)
1006 * [POSIX brackets](https://github.com/jonschlinkert/expand-brackets) (e.g. `[[:alpha:][:digit:]]`)
1008 If you need any of these features consider using [micromatch](https://github.com/micromatch/micromatch) instead.
1010 ## Bash expansion libs
1012 Nanomatch is part of a suite of libraries aimed at bringing the power and expressiveness of [Bash's](https://www.gnu.org/software/bash/) matching and expansion capabilities to JavaScript, _and - as you can see by the [benchmarks](#benchmarks) - without sacrificing speed_.
1014 | **Related library** | **Matching Type** | **Example** | **Description** |
1015 | --- | --- | --- | --- |
1016 | `nanomatch` (you are here) | Wildcards | `*` | [Filename expansion](https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html#Filename-Expansion), also referred to as globbing and pathname expansion, allows the use of [wildcards](#features) for matching. |
1017 | [expand-tilde](https://github.com/jonschlinkert/expand-tilde) | Tildes | `~` | [Tilde expansion](https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html#Tilde-Expansion) converts the leading tilde in a file path to the user home directory. |
1018 | [braces](https://github.com/jonschlinkert/braces) | Braces | `{a,b,c}` | [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) |
1019 | [expand-brackets](https://github.com/jonschlinkert/expand-brackets) | Brackets | `[[:alpha:]]` | [POSIX character classes](https://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html) (also referred to as POSIX brackets, or POSIX character classes) |
1020 | [extglob](https://github.com/jonschlinkert/extglob) | Parens | `!(a\ | b)` | [Extglobs](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching) |
1021 | [micromatch](https://github.com/micromatch/micromatch) | All | all | Micromatch is built on top of the other libraries. |
1023 There are many resources available on the web if you want to dive deeper into how these features work in Bash.
1027 ### Running benchmarks
1029 Install dev dependencies:
1032 npm i -d && node benchmark
1035 ### Nanomatch vs. Minimatch vs. Multimatch
1038 # globstar-basic (182 bytes)
1039 minimatch x 69,512 ops/sec ±1.92% (88 runs sampled)
1040 multimatch x 63,376 ops/sec ±1.41% (89 runs sampled)
1041 nanomatch x 432,451 ops/sec ±0.92% (88 runs sampled)
1043 fastest is nanomatch (by 651% avg)
1045 # large-list-globstar (485686 bytes)
1046 minimatch x 34.02 ops/sec ±1.42% (59 runs sampled)
1047 multimatch x 33.58 ops/sec ±1.97% (58 runs sampled)
1048 nanomatch x 483 ops/sec ±1.06% (86 runs sampled)
1050 fastest is nanomatch (by 1429% avg)
1052 # long-list-globstar (194085 bytes)
1053 minimatch x 383 ops/sec ±0.74% (90 runs sampled)
1054 multimatch x 378 ops/sec ±0.59% (89 runs sampled)
1055 nanomatch x 990 ops/sec ±1.14% (85 runs sampled)
1057 fastest is nanomatch (by 260% avg)
1059 # negation-basic (132 bytes)
1060 minimatch x 242,145 ops/sec ±1.17% (89 runs sampled)
1061 multimatch x 76,403 ops/sec ±0.78% (92 runs sampled)
1062 nanomatch x 537,253 ops/sec ±1.44% (86 runs sampled)
1064 fastest is nanomatch (by 337% avg)
1066 # not-glob-basic (93 bytes)
1067 minimatch x 252,402 ops/sec ±1.33% (89 runs sampled)
1068 multimatch x 209,954 ops/sec ±1.30% (90 runs sampled)
1069 nanomatch x 1,716,468 ops/sec ±1.13% (86 runs sampled)
1071 fastest is nanomatch (by 742% avg)
1073 # star-basic (93 bytes)
1074 minimatch x 182,780 ops/sec ±1.41% (91 runs sampled)
1075 multimatch x 153,210 ops/sec ±0.72% (89 runs sampled)
1076 nanomatch x 599,621 ops/sec ±1.22% (90 runs sampled)
1078 fastest is nanomatch (by 357% avg)
1085 <summary><strong>Contributing</strong></summary>
1087 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
1089 Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
1094 <summary><strong>Running Tests</strong></summary>
1096 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:
1099 $ npm install && npm test
1105 <summary><strong>Building docs</strong></summary>
1107 _(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.)_
1109 To generate the readme, run the following command:
1112 $ npm install -g verbose/verb#dev verb-generate-readme && verb
1117 ### Related projects
1119 You might also be interested in these projects:
1121 * [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.")
1122 * [is-extglob](https://www.npmjs.com/package/is-extglob): Returns true if a string has an extglob. | [homepage](https://github.com/jonschlinkert/is-extglob "Returns true if a string has an extglob.")
1123 * [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")
1124 * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
1128 | **Commits** | **Contributor** |
1130 | 164 | [jonschlinkert](https://github.com/jonschlinkert) |
1131 | 1 | [devongovett](https://github.com/devongovett) |
1137 * [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
1138 * [github/jonschlinkert](https://github.com/jonschlinkert)
1139 * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
1143 Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
1144 Released under the [MIT License](LICENSE).
1148 _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 18, 2018._