Pinsave/counterstrike
1
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 dependencies32* **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 tests37 38See the [library comparison](#library-comparisons) to other libraries.39 40<br>41<br>42 43## Table of Contents44 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## Install83 84Install with [npm](https://www.npmjs.com/):85 86```sh87npm install --save picomatch88```89 90<br>91 92## Usage93 94The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.95 96```js97const pm = require('picomatch');98const isMatch = pm('*.js');99 100console.log(isMatch('abcd')); //=> false101console.log(isMatch('a.js')); //=> true102console.log(isMatch('a.md')); //=> false103console.log(isMatch('a/b.js')); //=> false104```105 106<br>107 108## API109 110### [picomatch](lib/picomatch.js#L31)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```js123const picomatch = require('picomatch');124// picomatch(glob[, options]);125 126const isMatch = picomatch('*.!(*a)');127console.log(isMatch('a.a')); //=> false128console.log(isMatch('a.b')); //=> true129```130 131**Example without node.js**132 133For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.134 135```js136const picomatch = require('picomatch/posix');137// the same API, defaulting to posix paths138const isMatch = picomatch('a/*');139console.log(isMatch('a\\b')); //=> false140console.log(isMatch('a/b')); //=> true141 142// you can still configure the matcher function to accept windows paths143const isMatch = picomatch('a/*', { options: windows });144console.log(isMatch('a\\b')); //=> true145console.log(isMatch('a/b')); //=> true146```147 148### [.test](lib/picomatch.js#L116)149 150Test `input` with the given `regex`. This is used by the main `picomatch()` function to test the input string.151 152**Params**153 154* `input` **{String}**: String to test.155* `regex` **{RegExp}**156* `returns` **{Object}**: Returns an object with matching info.157 158**Example**159 160```js161const picomatch = require('picomatch');162// picomatch.test(input, regex[, options]);163 164console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));165// { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }166```167 168### [.matchBase](lib/picomatch.js#L160)169 170Match the basename of a filepath.171 172**Params**173 174* `input` **{String}**: String to test.175* `glob` **{RegExp|String}**: Glob pattern or regex created by [.makeRe](#makeRe).176* `returns` **{Boolean}**177 178**Example**179 180```js181const picomatch = require('picomatch');182// picomatch.matchBase(input, glob[, options]);183console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true184```185 186### [.isMatch](lib/picomatch.js#L182)187 188Returns true if **any** of the given glob `patterns` match the specified `string`.189 190**Params**191 192* **{String|Array}**: str The string to test.193* **{String|Array}**: patterns One or more glob patterns to use for matching.194* **{Object}**: See available [options](#options).195* `returns` **{Boolean}**: Returns true if any patterns match `str`196 197**Example**198 199```js200const picomatch = require('picomatch');201// picomatch.isMatch(string, patterns[, options]);202 203console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true204console.log(picomatch.isMatch('a.a', 'b.*')); //=> false205```206 207### [.parse](lib/picomatch.js#L198)208 209Parse a glob pattern to create the source string for a regular expression.210 211**Params**212 213* `pattern` **{String}**214* `options` **{Object}**215* `returns` **{Object}**: Returns an object with useful properties and output to be used as a regex source string.216 217**Example**218 219```js220const picomatch = require('picomatch');221const result = picomatch.parse(pattern[, options]);222```223 224### [.scan](lib/picomatch.js#L230)225 226Scan a glob pattern to separate the pattern into segments.227 228**Params**229 230* `input` **{String}**: Glob pattern to scan.231* `options` **{Object}**232* `returns` **{Object}**: Returns an object with233 234**Example**235 236```js237const picomatch = require('picomatch');238// picomatch.scan(input[, options]);239 240const result = picomatch.scan('!./foo/*.js');241console.log(result);242{ prefix: '!./',243 input: '!./foo/*.js',244 start: 3,245 base: 'foo',246 glob: '*.js',247 isBrace: false,248 isBracket: false,249 isGlob: true,250 isExtglob: false,251 isGlobstar: false,252 negated: true }253```254 255### [.compileRe](lib/picomatch.js#L244)256 257Compile a regular expression from the `state` object returned by the258[parse()](#parse) method.259 260**Params**261 262* `state` **{Object}**263* `options` **{Object}**264* `returnOutput` **{Boolean}**: Intended for implementors, this argument allows you to return the raw output from the parser.265* `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.266* `returns` **{RegExp}**267 268### [.makeRe](lib/picomatch.js#L285)269 270Create a regular expression from a parsed glob pattern.271 272**Params**273 274* `state` **{String}**: The object returned from the `.parse` method.275* `options` **{Object}**276* `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.277* `returnState` **{Boolean}**: Implementors may use this argument to return the state from the parsed glob with the returned regular expression.278* `returns` **{RegExp}**: Returns a regex created from the given pattern.279 280**Example**281 282```js283const picomatch = require('picomatch');284const state = picomatch.parse('*.js');285// picomatch.compileRe(state[, options]);286 287console.log(picomatch.compileRe(state));288//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/289```290 291### [.toRegex](lib/picomatch.js#L320)292 293Create a regular expression from the given regex source string.294 295**Params**296 297* `source` **{String}**: Regular expression source string.298* `options` **{Object}**299* `returns` **{RegExp}**300 301**Example**302 303```js304const picomatch = require('picomatch');305// picomatch.toRegex(source[, options]);306 307const { output } = picomatch.parse('*.js');308console.log(picomatch.toRegex(output));309//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/310```311 312<br>313 314## Options315 316### Picomatch options317 318The following options may be used with the main `picomatch()` function or any of the methods on the picomatch API.319 320| **Option** | **Type** | **Default value** | **Description** |321| --- | --- | --- | --- |322| `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`. |323| `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |324| `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |325| `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |326| `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` |327| `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |328| `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |329| `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. |330| `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |331| `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`. |332| `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |333| [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. |334| `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |335| `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |336| `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |337| `matchBase` | `boolean` | `false` | Alias for `basename` |338| `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |339| `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |340| `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |341| `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |342| `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. |343| `noext` | `boolean` | `false` | Alias for `noextglob` |344| `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |345| `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |346| `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |347| `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. |348| [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |349| [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |350| [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |351| `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |352| `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |353| `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |354| `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |355| `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |356| `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |357| `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |358| `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |359| `windows` | `boolean` | `false` | Also accept backslashes as the path separator. |360 361### Scan Options362 363In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.364 365| **Option** | **Type** | **Default value** | **Description** |366| --- | --- | --- | --- |367| `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |368| `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 |369 370**Example**371 372```js373const picomatch = require('picomatch');374const result = picomatch.scan('!./foo/*.js', { tokens: true });375console.log(result);376// {377// prefix: '!./',378// input: '!./foo/*.js',379// start: 3,380// base: 'foo',381// glob: '*.js',382// isBrace: false,383// isBracket: false,384// isGlob: true,385// isExtglob: false,386// isGlobstar: false,387// negated: true,388// maxDepth: 2,389// tokens: [390// { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },391// { value: 'foo', depth: 1, isGlob: false },392// { value: '*.js', depth: 1, isGlob: true }393// ],394// slashes: [ 2, 6 ],395// parts: [ 'foo', '*.js' ]396// }397```398 399<br>400 401### Options Examples402 403#### options.expandRange404 405**Type**: `function`406 407**Default**: `undefined`408 409Custom 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.410 411**Example**412 413The following example shows how to create a glob that matches a folder414 415```js416const fill = require('fill-range');417const regex = pm.makeRe('foo/{01..25}/bar', {418 expandRange(a, b) {419 return `(${fill(a, b, { toRegex: true })})`;420 }421});422 423console.log(regex);424//=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/425 426console.log(regex.test('foo/00/bar')) // false427console.log(regex.test('foo/01/bar')) // true428console.log(regex.test('foo/10/bar')) // true429console.log(regex.test('foo/22/bar')) // true430console.log(regex.test('foo/25/bar')) // true431console.log(regex.test('foo/26/bar')) // false432```433 434#### options.format435 436**Type**: `function`437 438**Default**: `undefined`439 440Custom function for formatting strings before they're matched.441 442**Example**443 444```js445// strip leading './' from strings446const format = str => str.replace(/^\.\//, '');447const isMatch = picomatch('foo/*.js', { format });448console.log(isMatch('./foo/bar.js')); //=> true449```450 451#### options.onMatch452 453```js454const onMatch = ({ glob, regex, input, output }) => {455 console.log({ glob, regex, input, output });456};457 458const isMatch = picomatch('*', { onMatch });459isMatch('foo');460isMatch('bar');461isMatch('baz');462```463 464#### options.onIgnore465 466```js467const onIgnore = ({ glob, regex, input, output }) => {468 console.log({ glob, regex, input, output });469};470 471const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });472isMatch('foo');473isMatch('bar');474isMatch('baz');475```476 477#### options.onResult478 479```js480const onResult = ({ glob, regex, input, output }) => {481 console.log({ glob, regex, input, output });482};483 484const isMatch = picomatch('*', { onResult, ignore: 'f*' });485isMatch('foo');486isMatch('bar');487isMatch('baz');488```489 490<br>491<br>492 493## Globbing features494 495* [Basic globbing](#basic-globbing) (Wildcard matching)496* [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)497 498### Basic globbing499 500| **Character** | **Description** |501| --- | --- |502| `*` | 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`. |503| `**` | Matches any character zero or more times, including path separators. Note that `**` will only match path separators (`/`, and `\\` with the `windows` option) 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`. |504| `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |505| `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |506 507#### Matching behavior vs. Bash508 509Picomatch'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:510 511* Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.512* 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`.513 514<br>515 516### Advanced globbing517 518* [extglobs](#extglobs)519* [POSIX brackets](#posix-brackets)520* [Braces](#brace-expansion)521 522#### Extglobs523 524| **Pattern** | **Description** |525| --- | --- |526| `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |527| `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |528| `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |529| `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |530| `!(pattern)` | Match _anything but_ `pattern` |531 532**Examples**533 534```js535const pm = require('picomatch');536 537// *(pattern) matches ZERO or more of "pattern"538console.log(pm.isMatch('a', 'a*(z)')); // true539console.log(pm.isMatch('az', 'a*(z)')); // true540console.log(pm.isMatch('azzz', 'a*(z)')); // true541 542// +(pattern) matches ONE or more of "pattern"543console.log(pm.isMatch('a', 'a+(z)')); // false544console.log(pm.isMatch('az', 'a+(z)')); // true545console.log(pm.isMatch('azzz', 'a+(z)')); // true546 547// supports multiple extglobs548console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false549 550// supports nested extglobs551console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true552```553 554#### POSIX brackets555 556POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.557 558**Enable POSIX bracket support**559 560```js561console.log(pm.makeRe('[[:word:]]+', { posix: true }));562//=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/563```564 565**Supported POSIX classes**566 567The following named POSIX bracket expressions are supported:568 569* `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`570* `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.571* `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.572* `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.573* `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.574* `[:digit:]` - Numerical digits, equivalent to `[0-9]`.575* `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.576* `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.577* `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.578* `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.579* `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.580* `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.581* `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.582* `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.583 584See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.585 586### Braces587 588Picomatch 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.589 590### Matching special characters as literals591 592If 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:593 594**Special Characters**595 596Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.597 598To match any of the following characters as literals: `$^*+?()[]599 600Examples:601 602```js603console.log(pm.makeRe('foo/bar \\(1\\)'));604console.log(pm.makeRe('foo/bar \\(1\\)'));605```606 607<br>608<br>609 610## Library Comparisons611 612The 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).613 614| **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |615| --- | --- | --- | --- | --- | --- | --- | --- |616| Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |617| Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |618| Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |619| Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |620| Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |621| Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |622| Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |623| File system operations | - | - | - | - | - | - | - |624 625<br>626<br>627 628## Benchmarks629 630Performance comparison of picomatch and minimatch.631 632_(Pay special attention to the last three benchmarks. Minimatch freezes on long ranges.)_633 634```635# .makeRe star (*)636 picomatch x 4,449,159 ops/sec ±0.24% (97 runs sampled)637 minimatch x 632,772 ops/sec ±0.14% (98 runs sampled)638 639# .makeRe star; dot=true (*)640 picomatch x 3,500,079 ops/sec ±0.26% (99 runs sampled)641 minimatch x 564,916 ops/sec ±0.23% (96 runs sampled)642 643# .makeRe globstar (**)644 picomatch x 3,261,000 ops/sec ±0.27% (98 runs sampled)645 minimatch x 1,664,766 ops/sec ±0.20% (100 runs sampled)646 647# .makeRe globstars (**/**/**)648 picomatch x 3,284,469 ops/sec ±0.18% (97 runs sampled)649 minimatch x 1,435,880 ops/sec ±0.34% (95 runs sampled)650 651# .makeRe with leading star (*.txt)652 picomatch x 3,100,197 ops/sec ±0.35% (99 runs sampled)653 minimatch x 428,347 ops/sec ±0.42% (94 runs sampled)654 655# .makeRe - basic braces ({a,b,c}*.txt)656 picomatch x 443,578 ops/sec ±1.33% (89 runs sampled)657 minimatch x 107,143 ops/sec ±0.35% (94 runs sampled)658 659# .makeRe - short ranges ({a..z}*.txt)660 picomatch x 415,484 ops/sec ±0.76% (96 runs sampled)661 minimatch x 14,299 ops/sec ±0.26% (96 runs sampled)662 663# .makeRe - medium ranges ({1..100000}*.txt)664 picomatch x 395,020 ops/sec ±0.87% (89 runs sampled)665 minimatch x 2 ops/sec ±4.59% (10 runs sampled)666 667# .makeRe - long ranges ({1..10000000}*.txt)668 picomatch x 400,036 ops/sec ±0.83% (90 runs sampled)669 minimatch (FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory)670```671 672<br>673<br>674 675## Philosophies676 677The goal of this library is to be blazing fast, without compromising on accuracy.678 679**Accuracy**680 681The 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})`.682 683Thus, 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.684 685**Performance**686 687Although 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.688 689<br>690<br>691 692## About693 694<details>695<summary><strong>Contributing</strong></summary>696 697Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).698 699Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.700 701</details>702 703<details>704<summary><strong>Running Tests</strong></summary>705 706Running 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:707 708```sh709npm install && npm test710```711 712</details>713 714<details>715<summary><strong>Building docs</strong></summary>716 717_(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.)_718 719To generate the readme, run the following command:720 721```sh722npm install -g verbose/verb#dev verb-generate-readme && verb723```724 725</details>726 727### Author728 729**Jon Schlinkert**730 731* [GitHub Profile](https://github.com/jonschlinkert)732* [Twitter Profile](https://twitter.com/jonschlinkert)733* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)734 735### License736 737Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).738Released under the [MIT License](LICENSE).739 