source: trip-planner-front/node_modules/picomatch/README.md@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 26.8 KB
Line 
1<h1 align="center">Picomatch</h1>
2
3<p align="center">
4<a href="https://npmjs.org/package/picomatch">
5<img src="https://img.shields.io/npm/v/picomatch.svg" alt="version">
6</a>
7<a href="https://github.com/micromatch/picomatch/actions?workflow=Tests">
8<img src="https://github.com/micromatch/picomatch/workflows/Tests/badge.svg" alt="test status">
9</a>
10<a href="https://coveralls.io/github/micromatch/picomatch">
11<img src="https://img.shields.io/coveralls/github/micromatch/picomatch/master.svg" alt="coverage status">
12</a>
13<a href="https://npmjs.org/package/picomatch">
14<img src="https://img.shields.io/npm/dm/picomatch.svg" alt="downloads">
15</a>
16</p>
17
18<br>
19<br>
20
21<p align="center">
22<strong>Blazing fast and accurate glob matcher written in JavaScript.</strong></br>
23<em>No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.</em>
24</p>
25
26<br>
27<br>
28
29## Why picomatch?
30
31* **Lightweight** - No dependencies
32* **Minimal** - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
33* **Fast** - Loads in about 2ms (that's several times faster than a [single frame of a HD movie](http://www.endmemo.com/sconvert/framespersecondframespermillisecond.php) at 60fps)
34* **Performant** - Use the returned matcher function to speed up repeat matching (like when watching files)
35* **Accurate matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories, [advanced globbing](#advanced-globbing) with extglobs, braces, and POSIX brackets, and support for escaping special characters with `\` or quotes.
36* **Well tested** - Thousands of unit tests
37
38See the [library comparison](#library-comparisons) to other libraries.
39
40<br>
41<br>
42
43## Table of Contents
44
45<details><summary> Click to expand </summary>
46
47- [Install](#install)
48- [Usage](#usage)
49- [API](#api)
50 * [picomatch](#picomatch)
51 * [.test](#test)
52 * [.matchBase](#matchbase)
53 * [.isMatch](#ismatch)
54 * [.parse](#parse)
55 * [.scan](#scan)
56 * [.compileRe](#compilere)
57 * [.makeRe](#makere)
58 * [.toRegex](#toregex)
59- [Options](#options)
60 * [Picomatch options](#picomatch-options)
61 * [Scan Options](#scan-options)
62 * [Options Examples](#options-examples)
63- [Globbing features](#globbing-features)
64 * [Basic globbing](#basic-globbing)
65 * [Advanced globbing](#advanced-globbing)
66 * [Braces](#braces)
67 * [Matching special characters as literals](#matching-special-characters-as-literals)
68- [Library Comparisons](#library-comparisons)
69- [Benchmarks](#benchmarks)
70- [Philosophies](#philosophies)
71- [About](#about)
72 * [Author](#author)
73 * [License](#license)
74
75_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
76
77</details>
78
79<br>
80<br>
81
82## Install
83
84Install with [npm](https://www.npmjs.com/):
85
86```sh
87npm install --save picomatch
88```
89
90<br>
91
92## Usage
93
94The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.
95
96```js
97const pm = require('picomatch');
98const isMatch = pm('*.js');
99
100console.log(isMatch('abcd')); //=> false
101console.log(isMatch('a.js')); //=> true
102console.log(isMatch('a.md')); //=> false
103console.log(isMatch('a/b.js')); //=> false
104```
105
106<br>
107
108## API
109
110### [picomatch](lib/picomatch.js#L32)
111
112Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information.
113
114**Params**
115
116* `globs` **{String|Array}**: One or more glob patterns.
117* `options` **{Object=}**
118* `returns` **{Function=}**: Returns a matcher function.
119
120**Example**
121
122```js
123const picomatch = require('picomatch');
124// picomatch(glob[, options]);
125
126const isMatch = picomatch('*.!(*a)');
127console.log(isMatch('a.a')); //=> false
128console.log(isMatch('a.b')); //=> true
129```
130
131### [.test](lib/picomatch.js#L117)
132
133Test `input` with the given `regex`. This is used by the main `picomatch()` function to test the input string.
134
135**Params**
136
137* `input` **{String}**: String to test.
138* `regex` **{RegExp}**
139* `returns` **{Object}**: Returns an object with matching info.
140
141**Example**
142
143```js
144const picomatch = require('picomatch');
145// picomatch.test(input, regex[, options]);
146
147console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
148// { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
149```
150
151### [.matchBase](lib/picomatch.js#L161)
152
153Match the basename of a filepath.
154
155**Params**
156
157* `input` **{String}**: String to test.
158* `glob` **{RegExp|String}**: Glob pattern or regex created by [.makeRe](#makeRe).
159* `returns` **{Boolean}**
160
161**Example**
162
163```js
164const picomatch = require('picomatch');
165// picomatch.matchBase(input, glob[, options]);
166console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
167```
168
169### [.isMatch](lib/picomatch.js#L183)
170
171Returns true if **any** of the given glob `patterns` match the specified `string`.
172
173**Params**
174
175* **{String|Array}**: str The string to test.
176* **{String|Array}**: patterns One or more glob patterns to use for matching.
177* **{Object}**: See available [options](#options).
178* `returns` **{Boolean}**: Returns true if any patterns match `str`
179
180**Example**
181
182```js
183const picomatch = require('picomatch');
184// picomatch.isMatch(string, patterns[, options]);
185
186console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
187console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
188```
189
190### [.parse](lib/picomatch.js#L199)
191
192Parse a glob pattern to create the source string for a regular expression.
193
194**Params**
195
196* `pattern` **{String}**
197* `options` **{Object}**
198* `returns` **{Object}**: Returns an object with useful properties and output to be used as a regex source string.
199
200**Example**
201
202```js
203const picomatch = require('picomatch');
204const result = picomatch.parse(pattern[, options]);
205```
206
207### [.scan](lib/picomatch.js#L231)
208
209Scan a glob pattern to separate the pattern into segments.
210
211**Params**
212
213* `input` **{String}**: Glob pattern to scan.
214* `options` **{Object}**
215* `returns` **{Object}**: Returns an object with
216
217**Example**
218
219```js
220const picomatch = require('picomatch');
221// picomatch.scan(input[, options]);
222
223const result = picomatch.scan('!./foo/*.js');
224console.log(result);
225{ prefix: '!./',
226 input: '!./foo/*.js',
227 start: 3,
228 base: 'foo',
229 glob: '*.js',
230 isBrace: false,
231 isBracket: false,
232 isGlob: true,
233 isExtglob: false,
234 isGlobstar: false,
235 negated: true }
236```
237
238### [.compileRe](lib/picomatch.js#L245)
239
240Compile a regular expression from the `state` object returned by the
241[parse()](#parse) method.
242
243**Params**
244
245* `state` **{Object}**
246* `options` **{Object}**
247* `returnOutput` **{Boolean}**: Intended for implementors, this argument allows you to return the raw output from the parser.
248* `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
249* `returns` **{RegExp}**
250
251### [.makeRe](lib/picomatch.js#L286)
252
253Create a regular expression from a parsed glob pattern.
254
255**Params**
256
257* `state` **{String}**: The object returned from the `.parse` method.
258* `options` **{Object}**
259* `returnOutput` **{Boolean}**: Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
260* `returnState` **{Boolean}**: Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
261* `returns` **{RegExp}**: Returns a regex created from the given pattern.
262
263**Example**
264
265```js
266const picomatch = require('picomatch');
267const state = picomatch.parse('*.js');
268// picomatch.compileRe(state[, options]);
269
270console.log(picomatch.compileRe(state));
271//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
272```
273
274### [.toRegex](lib/picomatch.js#L321)
275
276Create a regular expression from the given regex source string.
277
278**Params**
279
280* `source` **{String}**: Regular expression source string.
281* `options` **{Object}**
282* `returns` **{RegExp}**
283
284**Example**
285
286```js
287const picomatch = require('picomatch');
288// picomatch.toRegex(source[, options]);
289
290const { output } = picomatch.parse('*.js');
291console.log(picomatch.toRegex(output));
292//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
293```
294
295<br>
296
297## Options
298
299### Picomatch options
300
301The following options may be used with the main `picomatch()` function or any of the methods on the picomatch API.
302
303| **Option** | **Type** | **Default value** | **Description** |
304| --- | --- | --- | --- |
305| `basename` | `boolean` | `false` | If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. |
306| `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
307| `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
308| `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
309| `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` |
310| `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
311| `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
312| `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
313| `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |
314| `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
315| `flags` | `boolean` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
316| [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
317| `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |
318| `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |
319| `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
320| `lookbehinds` | `boolean` | `true` | Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds. |
321| `matchBase` | `boolean` | `false` | Alias for `basename` |
322| `maxLength` | `boolean` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
323| `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
324| `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
325| `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
326| `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. |
327| `noext` | `boolean` | `false` | Alias for `noextglob` |
328| `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
329| `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
330| `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
331| `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. |
332| [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
333| [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
334| [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
335| `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
336| `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |
337| `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
338| `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
339| `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
340| `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
341| `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
342| `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |
343
344### Scan Options
345
346In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
347
348| **Option** | **Type** | **Default value** | **Description** |
349| --- | --- | --- | --- |
350| `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |
351| `parts` | `boolean` | `false` | When `true`, the returned object will include an array of strings representing each path "segment" in the scanned glob pattern. This is automatically enabled when `options.tokens` is true |
352
353**Example**
354
355```js
356const picomatch = require('picomatch');
357const result = picomatch.scan('!./foo/*.js', { tokens: true });
358console.log(result);
359// {
360// prefix: '!./',
361// input: '!./foo/*.js',
362// start: 3,
363// base: 'foo',
364// glob: '*.js',
365// isBrace: false,
366// isBracket: false,
367// isGlob: true,
368// isExtglob: false,
369// isGlobstar: false,
370// negated: true,
371// maxDepth: 2,
372// tokens: [
373// { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },
374// { value: 'foo', depth: 1, isGlob: false },
375// { value: '*.js', depth: 1, isGlob: true }
376// ],
377// slashes: [ 2, 6 ],
378// parts: [ 'foo', '*.js' ]
379// }
380```
381
382<br>
383
384### Options Examples
385
386#### options.expandRange
387
388**Type**: `function`
389
390**Default**: `undefined`
391
392Custom function for expanding ranges in brace patterns. The [fill-range](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need.
393
394**Example**
395
396The following example shows how to create a glob that matches a folder
397
398```js
399const fill = require('fill-range');
400const regex = pm.makeRe('foo/{01..25}/bar', {
401 expandRange(a, b) {
402 return `(${fill(a, b, { toRegex: true })})`;
403 }
404});
405
406console.log(regex);
407//=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/
408
409console.log(regex.test('foo/00/bar')) // false
410console.log(regex.test('foo/01/bar')) // true
411console.log(regex.test('foo/10/bar')) // true
412console.log(regex.test('foo/22/bar')) // true
413console.log(regex.test('foo/25/bar')) // true
414console.log(regex.test('foo/26/bar')) // false
415```
416
417#### options.format
418
419**Type**: `function`
420
421**Default**: `undefined`
422
423Custom function for formatting strings before they're matched.
424
425**Example**
426
427```js
428// strip leading './' from strings
429const format = str => str.replace(/^\.\//, '');
430const isMatch = picomatch('foo/*.js', { format });
431console.log(isMatch('./foo/bar.js')); //=> true
432```
433
434#### options.onMatch
435
436```js
437const onMatch = ({ glob, regex, input, output }) => {
438 console.log({ glob, regex, input, output });
439};
440
441const isMatch = picomatch('*', { onMatch });
442isMatch('foo');
443isMatch('bar');
444isMatch('baz');
445```
446
447#### options.onIgnore
448
449```js
450const onIgnore = ({ glob, regex, input, output }) => {
451 console.log({ glob, regex, input, output });
452};
453
454const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });
455isMatch('foo');
456isMatch('bar');
457isMatch('baz');
458```
459
460#### options.onResult
461
462```js
463const onResult = ({ glob, regex, input, output }) => {
464 console.log({ glob, regex, input, output });
465};
466
467const isMatch = picomatch('*', { onResult, ignore: 'f*' });
468isMatch('foo');
469isMatch('bar');
470isMatch('baz');
471```
472
473<br>
474<br>
475
476## Globbing features
477
478* [Basic globbing](#basic-globbing) (Wildcard matching)
479* [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)
480
481### Basic globbing
482
483| **Character** | **Description** |
484| --- | --- |
485| `*` | Matches any character zero or more times, excluding path separators. Does _not match_ path separators or hidden files or directories ("dotfiles"), unless explicitly enabled by setting the `dot` option to `true`. |
486| `**` | Matches any character zero or more times, including path separators. Note that `**` will only match path separators (`/`, and `\\` on Windows) when they are the only characters in a path segment. Thus, `foo**/bar` is equivalent to `foo*/bar`, and `foo/a**b/bar` is equivalent to `foo/a*b/bar`, and _more than two_ consecutive stars in a glob path segment are regarded as _a single star_. Thus, `foo/***/bar` is equivalent to `foo/*/bar`. |
487| `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |
488| `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |
489
490#### Matching behavior vs. Bash
491
492Picomatch's matching features and expected results in unit tests are based on Bash's unit tests and the Bash 4.3 specification, with the following exceptions:
493
494* Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.
495* Bash greedily matches with negated extglobs. For example, Bash 4.3 says that `!(foo)*` should match `foo` and `foobar`, since the trailing `*` bracktracks to match the preceding pattern. This is very memory-inefficient, and IMHO, also incorrect. Picomatch would return `false` for both `foo` and `foobar`.
496
497<br>
498
499### Advanced globbing
500
501* [extglobs](#extglobs)
502* [POSIX brackets](#posix-brackets)
503* [Braces](#brace-expansion)
504
505#### Extglobs
506
507| **Pattern** | **Description** |
508| --- | --- |
509| `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |
510| `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |
511| `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |
512| `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |
513| `!(pattern)` | Match _anything but_ `pattern` |
514
515**Examples**
516
517```js
518const pm = require('picomatch');
519
520// *(pattern) matches ZERO or more of "pattern"
521console.log(pm.isMatch('a', 'a*(z)')); // true
522console.log(pm.isMatch('az', 'a*(z)')); // true
523console.log(pm.isMatch('azzz', 'a*(z)')); // true
524
525// +(pattern) matches ONE or more of "pattern"
526console.log(pm.isMatch('a', 'a*(z)')); // true
527console.log(pm.isMatch('az', 'a*(z)')); // true
528console.log(pm.isMatch('azzz', 'a*(z)')); // true
529
530// supports multiple extglobs
531console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
532
533// supports nested extglobs
534console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
535```
536
537#### POSIX brackets
538
539POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.
540
541**Enable POSIX bracket support**
542
543```js
544console.log(pm.makeRe('[[:word:]]+', { posix: true }));
545//=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/
546```
547
548**Supported POSIX classes**
549
550The following named POSIX bracket expressions are supported:
551
552* `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`
553* `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.
554* `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.
555* `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.
556* `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.
557* `[:digit:]` - Numerical digits, equivalent to `[0-9]`.
558* `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.
559* `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.
560* `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.
561* `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.
562* `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.
563* `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.
564* `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.
565* `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.
566
567See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.
568
569### Braces
570
571Picomatch does not do brace expansion. For [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) and advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch) instead. Picomatch has very basic support for braces.
572
573### Matching special characters as literals
574
575If you wish to match the following special characters in a filepath, and you want to use these characters in your glob pattern, they must be escaped with backslashes or quotes:
576
577**Special Characters**
578
579Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.
580
581To match any of the following characters as literals: `$^*+?()[]
582
583Examples:
584
585```js
586console.log(pm.makeRe('foo/bar \\(1\\)'));
587console.log(pm.makeRe('foo/bar \\(1\\)'));
588```
589
590<br>
591<br>
592
593## Library Comparisons
594
595The following table shows which features are supported by [minimatch](https://github.com/isaacs/minimatch), [micromatch](https://github.com/micromatch/micromatch), [picomatch](https://github.com/micromatch/picomatch), [nanomatch](https://github.com/micromatch/nanomatch), [extglob](https://github.com/micromatch/extglob), [braces](https://github.com/micromatch/braces), and [expand-brackets](https://github.com/micromatch/expand-brackets).
596
597| **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |
598| --- | --- | --- | --- | --- | --- | --- | --- |
599| Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |
600| Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |
601| Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |
602| Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |
603| Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |
604| Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |
605| Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |
606| File system operations | - | - | - | - | - | - | - |
607
608<br>
609<br>
610
611## Benchmarks
612
613Performance comparison of picomatch and minimatch.
614
615```
616# .makeRe star
617 picomatch x 1,993,050 ops/sec ±0.51% (91 runs sampled)
618 minimatch x 627,206 ops/sec ±1.96% (87 runs sampled))
619
620# .makeRe star; dot=true
621 picomatch x 1,436,640 ops/sec ±0.62% (91 runs sampled)
622 minimatch x 525,876 ops/sec ±0.60% (88 runs sampled)
623
624# .makeRe globstar
625 picomatch x 1,592,742 ops/sec ±0.42% (90 runs sampled)
626 minimatch x 962,043 ops/sec ±1.76% (91 runs sampled)d)
627
628# .makeRe globstars
629 picomatch x 1,615,199 ops/sec ±0.35% (94 runs sampled)
630 minimatch x 477,179 ops/sec ±1.33% (91 runs sampled)
631
632# .makeRe with leading star
633 picomatch x 1,220,856 ops/sec ±0.40% (92 runs sampled)
634 minimatch x 453,564 ops/sec ±1.43% (94 runs sampled)
635
636# .makeRe - basic braces
637 picomatch x 392,067 ops/sec ±0.70% (90 runs sampled)
638 minimatch x 99,532 ops/sec ±2.03% (87 runs sampled))
639```
640
641<br>
642<br>
643
644## Philosophies
645
646The goal of this library is to be blazing fast, without compromising on accuracy.
647
648**Accuracy**
649
650The number one of goal of this library is accuracy. However, it's not unusual for different glob implementations to have different rules for matching behavior, even with simple wildcard matching. It gets increasingly more complicated when combinations of different features are combined, like when extglobs are combined with globstars, braces, slashes, and so on: `!(**/{a,b,*/c})`.
651
652Thus, given that there is no canonical glob specification to use as a single source of truth when differences of opinion arise regarding behavior, sometimes we have to implement our best judgement and rely on feedback from users to make improvements.
653
654**Performance**
655
656Although this library performs well in benchmarks, and in most cases it's faster than other popular libraries we benchmarked against, we will always choose accuracy over performance. It's not helpful to anyone if our library is faster at returning the wrong answer.
657
658<br>
659<br>
660
661## About
662
663<details>
664<summary><strong>Contributing</strong></summary>
665
666Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
667
668Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
669
670</details>
671
672<details>
673<summary><strong>Running Tests</strong></summary>
674
675Running 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:
676
677```sh
678npm install && npm test
679```
680
681</details>
682
683<details>
684<summary><strong>Building docs</strong></summary>
685
686_(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.)_
687
688To generate the readme, run the following command:
689
690```sh
691npm install -g verbose/verb#dev verb-generate-readme && verb
692```
693
694</details>
695
696### Author
697
698**Jon Schlinkert**
699
700* [GitHub Profile](https://github.com/jonschlinkert)
701* [Twitter Profile](https://twitter.com/jonschlinkert)
702* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
703
704### License
705
706Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
707Released under the [MIT License](LICENSE).
Note: See TracBrowser for help on using the repository browser.