first commit
This commit is contained in:
15
node_modules/wildcard-match/LICENSE
generated
vendored
Normal file
15
node_modules/wildcard-match/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2021 Alex Schneider
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
289
node_modules/wildcard-match/README.md
generated
vendored
Normal file
289
node_modules/wildcard-match/README.md
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
<br>
|
||||
|
||||
<h1 align="center">wildcard-match</h1>
|
||||
|
||||
<p align="center">
|
||||
<strong>A tiny and extremely fast JavaScript library for compiling and matching basic glob patterns</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/wildcard-match"><img src="https://img.shields.io/npm/v/wildcard-match" alt="npm package"></a>
|
||||
|
||||
<a href="https://bundlephobia.com/package/wildcard-match"><img src="https://img.shields.io/bundlephobia/minzip/wildcard-match?color=%23b4a&label=size" alt="size"></a>
|
||||
|
||||
<a href="https://github.com/axtgr/wildcard-match/actions"><img src="https://img.shields.io/github/actions/workflow/status/axtgr/wildcard-match/ci.yml?label=CI&logo=github" alt="CI"></a>
|
||||
|
||||
<a href="https://www.buymeacoffee.com/axtgr"><img src="https://img.shields.io/badge/%F0%9F%8D%BA-Buy%20me%20a%20beer-red?style=flat" alt="Buy me a beer"></a>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
Wildcard-match takes one or more basic glob patterns, compiles them into a RegExp and returns a function for matching strings with it.
|
||||
|
||||
Glob patterns are strings that contain `?`, `*` and `**` wildcards. When such a pattern is compared with another string, these wildcards can replace one or more symbols. For example, `src/*` would match both `src/foo` and `src/bar`.
|
||||
|
||||
This library's goal is to be as small and as fast as possible while supporting only the most basic wildcards. If you need character ranges, extended globs, braces and other advanced features, check out [outmatch](https://github.com/axtgr/outmatch).
|
||||
|
||||
## Quickstart
|
||||
|
||||
```
|
||||
npm install wildcard-match
|
||||
```
|
||||
|
||||
```js
|
||||
import wcmatch from 'wildcard-match'
|
||||
|
||||
const isMatch = wcmatch('src/**/*.?s')
|
||||
|
||||
isMatch('src/components/header/index.js') //=> true
|
||||
isMatch('src/README.md') //=> false
|
||||
|
||||
isMatch.pattern //=> 'src/**/*.?s'
|
||||
isMatch.options //=> { separator: true }
|
||||
isMatch.regexp //=> /^src[/\\]+?(?:[^/\\]*?[/\\]+?)*?[^/\\]*?\.[^/\\]s[/\\]*?$/
|
||||
```
|
||||
|
||||
More details are available in the [Installation](#installation), [Usage](#usage) and [API](#api) sections.
|
||||
|
||||
## Features
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">🍃</td>
|
||||
<td><strong>Lightweight</strong><br>No dependencies. <em>Less than 1 KB</em> when minified and gzipped</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">🏎</td>
|
||||
<td><strong>Fast</strong><br>Compiles and matches patterns faster than any other known library</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">🌞</td>
|
||||
<td><strong>Simple</strong><br>The API is a single function</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">⚒</td>
|
||||
<td><strong>Reliable</strong><br>Written in TypeScript. Covered by hundreds of unit tests</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">🔌</td>
|
||||
<td><strong>Compatible</strong><br>Works in any ES5+ environment including older versions of Node.js, Bun, Deno, React Native and browsers</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
For comparison with the alternatives, see the [corresponding section](#comparison).
|
||||
|
||||
## Installation
|
||||
|
||||
The package is distributed via the npm package registry. It can be installed using one of the compatible package managers or included directly from a CDN.
|
||||
|
||||
#### [npm](https://www.npmjs.com)
|
||||
|
||||
```
|
||||
npm install wildcard-match
|
||||
```
|
||||
|
||||
#### [Yarn](https://yarnpkg.com)
|
||||
|
||||
```
|
||||
yarn add wildcard-match
|
||||
```
|
||||
|
||||
#### [pnpm](https://pnpm.js.org)
|
||||
|
||||
```
|
||||
pnpm install wildcard-match
|
||||
```
|
||||
|
||||
#### CDN
|
||||
|
||||
When included from a CDN, wildcard-match is available as the global function `wcmatch`.
|
||||
|
||||
- [unpkg](https://unpkg.com/wildcard-match)
|
||||
- [jsDelivr](https://www.jsdelivr.com/package/npm/wildcard-match)
|
||||
|
||||
## Usage
|
||||
|
||||
### Basics
|
||||
|
||||
Wildcard-match comes built in ESM, CommonJS and UMD formats and includes TypeScript typings. The examples use ESM imports, which can be replaced with the following line for CommonJS: `const wcmatch = require('wildcard-match')`.
|
||||
|
||||
The default export is a function of two arguments, first of which can be either a single glob string or an array of such patterns. The second argument is optional and can be either an [options](#options) object or a separator (which will be the value of the `separator` option). Wildcard-match compiles them into a regular expression and returns a function (usually called `isMatch` in the examples) that tests strings against the pattern. The pattern, options and the compiled RegExp object are available as properties on the returned function:
|
||||
|
||||
```js
|
||||
import wcmatch from 'wildcard-match'
|
||||
|
||||
const isMatch = wcmatch('src/?ar')
|
||||
|
||||
isMatch('src/bar') //=> true
|
||||
isMatch('src/car') //=> true
|
||||
isMatch('src/cvar') //=> false
|
||||
|
||||
isMatch.pattern //=> 'src/?ar'
|
||||
isMatch.options //=> {}
|
||||
isMatch.regexp //=> /^src[/\\]+?[^/\\]ar[/\\]*?$/
|
||||
```
|
||||
|
||||
The returned function can be invoked immediately if there is no need to match a pattern more than once:
|
||||
|
||||
```js
|
||||
wcmatch('src/**/*.js')('src/components/body/index.js') //=> true
|
||||
```
|
||||
|
||||
Compiling a pattern is much slower than comparing a string to it, so it is recommended to always reuse the returned function when possible.
|
||||
|
||||
### Syntax
|
||||
|
||||
Wildcard-match supports the following glob syntax in patterns:
|
||||
|
||||
- `?` matches exactly one arbitrary character excluding separators
|
||||
- `*` matches zero or more arbitrary characters excluding separators
|
||||
- `**` matches any number of segments when used as a whole segment in a separated pattern (e.g. <code>/\*\*/</code> if <code>/</code> is the separator)
|
||||
- `\` escapes the following character making it be treated literally
|
||||
|
||||
More features are available in the [outmatch](https://github.com/axtgr/outmatch) library.
|
||||
|
||||
### Separators
|
||||
|
||||
Globs are most often used to search file paths, which are, essentially, strings split into segments by slashes. While other libraries are usually restricted to this use-case, wildcard-match is able to work with _arbitrary_ strings by accepting a custom separator in the second parameter:
|
||||
|
||||
```js
|
||||
const matchDomain = wcmatch('*.example.com', { separator: '.' })
|
||||
matchDomain('subdomain.example.com') //=> true
|
||||
|
||||
// Here, the second parameter is a shorthand for `{ separator: ',' }`
|
||||
const matchLike = wcmatch('one,**,f?ur', ',')
|
||||
matchLike('one,two,three,four') //=> true
|
||||
```
|
||||
|
||||
The only limitation is that backslashes `\` cannot be used as separators in patterns because
|
||||
wildcard-match uses them for character escaping. However, when `separator` is `undefined`
|
||||
or `true`, `/` in patterns will match both `/` and `\`, so a single pattern with forward
|
||||
slashes can match both Unix and Windows paths:
|
||||
|
||||
```js
|
||||
const isMatchA = outmatch('foo\\bar') // throws an error
|
||||
|
||||
const isMatchB = outmatch('foo/bar') // same as passing `true` as the separator
|
||||
|
||||
isMatchB('foo/bar') //=> true
|
||||
isMatchB('foo\\bar') //=> true
|
||||
|
||||
const isMatchC = outmatch('foo/bar', '/')
|
||||
|
||||
isMatchC('foo/bar') //=> true
|
||||
isMatchC('foo\\bar') //=> false
|
||||
```
|
||||
|
||||
The matching features work with a _segment_ rather than a whole pattern:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch('foo/b*')
|
||||
|
||||
isMatch('foo/bar') //=> true
|
||||
isMatch('foo/b/ar') //=> false
|
||||
```
|
||||
|
||||
Segmentation can be turned off completely by passing `false` as the separator, which makes wildcard-match treat whole patterns as a single segment. Slashes become regular symbols and `*` matches _anything_:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch('foo?ba*', false)
|
||||
isMatch('foo/bar/qux') //=> true
|
||||
```
|
||||
|
||||
A single separator in a pattern will match _one or more_ separators in a sample string:
|
||||
|
||||
```js
|
||||
wcmatch('foo/bar/baz')('foo/bar///baz') //=> true
|
||||
```
|
||||
|
||||
When a pattern has an explicit separator at its end, samples also require one or more trailing separators:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch('foo/bar/')
|
||||
|
||||
isMatch('foo/bar') //=> false
|
||||
isMatch('foo/bar/') //=> true
|
||||
isMatch('foo/bar///') //=> true
|
||||
```
|
||||
|
||||
However, if there is no trailing separator in a pattern, strings will match even if they have separators at the end:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch('foo/bar')
|
||||
|
||||
isMatch('foo/bar') //=> true
|
||||
isMatch('foo/bar/') //=> true
|
||||
isMatch('foo/bar///') //=> true
|
||||
```
|
||||
|
||||
### Multiple Patterns
|
||||
|
||||
Wildcard-match can take an array of glob patterns as the first argument instead of a single pattern. In that case a string will be considered a match if it matches _any_ of the given patterns:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch(['src/*', 'tests/*'])
|
||||
|
||||
isMatch('src/utils.js') //=> true
|
||||
isMatch('tests/utils.js') //=> true
|
||||
```
|
||||
|
||||
### Matching Arrays of Strings
|
||||
|
||||
The returned function can work with arrays of strings when used as the predicate of the native array methods:
|
||||
|
||||
```js
|
||||
const isMatch = wcmatch('src/*.js')
|
||||
const paths = ['readme.md', 'src/index.js', 'src/components/body.js']
|
||||
|
||||
paths.map(isMatch) //=> [ false, true, false ]
|
||||
paths.filter(isMatch) //=> [ 'src/index.js' ]
|
||||
paths.some(isMatch) //=> true
|
||||
paths.every(isMatch) //=> false
|
||||
paths.find(isMatch) //=> 'src/index.js'
|
||||
paths.findIndex(isMatch) //=> 1
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### wcmatch(patterns, options?): isMatch<br>wcmatch(patterns, separator?): isMatch
|
||||
|
||||
Takes a single pattern string or an array of patterns and compiles them into a regular expression. Returns an isMatch function that takes a sample string as its only argument and returns true if the string matches the pattern(s).
|
||||
|
||||
### isMatch(sample): boolean
|
||||
|
||||
Tests if a sample string matches the patterns that were used to compile the regular expression and create this function.
|
||||
|
||||
### isMatch.regexp
|
||||
|
||||
The compiled regular expression.
|
||||
|
||||
### isMatch.pattern
|
||||
|
||||
The original pattern or array of patterns that was used to compile the regular expression and create the isMatch function.
|
||||
|
||||
### isMatch.options
|
||||
|
||||
The options object that was used to compile the regular expression and create the isMatch function.
|
||||
|
||||
### Options
|
||||
|
||||
| Option | Type | Default Value | Description |
|
||||
| ----------- | --------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `separator` | string \| boolean | true | Separator to be used to split patterns and samples into segments<ul><li>`true` — `/` in patterns match both `/` and `\` in samples<li>`false` — don't split<li>_any string_ — custom separator |
|
||||
| `flags` | string | undefined | [Flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags) to pass to the RegExp. For example, setting this option to `'i'` will make the matching case-insensitive |
|
||||
|
||||
## Comparison
|
||||
|
||||
```
|
||||
Node.js v22
|
||||
Pattern: src/test/**/*.?s
|
||||
Sample: src/test/foo/bar.js
|
||||
|
||||
Compilation
|
||||
wildcard-match v5.1.4 1,000,947 ops/sec
|
||||
picomatch v4.0.2 216,903 ops/sec
|
||||
|
||||
Matching
|
||||
wildcard-match v5.1.4 24,330,069 ops/sec
|
||||
picomatch v4.0.2 7,776,730 ops/sec
|
||||
```
|
||||
40
node_modules/wildcard-match/build/index.d.ts
generated
vendored
Normal file
40
node_modules/wildcard-match/build/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
interface WildcardMatchOptions {
|
||||
/** Separator to be used to split patterns and samples into segments */
|
||||
separator?: string | boolean;
|
||||
/** Flags to pass to the RegExp */
|
||||
flags?: string;
|
||||
}
|
||||
interface isMatch {
|
||||
/**
|
||||
* Tests if a sample string matches the pattern(s)
|
||||
*
|
||||
* ```js
|
||||
* isMatch('foo') //=> true
|
||||
* ```
|
||||
*/
|
||||
(sample: string): boolean;
|
||||
/** Compiled regular expression */
|
||||
regexp: RegExp;
|
||||
/** Original pattern or array of patterns that was used to compile the RegExp */
|
||||
pattern: string | string[];
|
||||
/** Options that were used to compile the RegExp */
|
||||
options: WildcardMatchOptions;
|
||||
}
|
||||
declare function isMatch(regexp: RegExp, sample: string): boolean;
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
declare function wildcardMatch(pattern: string | string[], options?: string | boolean | WildcardMatchOptions): isMatch;
|
||||
export = wildcardMatch;
|
||||
40
node_modules/wildcard-match/build/index.es.d.ts
generated
vendored
Normal file
40
node_modules/wildcard-match/build/index.es.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
interface WildcardMatchOptions {
|
||||
/** Separator to be used to split patterns and samples into segments */
|
||||
separator?: string | boolean;
|
||||
/** Flags to pass to the RegExp */
|
||||
flags?: string;
|
||||
}
|
||||
interface isMatch {
|
||||
/**
|
||||
* Tests if a sample string matches the pattern(s)
|
||||
*
|
||||
* ```js
|
||||
* isMatch('foo') //=> true
|
||||
* ```
|
||||
*/
|
||||
(sample: string): boolean;
|
||||
/** Compiled regular expression */
|
||||
regexp: RegExp;
|
||||
/** Original pattern or array of patterns that was used to compile the RegExp */
|
||||
pattern: string | string[];
|
||||
/** Options that were used to compile the RegExp */
|
||||
options: WildcardMatchOptions;
|
||||
}
|
||||
declare function isMatch(regexp: RegExp, sample: string): boolean;
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
declare function wildcardMatch(pattern: string | string[], options?: string | boolean | WildcardMatchOptions): isMatch;
|
||||
export { wildcardMatch as default };
|
||||
169
node_modules/wildcard-match/build/index.es.mjs
generated
vendored
Normal file
169
node_modules/wildcard-match/build/index.es.mjs
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* Escapes a character if it has a special meaning in regular expressions
|
||||
* and returns the character as is if it doesn't
|
||||
*/
|
||||
function escapeRegExpChar(char) {
|
||||
if (char === '-' ||
|
||||
char === '^' ||
|
||||
char === '$' ||
|
||||
char === '+' ||
|
||||
char === '.' ||
|
||||
char === '(' ||
|
||||
char === ')' ||
|
||||
char === '|' ||
|
||||
char === '[' ||
|
||||
char === ']' ||
|
||||
char === '{' ||
|
||||
char === '}' ||
|
||||
char === '*' ||
|
||||
char === '?' ||
|
||||
char === '\\') {
|
||||
return "\\".concat(char);
|
||||
}
|
||||
else {
|
||||
return char;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Escapes all characters in a given string that have a special meaning in regular expressions
|
||||
*/
|
||||
function escapeRegExpString(str) {
|
||||
var result = '';
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result += escapeRegExpChar(str[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Transforms one or more glob patterns into a RegExp pattern
|
||||
*/
|
||||
function transform(pattern, separator) {
|
||||
if (separator === void 0) { separator = true; }
|
||||
if (Array.isArray(pattern)) {
|
||||
var regExpPatterns = pattern.map(function (p) { return "^".concat(transform(p, separator), "$"); });
|
||||
return "(?:".concat(regExpPatterns.join('|'), ")");
|
||||
}
|
||||
var separatorSplitter = '';
|
||||
var separatorMatcher = '';
|
||||
var wildcard = '.';
|
||||
if (separator === true) {
|
||||
separatorSplitter = '/';
|
||||
separatorMatcher = '[/\\\\]';
|
||||
wildcard = '[^/\\\\]';
|
||||
}
|
||||
else if (separator) {
|
||||
separatorSplitter = separator;
|
||||
separatorMatcher = escapeRegExpString(separatorSplitter);
|
||||
if (separatorMatcher.length > 1) {
|
||||
separatorMatcher = "(?:".concat(separatorMatcher, ")");
|
||||
wildcard = "((?!".concat(separatorMatcher, ").)");
|
||||
}
|
||||
else {
|
||||
wildcard = "[^".concat(separatorMatcher, "]");
|
||||
}
|
||||
}
|
||||
var requiredSeparator = separator ? "".concat(separatorMatcher, "+?") : '';
|
||||
var optionalSeparator = separator ? "".concat(separatorMatcher, "*?") : '';
|
||||
var segments = separator ? pattern.split(separatorSplitter) : [pattern];
|
||||
var result = '';
|
||||
for (var s = 0; s < segments.length; s++) {
|
||||
var segment = segments[s];
|
||||
var nextSegment = segments[s + 1];
|
||||
var currentSeparator = '';
|
||||
if (!segment && s > 0) {
|
||||
continue;
|
||||
}
|
||||
if (separator) {
|
||||
if (s === segments.length - 1) {
|
||||
currentSeparator = optionalSeparator;
|
||||
}
|
||||
else if (nextSegment !== '**') {
|
||||
currentSeparator = requiredSeparator;
|
||||
}
|
||||
else {
|
||||
currentSeparator = '';
|
||||
}
|
||||
}
|
||||
if (separator && segment === '**') {
|
||||
if (currentSeparator) {
|
||||
result +=
|
||||
s === 0
|
||||
? ''
|
||||
: s === segments.length - 1
|
||||
? "(?:".concat(requiredSeparator, "|$)")
|
||||
: requiredSeparator;
|
||||
result += "(?:".concat(wildcard, "*?").concat(currentSeparator, ")*?");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (var c = 0; c < segment.length; c++) {
|
||||
var char = segment[c];
|
||||
if (char === '\\') {
|
||||
if (c < segment.length - 1) {
|
||||
result += escapeRegExpChar(segment[c + 1]);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
else if (char === '?') {
|
||||
result += wildcard;
|
||||
}
|
||||
else if (char === '*') {
|
||||
result += "".concat(wildcard, "*?");
|
||||
}
|
||||
else {
|
||||
result += escapeRegExpChar(char);
|
||||
}
|
||||
}
|
||||
result += currentSeparator;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isMatch(regexp, sample) {
|
||||
if (typeof sample !== 'string') {
|
||||
throw new TypeError("Sample must be a string, but ".concat(typeof sample, " given"));
|
||||
}
|
||||
return regexp.test(sample);
|
||||
}
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
function wildcardMatch(pattern, options) {
|
||||
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
|
||||
throw new TypeError("The first argument must be a single pattern string or an array of patterns, but ".concat(typeof pattern, " given"));
|
||||
}
|
||||
if (typeof options === 'string' || typeof options === 'boolean') {
|
||||
options = { separator: options };
|
||||
}
|
||||
if (arguments.length === 2 &&
|
||||
!(typeof options === 'undefined' ||
|
||||
(typeof options === 'object' && options !== null && !Array.isArray(options)))) {
|
||||
throw new TypeError("The second argument must be an options object or a string/boolean separator, but ".concat(typeof options, " given"));
|
||||
}
|
||||
options = options || {};
|
||||
if (options.separator === '\\') {
|
||||
throw new Error('\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead');
|
||||
}
|
||||
var regexpPattern = transform(pattern, options.separator);
|
||||
var regexp = new RegExp("^".concat(regexpPattern, "$"), options.flags);
|
||||
var fn = isMatch.bind(null, regexp);
|
||||
fn.options = options;
|
||||
fn.pattern = pattern;
|
||||
fn.regexp = regexp;
|
||||
return fn;
|
||||
}
|
||||
|
||||
export { wildcardMatch as default };
|
||||
//# sourceMappingURL=index.es.mjs.map
|
||||
1
node_modules/wildcard-match/build/index.es.mjs.map
generated
vendored
Normal file
1
node_modules/wildcard-match/build/index.es.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
171
node_modules/wildcard-match/build/index.js
generated
vendored
Normal file
171
node_modules/wildcard-match/build/index.js
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Escapes a character if it has a special meaning in regular expressions
|
||||
* and returns the character as is if it doesn't
|
||||
*/
|
||||
function escapeRegExpChar(char) {
|
||||
if (char === '-' ||
|
||||
char === '^' ||
|
||||
char === '$' ||
|
||||
char === '+' ||
|
||||
char === '.' ||
|
||||
char === '(' ||
|
||||
char === ')' ||
|
||||
char === '|' ||
|
||||
char === '[' ||
|
||||
char === ']' ||
|
||||
char === '{' ||
|
||||
char === '}' ||
|
||||
char === '*' ||
|
||||
char === '?' ||
|
||||
char === '\\') {
|
||||
return "\\".concat(char);
|
||||
}
|
||||
else {
|
||||
return char;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Escapes all characters in a given string that have a special meaning in regular expressions
|
||||
*/
|
||||
function escapeRegExpString(str) {
|
||||
var result = '';
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result += escapeRegExpChar(str[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Transforms one or more glob patterns into a RegExp pattern
|
||||
*/
|
||||
function transform(pattern, separator) {
|
||||
if (separator === void 0) { separator = true; }
|
||||
if (Array.isArray(pattern)) {
|
||||
var regExpPatterns = pattern.map(function (p) { return "^".concat(transform(p, separator), "$"); });
|
||||
return "(?:".concat(regExpPatterns.join('|'), ")");
|
||||
}
|
||||
var separatorSplitter = '';
|
||||
var separatorMatcher = '';
|
||||
var wildcard = '.';
|
||||
if (separator === true) {
|
||||
separatorSplitter = '/';
|
||||
separatorMatcher = '[/\\\\]';
|
||||
wildcard = '[^/\\\\]';
|
||||
}
|
||||
else if (separator) {
|
||||
separatorSplitter = separator;
|
||||
separatorMatcher = escapeRegExpString(separatorSplitter);
|
||||
if (separatorMatcher.length > 1) {
|
||||
separatorMatcher = "(?:".concat(separatorMatcher, ")");
|
||||
wildcard = "((?!".concat(separatorMatcher, ").)");
|
||||
}
|
||||
else {
|
||||
wildcard = "[^".concat(separatorMatcher, "]");
|
||||
}
|
||||
}
|
||||
var requiredSeparator = separator ? "".concat(separatorMatcher, "+?") : '';
|
||||
var optionalSeparator = separator ? "".concat(separatorMatcher, "*?") : '';
|
||||
var segments = separator ? pattern.split(separatorSplitter) : [pattern];
|
||||
var result = '';
|
||||
for (var s = 0; s < segments.length; s++) {
|
||||
var segment = segments[s];
|
||||
var nextSegment = segments[s + 1];
|
||||
var currentSeparator = '';
|
||||
if (!segment && s > 0) {
|
||||
continue;
|
||||
}
|
||||
if (separator) {
|
||||
if (s === segments.length - 1) {
|
||||
currentSeparator = optionalSeparator;
|
||||
}
|
||||
else if (nextSegment !== '**') {
|
||||
currentSeparator = requiredSeparator;
|
||||
}
|
||||
else {
|
||||
currentSeparator = '';
|
||||
}
|
||||
}
|
||||
if (separator && segment === '**') {
|
||||
if (currentSeparator) {
|
||||
result +=
|
||||
s === 0
|
||||
? ''
|
||||
: s === segments.length - 1
|
||||
? "(?:".concat(requiredSeparator, "|$)")
|
||||
: requiredSeparator;
|
||||
result += "(?:".concat(wildcard, "*?").concat(currentSeparator, ")*?");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (var c = 0; c < segment.length; c++) {
|
||||
var char = segment[c];
|
||||
if (char === '\\') {
|
||||
if (c < segment.length - 1) {
|
||||
result += escapeRegExpChar(segment[c + 1]);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
else if (char === '?') {
|
||||
result += wildcard;
|
||||
}
|
||||
else if (char === '*') {
|
||||
result += "".concat(wildcard, "*?");
|
||||
}
|
||||
else {
|
||||
result += escapeRegExpChar(char);
|
||||
}
|
||||
}
|
||||
result += currentSeparator;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isMatch(regexp, sample) {
|
||||
if (typeof sample !== 'string') {
|
||||
throw new TypeError("Sample must be a string, but ".concat(typeof sample, " given"));
|
||||
}
|
||||
return regexp.test(sample);
|
||||
}
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
function wildcardMatch(pattern, options) {
|
||||
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
|
||||
throw new TypeError("The first argument must be a single pattern string or an array of patterns, but ".concat(typeof pattern, " given"));
|
||||
}
|
||||
if (typeof options === 'string' || typeof options === 'boolean') {
|
||||
options = { separator: options };
|
||||
}
|
||||
if (arguments.length === 2 &&
|
||||
!(typeof options === 'undefined' ||
|
||||
(typeof options === 'object' && options !== null && !Array.isArray(options)))) {
|
||||
throw new TypeError("The second argument must be an options object or a string/boolean separator, but ".concat(typeof options, " given"));
|
||||
}
|
||||
options = options || {};
|
||||
if (options.separator === '\\') {
|
||||
throw new Error('\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead');
|
||||
}
|
||||
var regexpPattern = transform(pattern, options.separator);
|
||||
var regexp = new RegExp("^".concat(regexpPattern, "$"), options.flags);
|
||||
var fn = isMatch.bind(null, regexp);
|
||||
fn.options = options;
|
||||
fn.pattern = pattern;
|
||||
fn.regexp = regexp;
|
||||
return fn;
|
||||
}
|
||||
|
||||
module.exports = wildcardMatch;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/wildcard-match/build/index.js.map
generated
vendored
Normal file
1
node_modules/wildcard-match/build/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
40
node_modules/wildcard-match/build/index.umd.d.ts
generated
vendored
Normal file
40
node_modules/wildcard-match/build/index.umd.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
interface WildcardMatchOptions {
|
||||
/** Separator to be used to split patterns and samples into segments */
|
||||
separator?: string | boolean;
|
||||
/** Flags to pass to the RegExp */
|
||||
flags?: string;
|
||||
}
|
||||
interface isMatch {
|
||||
/**
|
||||
* Tests if a sample string matches the pattern(s)
|
||||
*
|
||||
* ```js
|
||||
* isMatch('foo') //=> true
|
||||
* ```
|
||||
*/
|
||||
(sample: string): boolean;
|
||||
/** Compiled regular expression */
|
||||
regexp: RegExp;
|
||||
/** Original pattern or array of patterns that was used to compile the RegExp */
|
||||
pattern: string | string[];
|
||||
/** Options that were used to compile the RegExp */
|
||||
options: WildcardMatchOptions;
|
||||
}
|
||||
declare function isMatch(regexp: RegExp, sample: string): boolean;
|
||||
/**
|
||||
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
|
||||
* The isMatch function takes a sample string as its only argument and returns `true`
|
||||
* if the string matches the pattern(s).
|
||||
*
|
||||
* ```js
|
||||
* wildcardMatch('src/*.js')('src/index.js') //=> true
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* const isMatch = wildcardMatch('*.example.com', '.')
|
||||
* isMatch('foo.example.com') //=> true
|
||||
* isMatch('foo.bar.com') //=> false
|
||||
* ```
|
||||
*/
|
||||
declare function wildcardMatch(pattern: string | string[], options?: string | boolean | WildcardMatchOptions): isMatch;
|
||||
export = wildcardMatch;
|
||||
2
node_modules/wildcard-match/build/index.umd.js
generated
vendored
Normal file
2
node_modules/wildcard-match/build/index.umd.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).wcmatch=e()}(this,(function(){"use strict";function t(t){return"-"===t||"^"===t||"$"===t||"+"===t||"."===t||"("===t||")"===t||"|"===t||"["===t||"]"===t||"{"===t||"}"===t||"*"===t||"?"===t||"\\"===t?"\\".concat(t):t}function e(n,r){if(void 0===r&&(r=!0),Array.isArray(n)){var o=n.map((function(t){return"^".concat(e(t,r),"$")}));return"(?:".concat(o.join("|"),")")}var a="",i="",c=".";!0===r?(a="/",i="[/\\\\]",c="[^/\\\\]"):r&&(i=function(e){for(var n="",r=0;r<e.length;r++)n+=t(e[r]);return n}(a=r),i.length>1?(i="(?:".concat(i,")"),c="((?!".concat(i,").)")):c="[^".concat(i,"]"));for(var s=r?"".concat(i,"+?"):"",f=r?"".concat(i,"*?"):"",u=r?n.split(a):[n],p="",g=0;g<u.length;g++){var l=u[g],y=u[g+1],h="";if(l||!(g>0))if(r&&(h=g===u.length-1?f:"**"!==y?s:""),r&&"**"===l)h&&(p+=0===g?"":g===u.length-1?"(?:".concat(s,"|$)"):s,p+="(?:".concat(c,"*?").concat(h,")*?"));else{for(var d=0;d<l.length;d++){var b=l[d];"\\"===b?d<l.length-1&&(p+=t(l[d+1]),d++):p+="?"===b?c:"*"===b?"".concat(c,"*?"):t(b)}p+=h}}return p}function n(t,e){if("string"!=typeof e)throw new TypeError("Sample must be a string, but ".concat(typeof e," given"));return t.test(e)}return function(t,r){if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("The first argument must be a single pattern string or an array of patterns, but ".concat(typeof t," given"));if("string"!=typeof r&&"boolean"!=typeof r||(r={separator:r}),2===arguments.length&&void 0!==r&&("object"!=typeof r||null===r||Array.isArray(r)))throw new TypeError("The second argument must be an options object or a string/boolean separator, but ".concat(typeof r," given"));if("\\"===(r=r||{}).separator)throw new Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");var o=e(t,r.separator),a=new RegExp("^".concat(o,"$"),r.flags),i=n.bind(null,a);return i.options=r,i.pattern=t,i.regexp=a,i}}));
|
||||
//# sourceMappingURL=index.umd.js.map
|
||||
1
node_modules/wildcard-match/build/index.umd.js.map
generated
vendored
Normal file
1
node_modules/wildcard-match/build/index.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
64
node_modules/wildcard-match/package.json
generated
vendored
Normal file
64
node_modules/wildcard-match/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "wildcard-match",
|
||||
"version": "5.1.4",
|
||||
"description": "A tiny and extremely fast library for compiling and matching basic glob patterns",
|
||||
"author": "Alex Schneider <me@schneider.ax>",
|
||||
"license": "ISC",
|
||||
"repository": "https://github.com/axtgr/wildcard-match",
|
||||
"keywords": [
|
||||
"glob",
|
||||
"pattern",
|
||||
"wildcard",
|
||||
"match",
|
||||
"regexp"
|
||||
],
|
||||
"packageManager": "yarn@1.22.22",
|
||||
"type": "commonjs",
|
||||
"main": "build/index.js",
|
||||
"module": "build/index.es.mjs",
|
||||
"unpkg": "build/index.umd.js",
|
||||
"types": "build/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./build/index.es.mjs",
|
||||
"require": "./build/index.js",
|
||||
"types": "./build/index.d.ts"
|
||||
},
|
||||
"files": [
|
||||
"build"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"bench": "node bench/bench",
|
||||
"lint": "eslint {src,test,bench}/*",
|
||||
"format": "eslint --cache --fix {src,test,bench}/* && prettier --write **/*.md",
|
||||
"test": "ts-node -T -r \"core-js/modules/es.symbol.async-iterator\" -I \" \" node_modules/pta/src/cli.js test/[!_]*.mjs"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run format"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"core-js": "^3.36.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.10.0",
|
||||
"eslint-plugin-prettier": "^3.4.1",
|
||||
"globrex": "^0.1.2",
|
||||
"husky": "^4.3.8",
|
||||
"matcher": "^4.0.0",
|
||||
"picomatch": "^4.0.2",
|
||||
"prettier": "^2.8.8",
|
||||
"pta": "^0.2.3",
|
||||
"rollup": "^2.79.2",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-delete": "^2.0.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-ts": "2.0.4",
|
||||
"ts-node": "^9.1.1",
|
||||
"ts-transform-default-export": "^1.0.3",
|
||||
"typescript": "~4.7.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user