source: frontend/node_modules/picomatch/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 27.3 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` | `string` | `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| `matchBase` | `boolean` | `false` | Alias for `basename` |
321| `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
322| `maxExtglobRecursion` | `number\|boolean` | `0` | Limit nested quantified extglobs and other risky repeated extglob forms. When the limit is exceeded, the extglob is treated as a literal string instead of being compiled to regex. Set to `false` to disable this safeguard. |
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
344picomatch has automatic detection for regex positive and negative lookbehinds. If the pattern contains a negative lookbehind, you must be using Node.js >= 8.10 or else picomatch will throw an error.
345
346### Scan Options
347
348In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
349
350| **Option** | **Type** | **Default value** | **Description** |
351| --- | --- | --- | --- |
352| `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |
353| `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 |
354
355**Example**
356
357```js
358const picomatch = require('picomatch');
359const result = picomatch.scan('!./foo/*.js', { tokens: true });
360console.log(result);
361// {
362// prefix: '!./',
363// input: '!./foo/*.js',
364// start: 3,
365// base: 'foo',
366// glob: '*.js',
367// isBrace: false,
368// isBracket: false,
369// isGlob: true,
370// isExtglob: false,
371// isGlobstar: false,
372// negated: true,
373// maxDepth: 2,
374// tokens: [
375// { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },
376// { value: 'foo', depth: 1, isGlob: false },
377// { value: '*.js', depth: 1, isGlob: true }
378// ],
379// slashes: [ 2, 6 ],
380// parts: [ 'foo', '*.js' ]
381// }
382```
383
384<br>
385
386### Options Examples
387
388#### options.expandRange
389
390**Type**: `function`
391
392**Default**: `undefined`
393
394Custom 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.
395
396**Example**
397
398The following example shows how to create a glob that matches a folder
399
400```js
401const fill = require('fill-range');
402const regex = pm.makeRe('foo/{01..25}/bar', {
403 expandRange(a, b) {
404 return `(${fill(a, b, { toRegex: true })})`;
405 }
406});
407
408console.log(regex);
409//=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/
410
411console.log(regex.test('foo/00/bar')) // false
412console.log(regex.test('foo/01/bar')) // true
413console.log(regex.test('foo/10/bar')) // true
414console.log(regex.test('foo/22/bar')) // true
415console.log(regex.test('foo/25/bar')) // true
416console.log(regex.test('foo/26/bar')) // false
417```
418
419#### options.format
420
421**Type**: `function`
422
423**Default**: `undefined`
424
425Custom function for formatting strings before they're matched.
426
427**Example**
428
429```js
430// strip leading './' from strings
431const format = str => str.replace(/^\.\//, '');
432const isMatch = picomatch('foo/*.js', { format });
433console.log(isMatch('./foo/bar.js')); //=> true
434```
435
436#### options.onMatch
437
438```js
439const onMatch = ({ glob, regex, input, output }) => {
440 console.log({ glob, regex, input, output });
441};
442
443const isMatch = picomatch('*', { onMatch });
444isMatch('foo');
445isMatch('bar');
446isMatch('baz');
447```
448
449#### options.onIgnore
450
451```js
452const onIgnore = ({ glob, regex, input, output }) => {
453 console.log({ glob, regex, input, output });
454};
455
456const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });
457isMatch('foo');
458isMatch('bar');
459isMatch('baz');
460```
461
462#### options.onResult
463
464```js
465const onResult = ({ glob, regex, input, output }) => {
466 console.log({ glob, regex, input, output });
467};
468
469const isMatch = picomatch('*', { onResult, ignore: 'f*' });
470isMatch('foo');
471isMatch('bar');
472isMatch('baz');
473```
474
475<br>
476<br>
477
478## Globbing features
479
480* [Basic globbing](#basic-globbing) (Wildcard matching)
481* [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)
482
483### Basic globbing
484
485| **Character** | **Description** |
486| --- | --- |
487| `*` | 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`. |
488| `**` | 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`. |
489| `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |
490| `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |
491
492#### Matching behavior vs. Bash
493
494Picomatch'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:
495
496* Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.
497* 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`.
498
499<br>
500
501### Advanced globbing
502
503* [extglobs](#extglobs)
504* [POSIX brackets](#posix-brackets)
505* [Braces](#brace-expansion)
506
507#### Extglobs
508
509| **Pattern** | **Description** |
510| --- | --- |
511| `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |
512| `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |
513| `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |
514| `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |
515| `!(pattern)` | Match _anything but_ `pattern` |
516
517**Examples**
518
519```js
520const pm = require('picomatch');
521
522// *(pattern) matches ZERO or more of "pattern"
523console.log(pm.isMatch('a', 'a*(z)')); // true
524console.log(pm.isMatch('az', 'a*(z)')); // true
525console.log(pm.isMatch('azzz', 'a*(z)')); // true
526
527// +(pattern) matches ONE or more of "pattern"
528console.log(pm.isMatch('a', 'a*(z)')); // true
529console.log(pm.isMatch('az', 'a*(z)')); // true
530console.log(pm.isMatch('azzz', 'a*(z)')); // true
531
532// supports multiple extglobs
533console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
534
535// supports nested extglobs
536console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
537
538// risky quantified extglobs are treated literally by default
539console.log(pm.makeRe('+(a|aa)'));
540//=> /^(?:\+\(a\|aa\))$/
541
542// increase the limit to allow a small amount of nested quantified extglobs
543console.log(pm.isMatch('aaa', '+(+(a))', { maxExtglobRecursion: 1 })); // true
544```
545
546#### POSIX brackets
547
548POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.
549
550**Enable POSIX bracket support**
551
552```js
553console.log(pm.makeRe('[[:word:]]+', { posix: true }));
554//=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/
555```
556
557**Supported POSIX classes**
558
559The following named POSIX bracket expressions are supported:
560
561* `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`
562* `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.
563* `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.
564* `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.
565* `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.
566* `[:digit:]` - Numerical digits, equivalent to `[0-9]`.
567* `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.
568* `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.
569* `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.
570* `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.
571* `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.
572* `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.
573* `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.
574* `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.
575
576See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.
577
578### Braces
579
580Picomatch 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.
581
582### Matching special characters as literals
583
584If 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:
585
586**Special Characters**
587
588Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.
589
590To match any of the following characters as literals: `$^*+?()[]
591
592Examples:
593
594```js
595console.log(pm.makeRe('foo/bar \\(1\\)'));
596console.log(pm.makeRe('foo/bar \\(1\\)'));
597```
598
599<br>
600<br>
601
602## Library Comparisons
603
604The 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).
605
606| **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |
607| --- | --- | --- | --- | --- | --- | --- | --- |
608| Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |
609| Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |
610| Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |
611| Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |
612| Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |
613| Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |
614| Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |
615| File system operations | - | - | - | - | - | - | - |
616
617<br>
618<br>
619
620## Benchmarks
621
622Performance comparison of picomatch and minimatch.
623
624```
625# .makeRe star
626 picomatch x 1,993,050 ops/sec ±0.51% (91 runs sampled)
627 minimatch x 627,206 ops/sec ±1.96% (87 runs sampled))
628
629# .makeRe star; dot=true
630 picomatch x 1,436,640 ops/sec ±0.62% (91 runs sampled)
631 minimatch x 525,876 ops/sec ±0.60% (88 runs sampled)
632
633# .makeRe globstar
634 picomatch x 1,592,742 ops/sec ±0.42% (90 runs sampled)
635 minimatch x 962,043 ops/sec ±1.76% (91 runs sampled)d)
636
637# .makeRe globstars
638 picomatch x 1,615,199 ops/sec ±0.35% (94 runs sampled)
639 minimatch x 477,179 ops/sec ±1.33% (91 runs sampled)
640
641# .makeRe with leading star
642 picomatch x 1,220,856 ops/sec ±0.40% (92 runs sampled)
643 minimatch x 453,564 ops/sec ±1.43% (94 runs sampled)
644
645# .makeRe - basic braces
646 picomatch x 392,067 ops/sec ±0.70% (90 runs sampled)
647 minimatch x 99,532 ops/sec ±2.03% (87 runs sampled))
648```
649
650<br>
651<br>
652
653## Philosophies
654
655The goal of this library is to be blazing fast, without compromising on accuracy.
656
657**Accuracy**
658
659The 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})`.
660
661Thus, 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.
662
663**Performance**
664
665Although 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.
666
667<br>
668<br>
669
670## About
671
672<details>
673<summary><strong>Contributing</strong></summary>
674
675Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
676
677Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
678
679</details>
680
681<details>
682<summary><strong>Running Tests</strong></summary>
683
684Running 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:
685
686```sh
687npm install && npm test
688```
689
690</details>
691
692<details>
693<summary><strong>Building docs</strong></summary>
694
695_(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.)_
696
697To generate the readme, run the following command:
698
699```sh
700npm install -g verbose/verb#dev verb-generate-readme && verb
701```
702
703</details>
704
705### Author
706
707**Jon Schlinkert**
708
709* [GitHub Profile](https://github.com/jonschlinkert)
710* [Twitter Profile](https://twitter.com/jonschlinkert)
711* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
712
713### License
714
715Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
716Released under the [MIT License](LICENSE).
Note: See TracBrowser for help on using the repository browser.