minimatch-fast 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +950 -0
- package/dist/cjs/brace-expand.d.ts +42 -0
- package/dist/cjs/brace-expand.d.ts.map +1 -0
- package/dist/cjs/brace-expand.js +172 -0
- package/dist/cjs/brace-expand.js.map +1 -0
- package/dist/cjs/cache.d.ts +36 -0
- package/dist/cjs/cache.d.ts.map +1 -0
- package/dist/cjs/cache.js +91 -0
- package/dist/cjs/cache.js.map +1 -0
- package/dist/cjs/escape.d.ts +40 -0
- package/dist/cjs/escape.d.ts.map +1 -0
- package/dist/cjs/escape.js +52 -0
- package/dist/cjs/escape.js.map +1 -0
- package/dist/cjs/fast-paths.d.ts +54 -0
- package/dist/cjs/fast-paths.d.ts.map +1 -0
- package/dist/cjs/fast-paths.js +213 -0
- package/dist/cjs/fast-paths.js.map +1 -0
- package/dist/cjs/index.d.ts +150 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +250 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/minimatch-class.d.ts +153 -0
- package/dist/cjs/minimatch-class.d.ts.map +1 -0
- package/dist/cjs/minimatch-class.js +618 -0
- package/dist/cjs/minimatch-class.js.map +1 -0
- package/dist/cjs/options.d.ts +31 -0
- package/dist/cjs/options.d.ts.map +1 -0
- package/dist/cjs/options.js +67 -0
- package/dist/cjs/options.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types.d.ts +194 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +19 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/unescape.d.ts +36 -0
- package/dist/cjs/unescape.d.ts.map +1 -0
- package/dist/cjs/unescape.js +49 -0
- package/dist/cjs/unescape.js.map +1 -0
- package/dist/cjs/utils.d.ts +62 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +126 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/brace-expand.d.ts +42 -0
- package/dist/esm/brace-expand.d.ts.map +1 -0
- package/dist/esm/brace-expand.js +165 -0
- package/dist/esm/brace-expand.js.map +1 -0
- package/dist/esm/cache.d.ts +36 -0
- package/dist/esm/cache.d.ts.map +1 -0
- package/dist/esm/cache.js +86 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/esm/escape.d.ts +40 -0
- package/dist/esm/escape.d.ts.map +1 -0
- package/dist/esm/escape.js +49 -0
- package/dist/esm/escape.js.map +1 -0
- package/dist/esm/fast-paths.d.ts +54 -0
- package/dist/esm/fast-paths.d.ts.map +1 -0
- package/dist/esm/fast-paths.js +209 -0
- package/dist/esm/fast-paths.js.map +1 -0
- package/dist/esm/index.d.ts +150 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +240 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/minimatch-class.d.ts +153 -0
- package/dist/esm/minimatch-class.d.ts.map +1 -0
- package/dist/esm/minimatch-class.js +611 -0
- package/dist/esm/minimatch-class.js.map +1 -0
- package/dist/esm/options.d.ts +31 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +63 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/types.d.ts +194 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +16 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/unescape.d.ts +36 -0
- package/dist/esm/unescape.d.ts.map +1 -0
- package/dist/esm/unescape.js +46 -0
- package/dist/esm/unescape.js.map +1 -0
- package/dist/esm/utils.d.ts +62 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +116 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Fast path handlers for common glob patterns
|
|
4
|
+
*
|
|
5
|
+
* This module provides optimized matching for the most common glob patterns,
|
|
6
|
+
* avoiding the overhead of full regex compilation. These fast paths use
|
|
7
|
+
* simple string operations like startsWith(), endsWith(), and includes()
|
|
8
|
+
* which are significantly faster than regex matching.
|
|
9
|
+
*
|
|
10
|
+
* Supported fast path patterns:
|
|
11
|
+
* - `*` - Match any single path segment (except dotfiles by default)
|
|
12
|
+
* - `*.ext` - Match files with specific extension (e.g., `*.js`, `*.ts`)
|
|
13
|
+
* - `*.*` - Match files with any extension
|
|
14
|
+
* - `.*` - Match hidden files (dotfiles)
|
|
15
|
+
* - `???` - Match files with exact length (question mark patterns)
|
|
16
|
+
*
|
|
17
|
+
* When a pattern doesn't match any fast path, null is returned and the
|
|
18
|
+
* caller should fall back to full pattern matching.
|
|
19
|
+
*
|
|
20
|
+
* @author 686f6c61
|
|
21
|
+
* @see https://github.com/686f6c61/minimatch-fast
|
|
22
|
+
* @license MIT
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.tryFastPath = tryFastPath;
|
|
26
|
+
exports.mightUseFastPath = mightUseFastPath;
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// PATTERN DETECTION REGEXES
|
|
29
|
+
// These regexes detect which fast path to use. They are compiled once at
|
|
30
|
+
// module load time and reused for all pattern checks.
|
|
31
|
+
// ============================================================================
|
|
32
|
+
/**
|
|
33
|
+
* Matches pure star patterns: *, **, ***
|
|
34
|
+
* Used for "match anything" patterns.
|
|
35
|
+
*/
|
|
36
|
+
const STAR_RE = /^\*+$/;
|
|
37
|
+
/**
|
|
38
|
+
* Matches star-dot-extension patterns: *.js, *.ts, *.txt
|
|
39
|
+
* Captures the extension (including the dot).
|
|
40
|
+
* Excludes patterns with special glob characters in the extension.
|
|
41
|
+
*/
|
|
42
|
+
const STAR_DOT_EXT_RE = /^\*+(\.[^+@!?\*\[\(]+)$/;
|
|
43
|
+
/**
|
|
44
|
+
* Matches star-dot-star patterns: *.*, **.*
|
|
45
|
+
* Used for "any file with an extension" matching.
|
|
46
|
+
*/
|
|
47
|
+
const STAR_DOT_STAR_RE = /^\*+\.\*+$/;
|
|
48
|
+
/**
|
|
49
|
+
* Matches dot-star patterns: .*, .**
|
|
50
|
+
* Used for dotfile/hidden file matching.
|
|
51
|
+
*/
|
|
52
|
+
const DOT_STAR_RE = /^\.\*+$/;
|
|
53
|
+
/**
|
|
54
|
+
* Matches question mark patterns: ?, ??, ???, ???.js
|
|
55
|
+
* Captures optional extension after the question marks.
|
|
56
|
+
* Used for exact-length matching.
|
|
57
|
+
*/
|
|
58
|
+
const QMARKS_RE = /^(\?+)(\.[^+@!?\*\[\(]+)?$/;
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// FAST PATH IMPLEMENTATION
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Try to match a path against a pattern using a fast path.
|
|
64
|
+
*
|
|
65
|
+
* This function attempts to use optimized string operations for common
|
|
66
|
+
* glob patterns instead of full regex compilation. If the pattern is not
|
|
67
|
+
* a simple pattern that can be handled by a fast path, null is returned.
|
|
68
|
+
*
|
|
69
|
+
* @param path - The path to match (should be a filename without directory)
|
|
70
|
+
* @param pattern - The glob pattern to match against
|
|
71
|
+
* @param options - Minimatch options (dot, nocase are relevant)
|
|
72
|
+
* @returns true if matches, false if doesn't match, null if no fast path available
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* tryFastPath('foo.js', '*.js', {}); // true
|
|
77
|
+
* tryFastPath('foo.txt', '*.js', {}); // false
|
|
78
|
+
* tryFastPath('.hidden', '*', {}); // false
|
|
79
|
+
* tryFastPath('.hidden', '*', { dot: true }); // true
|
|
80
|
+
* tryFastPath('foo.js', '**\/*.js', {}); // null (has /, need full matching)
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
function tryFastPath(path, pattern, options) {
|
|
84
|
+
// Skip if path contains / (need full path matching)
|
|
85
|
+
if (path.includes('/'))
|
|
86
|
+
return null;
|
|
87
|
+
// Skip if pattern has path separators (need full matching)
|
|
88
|
+
if (pattern.includes('/'))
|
|
89
|
+
return null;
|
|
90
|
+
// Skip if negated (need full matching for proper negation handling)
|
|
91
|
+
if (!options.nonegate && pattern.startsWith('!'))
|
|
92
|
+
return null;
|
|
93
|
+
// Skip if pattern has braces (need brace expansion)
|
|
94
|
+
if (!options.nobrace && pattern.includes('{'))
|
|
95
|
+
return null;
|
|
96
|
+
// Skip if pattern has extglob (need extglob handling)
|
|
97
|
+
if (!options.noext && /[@!?+*]\(/.test(pattern))
|
|
98
|
+
return null;
|
|
99
|
+
// Skip if pattern has character class (need regex)
|
|
100
|
+
if (pattern.includes('['))
|
|
101
|
+
return null;
|
|
102
|
+
const dot = options.dot ?? false;
|
|
103
|
+
const nocase = options.nocase ?? false;
|
|
104
|
+
let m;
|
|
105
|
+
// -------------------------------------------------------------------------
|
|
106
|
+
// Fast path: * (pure star)
|
|
107
|
+
// Matches any non-empty filename, respecting dot option
|
|
108
|
+
// -------------------------------------------------------------------------
|
|
109
|
+
if ((m = pattern.match(STAR_RE))) {
|
|
110
|
+
if (path.length === 0)
|
|
111
|
+
return false;
|
|
112
|
+
if (dot) {
|
|
113
|
+
// With dot option, match anything except . and ..
|
|
114
|
+
return path !== '.' && path !== '..';
|
|
115
|
+
}
|
|
116
|
+
// Without dot option, don't match dotfiles
|
|
117
|
+
return !path.startsWith('.');
|
|
118
|
+
}
|
|
119
|
+
// -------------------------------------------------------------------------
|
|
120
|
+
// Fast path: *.ext (star-dot-extension)
|
|
121
|
+
// Matches files ending with specific extension
|
|
122
|
+
// -------------------------------------------------------------------------
|
|
123
|
+
if ((m = pattern.match(STAR_DOT_EXT_RE))) {
|
|
124
|
+
const ext = m[1]; // Includes the dot, e.g., ".js"
|
|
125
|
+
if (path.length === 0)
|
|
126
|
+
return false;
|
|
127
|
+
if (nocase) {
|
|
128
|
+
const lpath = path.toLowerCase();
|
|
129
|
+
const lext = ext.toLowerCase();
|
|
130
|
+
if (dot)
|
|
131
|
+
return lpath.endsWith(lext);
|
|
132
|
+
return !path.startsWith('.') && lpath.endsWith(lext);
|
|
133
|
+
}
|
|
134
|
+
if (dot)
|
|
135
|
+
return path.endsWith(ext);
|
|
136
|
+
return !path.startsWith('.') && path.endsWith(ext);
|
|
137
|
+
}
|
|
138
|
+
// -------------------------------------------------------------------------
|
|
139
|
+
// Fast path: *.* (star-dot-star)
|
|
140
|
+
// Matches any file with an extension (contains a dot)
|
|
141
|
+
// -------------------------------------------------------------------------
|
|
142
|
+
if ((m = pattern.match(STAR_DOT_STAR_RE))) {
|
|
143
|
+
if (path.length === 0)
|
|
144
|
+
return false;
|
|
145
|
+
if (dot) {
|
|
146
|
+
// With dot, match anything with a dot except . and ..
|
|
147
|
+
return path !== '.' && path !== '..' && path.includes('.');
|
|
148
|
+
}
|
|
149
|
+
// Without dot, must have extension and not be a dotfile
|
|
150
|
+
return !path.startsWith('.') && path.includes('.');
|
|
151
|
+
}
|
|
152
|
+
// -------------------------------------------------------------------------
|
|
153
|
+
// Fast path: .* (dot-star)
|
|
154
|
+
// Matches hidden files (starting with dot)
|
|
155
|
+
// -------------------------------------------------------------------------
|
|
156
|
+
if ((m = pattern.match(DOT_STAR_RE))) {
|
|
157
|
+
// Must start with dot but not be . or ..
|
|
158
|
+
return path.startsWith('.') && path !== '.' && path !== '..';
|
|
159
|
+
}
|
|
160
|
+
// -------------------------------------------------------------------------
|
|
161
|
+
// Fast path: ??? (question marks with optional extension)
|
|
162
|
+
// Matches files with exact length
|
|
163
|
+
// -------------------------------------------------------------------------
|
|
164
|
+
if ((m = pattern.match(QMARKS_RE))) {
|
|
165
|
+
const qmarks = m[1]; // The question marks, e.g., "???"
|
|
166
|
+
const ext = m[2] ?? ''; // Optional extension, e.g., ".js"
|
|
167
|
+
const qLen = qmarks.length;
|
|
168
|
+
const expectedLen = qLen + ext.length;
|
|
169
|
+
if (path.length !== expectedLen)
|
|
170
|
+
return false;
|
|
171
|
+
// Never match . or .. (special directories)
|
|
172
|
+
if (path === '.' || path === '..')
|
|
173
|
+
return false;
|
|
174
|
+
if (ext) {
|
|
175
|
+
// Has extension - check length and extension match
|
|
176
|
+
if (nocase) {
|
|
177
|
+
const lpath = path.toLowerCase();
|
|
178
|
+
const lext = ext.toLowerCase();
|
|
179
|
+
if (!lpath.endsWith(lext))
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
if (!path.endsWith(ext))
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Check dotfile restriction
|
|
188
|
+
if (!dot && path.startsWith('.'))
|
|
189
|
+
return false;
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
// No fast path available
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Check if a pattern might be eligible for fast path.
|
|
197
|
+
* This is a quick pre-check to avoid expensive regex tests.
|
|
198
|
+
*
|
|
199
|
+
* @param pattern - The glob pattern
|
|
200
|
+
* @returns true if pattern might use fast path
|
|
201
|
+
*/
|
|
202
|
+
function mightUseFastPath(pattern) {
|
|
203
|
+
// Fast paths only work for simple patterns without:
|
|
204
|
+
// - Path separators
|
|
205
|
+
// - Braces
|
|
206
|
+
// - Character classes
|
|
207
|
+
// - Extglob patterns
|
|
208
|
+
return (!pattern.includes('/') &&
|
|
209
|
+
!pattern.includes('{') &&
|
|
210
|
+
!pattern.includes('[') &&
|
|
211
|
+
!/[@!?+*]\(/.test(pattern));
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=fast-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-paths.js","sourceRoot":"","sources":["../../src/fast-paths.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;AAmEH,kCAuHC;AASD,4CAYC;AA3MD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,CAAC;QAE9C,4CAA4C;QAC5C,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAEhD,IAAI,GAAG,EAAE,CAAC;YACR,mDAAmD;YACnD,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;gBAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAO,KAAK,CAAC;YAC1C,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAAE,OAAO,KAAK,CAAC;YACxC,CAAC;QACH,CAAC;QAED,4BAA4B;QAC5B,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAE/C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yBAAyB;IACzB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,oDAAoD;IACpD,oBAAoB;IACpB,WAAW;IACX,sBAAsB;IACtB,qBAAqB;IACrB,OAAO,CACL,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview minimatch-fast - Drop-in replacement for minimatch
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the minimatch-fast package. It provides
|
|
5
|
+
* a 100% API-compatible replacement for minimatch while using picomatch
|
|
6
|
+
* internally for better performance and security.
|
|
7
|
+
*
|
|
8
|
+
* The package exports:
|
|
9
|
+
* - minimatch(): Main function for testing if a path matches a pattern
|
|
10
|
+
* - minimatch.match(): Filter an array of paths
|
|
11
|
+
* - minimatch.filter(): Create a filter function for Array.filter()
|
|
12
|
+
* - minimatch.makeRe(): Convert a pattern to a RegExp
|
|
13
|
+
* - minimatch.braceExpand(): Expand brace patterns
|
|
14
|
+
* - minimatch.escape(): Escape glob special characters
|
|
15
|
+
* - minimatch.unescape(): Unescape glob special characters
|
|
16
|
+
* - minimatch.defaults(): Create a new minimatch with default options
|
|
17
|
+
* - Minimatch: Class for repeated matching against the same pattern
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import minimatch from 'minimatch-fast';
|
|
22
|
+
*
|
|
23
|
+
* // Basic matching
|
|
24
|
+
* minimatch('bar.js', '*.js'); // true
|
|
25
|
+
* minimatch('src/deep/file.ts', '**\/*.ts'); // true
|
|
26
|
+
*
|
|
27
|
+
* // Filter an array
|
|
28
|
+
* minimatch.match(['a.js', 'b.txt'], '*.js'); // ['a.js']
|
|
29
|
+
*
|
|
30
|
+
* // Create filter function
|
|
31
|
+
* const jsFiles = files.filter(minimatch.filter('*.js'));
|
|
32
|
+
*
|
|
33
|
+
* // Use Minimatch class for repeated matching (more efficient)
|
|
34
|
+
* const mm = new minimatch.Minimatch('**\/*.js');
|
|
35
|
+
* mm.match('src/index.js'); // true
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @author 686f6c61
|
|
39
|
+
* @see https://github.com/686f6c61/minimatch-fast
|
|
40
|
+
* @license MIT
|
|
41
|
+
*/
|
|
42
|
+
import type { MinimatchOptions, MMRegExp, Platform, Sep, ParseReturn, ParseReturnFiltered, GlobstarSymbol } from './types.js';
|
|
43
|
+
import { GLOBSTAR } from './types.js';
|
|
44
|
+
import { Minimatch } from './minimatch-class.js';
|
|
45
|
+
export type { MinimatchOptions, MMRegExp, Platform, Sep, ParseReturn, ParseReturnFiltered, GlobstarSymbol, };
|
|
46
|
+
export { Minimatch, GLOBSTAR };
|
|
47
|
+
export { escape } from './escape.js';
|
|
48
|
+
export { unescape } from './unescape.js';
|
|
49
|
+
/**
|
|
50
|
+
* Path separator for the current platform
|
|
51
|
+
*/
|
|
52
|
+
export declare const sep: Sep;
|
|
53
|
+
/**
|
|
54
|
+
* Test if a path matches a glob pattern
|
|
55
|
+
*
|
|
56
|
+
* This function is optimized with:
|
|
57
|
+
* 1. Fast paths for common simple patterns (*.js, *, ???)
|
|
58
|
+
* 2. LRU cache for compiled Minimatch instances
|
|
59
|
+
*
|
|
60
|
+
* @param path - The path to test
|
|
61
|
+
* @param pattern - The glob pattern
|
|
62
|
+
* @param options - Matching options
|
|
63
|
+
* @returns true if the path matches the pattern
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* minimatch('foo.js', '*.js'); // true
|
|
68
|
+
* minimatch('src/foo.js', '**\/*.js'); // true
|
|
69
|
+
* minimatch('.hidden', '*'); // false
|
|
70
|
+
* minimatch('.hidden', '*', { dot: true }); // true
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function minimatch(path: string, pattern: string, options?: MinimatchOptions): boolean;
|
|
74
|
+
export declare namespace minimatch {
|
|
75
|
+
var sep: Sep;
|
|
76
|
+
var GLOBSTAR: typeof import("./types.js").GLOBSTAR;
|
|
77
|
+
var Minimatch: typeof import("./minimatch-class.js").Minimatch;
|
|
78
|
+
var filter: typeof import("./index.js").filter;
|
|
79
|
+
var defaults: typeof import("./index.js").defaults;
|
|
80
|
+
var braceExpand: (pattern: string, options?: MinimatchOptions) => string[];
|
|
81
|
+
var makeRe: typeof import("./index.js").makeRe;
|
|
82
|
+
var match: typeof import("./index.js").match;
|
|
83
|
+
var escape: typeof import("./escape.js").escape;
|
|
84
|
+
var unescape: typeof import("./unescape.js").unescape;
|
|
85
|
+
var clearCache: typeof import("./cache.js").clearCache;
|
|
86
|
+
var getCacheSize: typeof import("./cache.js").getCacheSize;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a filter function for use with Array.filter()
|
|
90
|
+
*
|
|
91
|
+
* Uses cached Minimatch instance for better performance.
|
|
92
|
+
*
|
|
93
|
+
* @param pattern - The glob pattern
|
|
94
|
+
* @param options - Matching options
|
|
95
|
+
* @returns A function that tests paths against the pattern
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const jsFilter = minimatch.filter('*.js');
|
|
100
|
+
* ['a.js', 'b.txt', 'c.js'].filter(jsFilter); // ['a.js', 'c.js']
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function filter(pattern: string, options?: MinimatchOptions): (path: string) => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Create a minimatch function with default options
|
|
106
|
+
*
|
|
107
|
+
* @param def - Default options to apply to all calls
|
|
108
|
+
* @returns A new minimatch function with defaults applied
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const mm = minimatch.defaults({ dot: true });
|
|
113
|
+
* mm('.hidden', '*'); // true (dot files included)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function defaults(def: MinimatchOptions): typeof minimatch;
|
|
117
|
+
/**
|
|
118
|
+
* Convert a glob pattern to a regular expression
|
|
119
|
+
*
|
|
120
|
+
* Uses cached Minimatch instance for better performance.
|
|
121
|
+
*
|
|
122
|
+
* @param pattern - The glob pattern
|
|
123
|
+
* @param options - Matching options
|
|
124
|
+
* @returns RegExp or false if pattern is invalid
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const re = minimatch.makeRe('*.js');
|
|
129
|
+
* re.test('foo.js'); // true
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare function makeRe(pattern: string, options?: MinimatchOptions): false | MMRegExp;
|
|
133
|
+
/**
|
|
134
|
+
* Match a list of paths against a glob pattern
|
|
135
|
+
*
|
|
136
|
+
* Uses cached Minimatch instance for better performance.
|
|
137
|
+
*
|
|
138
|
+
* @param list - Array of paths to filter
|
|
139
|
+
* @param pattern - The glob pattern
|
|
140
|
+
* @param options - Matching options
|
|
141
|
+
* @returns Array of matching paths
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* minimatch.match(['a.js', 'b.txt', 'c.js'], '*.js'); // ['a.js', 'c.js']
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function match(list: string[], pattern: string, options?: MinimatchOptions): string[];
|
|
149
|
+
export default minimatch;
|
|
150
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,WAAW,EACX,mBAAmB,EACnB,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AASjD,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,WAAW,EACX,mBAAmB,EACnB,cAAc,GACf,CAAC;AAGF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,GAAG,EAAE,GAAa,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CA2BT;yBA/Be,SAAS;;;;;;+BA6Hd,MAAM,YACN,gBAAgB,KACxB,MAAM,EAAE;;;;;;;;AAzFX;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAI3B;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,SAAS,CAgChE;AAwBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,KAAK,GAAG,QAAQ,CAElB;AAGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,MAAM,EAAE,CAUV;AA0BD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview minimatch-fast - Drop-in replacement for minimatch
|
|
4
|
+
*
|
|
5
|
+
* This is the main entry point for the minimatch-fast package. It provides
|
|
6
|
+
* a 100% API-compatible replacement for minimatch while using picomatch
|
|
7
|
+
* internally for better performance and security.
|
|
8
|
+
*
|
|
9
|
+
* The package exports:
|
|
10
|
+
* - minimatch(): Main function for testing if a path matches a pattern
|
|
11
|
+
* - minimatch.match(): Filter an array of paths
|
|
12
|
+
* - minimatch.filter(): Create a filter function for Array.filter()
|
|
13
|
+
* - minimatch.makeRe(): Convert a pattern to a RegExp
|
|
14
|
+
* - minimatch.braceExpand(): Expand brace patterns
|
|
15
|
+
* - minimatch.escape(): Escape glob special characters
|
|
16
|
+
* - minimatch.unescape(): Unescape glob special characters
|
|
17
|
+
* - minimatch.defaults(): Create a new minimatch with default options
|
|
18
|
+
* - Minimatch: Class for repeated matching against the same pattern
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import minimatch from 'minimatch-fast';
|
|
23
|
+
*
|
|
24
|
+
* // Basic matching
|
|
25
|
+
* minimatch('bar.js', '*.js'); // true
|
|
26
|
+
* minimatch('src/deep/file.ts', '**\/*.ts'); // true
|
|
27
|
+
*
|
|
28
|
+
* // Filter an array
|
|
29
|
+
* minimatch.match(['a.js', 'b.txt'], '*.js'); // ['a.js']
|
|
30
|
+
*
|
|
31
|
+
* // Create filter function
|
|
32
|
+
* const jsFiles = files.filter(minimatch.filter('*.js'));
|
|
33
|
+
*
|
|
34
|
+
* // Use Minimatch class for repeated matching (more efficient)
|
|
35
|
+
* const mm = new minimatch.Minimatch('**\/*.js');
|
|
36
|
+
* mm.match('src/index.js'); // true
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @author 686f6c61
|
|
40
|
+
* @see https://github.com/686f6c61/minimatch-fast
|
|
41
|
+
* @license MIT
|
|
42
|
+
*/
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.sep = exports.unescape = exports.escape = exports.GLOBSTAR = exports.Minimatch = void 0;
|
|
45
|
+
exports.minimatch = minimatch;
|
|
46
|
+
exports.filter = filter;
|
|
47
|
+
exports.defaults = defaults;
|
|
48
|
+
exports.makeRe = makeRe;
|
|
49
|
+
exports.match = match;
|
|
50
|
+
const types_js_1 = require("./types.js");
|
|
51
|
+
Object.defineProperty(exports, "GLOBSTAR", { enumerable: true, get: function () { return types_js_1.GLOBSTAR; } });
|
|
52
|
+
const minimatch_class_js_1 = require("./minimatch-class.js");
|
|
53
|
+
Object.defineProperty(exports, "Minimatch", { enumerable: true, get: function () { return minimatch_class_js_1.Minimatch; } });
|
|
54
|
+
const brace_expand_js_1 = require("./brace-expand.js");
|
|
55
|
+
const escape_js_1 = require("./escape.js");
|
|
56
|
+
const unescape_js_1 = require("./unescape.js");
|
|
57
|
+
const utils_js_1 = require("./utils.js");
|
|
58
|
+
const cache_js_1 = require("./cache.js");
|
|
59
|
+
const fast_paths_js_1 = require("./fast-paths.js");
|
|
60
|
+
var escape_js_2 = require("./escape.js");
|
|
61
|
+
Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return escape_js_2.escape; } });
|
|
62
|
+
var unescape_js_2 = require("./unescape.js");
|
|
63
|
+
Object.defineProperty(exports, "unescape", { enumerable: true, get: function () { return unescape_js_2.unescape; } });
|
|
64
|
+
/**
|
|
65
|
+
* Path separator for the current platform
|
|
66
|
+
*/
|
|
67
|
+
exports.sep = utils_js_1.sep;
|
|
68
|
+
/**
|
|
69
|
+
* Test if a path matches a glob pattern
|
|
70
|
+
*
|
|
71
|
+
* This function is optimized with:
|
|
72
|
+
* 1. Fast paths for common simple patterns (*.js, *, ???)
|
|
73
|
+
* 2. LRU cache for compiled Minimatch instances
|
|
74
|
+
*
|
|
75
|
+
* @param path - The path to test
|
|
76
|
+
* @param pattern - The glob pattern
|
|
77
|
+
* @param options - Matching options
|
|
78
|
+
* @returns true if the path matches the pattern
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* minimatch('foo.js', '*.js'); // true
|
|
83
|
+
* minimatch('src/foo.js', '**\/*.js'); // true
|
|
84
|
+
* minimatch('.hidden', '*'); // false
|
|
85
|
+
* minimatch('.hidden', '*', { dot: true }); // true
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
function minimatch(path, pattern, options = {}) {
|
|
89
|
+
// Validate pattern type
|
|
90
|
+
if (typeof pattern !== 'string') {
|
|
91
|
+
throw new TypeError('glob pattern must be a string');
|
|
92
|
+
}
|
|
93
|
+
// Handle empty pattern
|
|
94
|
+
if (pattern === '') {
|
|
95
|
+
return path === '';
|
|
96
|
+
}
|
|
97
|
+
// Handle comments
|
|
98
|
+
if (!options.nocomment && pattern.charAt(0) === '#') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
// Try fast path for simple patterns (no path separators, no complex features)
|
|
102
|
+
// Fast paths avoid creating Minimatch instance entirely
|
|
103
|
+
if (!options.matchBase && (0, fast_paths_js_1.mightUseFastPath)(pattern)) {
|
|
104
|
+
const fastResult = (0, fast_paths_js_1.tryFastPath)(path, pattern, options);
|
|
105
|
+
if (fastResult !== null) {
|
|
106
|
+
return fastResult;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Use cached Minimatch instance for full matching
|
|
110
|
+
return (0, cache_js_1.getOrCreateMatcher)(pattern, options).match(path);
|
|
111
|
+
}
|
|
112
|
+
// Attach static properties to minimatch function
|
|
113
|
+
minimatch.sep = exports.sep;
|
|
114
|
+
minimatch.GLOBSTAR = types_js_1.GLOBSTAR;
|
|
115
|
+
minimatch.Minimatch = minimatch_class_js_1.Minimatch;
|
|
116
|
+
/**
|
|
117
|
+
* Create a filter function for use with Array.filter()
|
|
118
|
+
*
|
|
119
|
+
* Uses cached Minimatch instance for better performance.
|
|
120
|
+
*
|
|
121
|
+
* @param pattern - The glob pattern
|
|
122
|
+
* @param options - Matching options
|
|
123
|
+
* @returns A function that tests paths against the pattern
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const jsFilter = minimatch.filter('*.js');
|
|
128
|
+
* ['a.js', 'b.txt', 'c.js'].filter(jsFilter); // ['a.js', 'c.js']
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
function filter(pattern, options = {}) {
|
|
132
|
+
// Use cached matcher for repeated matching
|
|
133
|
+
const mm = (0, cache_js_1.getOrCreateMatcher)(pattern, options);
|
|
134
|
+
return (path) => mm.match(path);
|
|
135
|
+
}
|
|
136
|
+
minimatch.filter = filter;
|
|
137
|
+
/**
|
|
138
|
+
* Create a minimatch function with default options
|
|
139
|
+
*
|
|
140
|
+
* @param def - Default options to apply to all calls
|
|
141
|
+
* @returns A new minimatch function with defaults applied
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const mm = minimatch.defaults({ dot: true });
|
|
146
|
+
* mm('.hidden', '*'); // true (dot files included)
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function defaults(def) {
|
|
150
|
+
if (!def || typeof def !== 'object' || !Object.keys(def).length) {
|
|
151
|
+
return minimatch;
|
|
152
|
+
}
|
|
153
|
+
const orig = minimatch;
|
|
154
|
+
const m = (path, pattern, options = {}) => orig(path, pattern, { ...def, ...options });
|
|
155
|
+
return Object.assign(m, {
|
|
156
|
+
Minimatch: minimatch_class_js_1.Minimatch.defaults(def),
|
|
157
|
+
filter: (pattern, options = {}) => orig.filter(pattern, { ...def, ...options }),
|
|
158
|
+
defaults: (options) => orig.defaults({ ...def, ...options }),
|
|
159
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, { ...def, ...options }),
|
|
160
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, { ...def, ...options }),
|
|
161
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, { ...def, ...options }),
|
|
162
|
+
escape: (s, options = {}) => (0, escape_js_1.escape)(s, { ...def, ...options }),
|
|
163
|
+
unescape: (s, options = {}) => (0, unescape_js_1.unescape)(s, { ...def, ...options }),
|
|
164
|
+
sep: orig.sep,
|
|
165
|
+
GLOBSTAR: types_js_1.GLOBSTAR,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
minimatch.defaults = defaults;
|
|
169
|
+
/**
|
|
170
|
+
* Expand brace patterns like {a,b,c} and {1..3}
|
|
171
|
+
*
|
|
172
|
+
* @param pattern - The pattern to expand
|
|
173
|
+
* @param options - Expansion options
|
|
174
|
+
* @returns Array of expanded patterns
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* minimatch.braceExpand('{a,b,c}'); // ['a', 'b', 'c']
|
|
179
|
+
* minimatch.braceExpand('{1..3}'); // ['1', '2', '3']
|
|
180
|
+
* minimatch.braceExpand('file.{js,ts}'); // ['file.js', 'file.ts']
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
minimatch.braceExpand = function (pattern, options = {}) {
|
|
184
|
+
return (0, brace_expand_js_1.braceExpand)(pattern, options);
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Convert a glob pattern to a regular expression
|
|
188
|
+
*
|
|
189
|
+
* Uses cached Minimatch instance for better performance.
|
|
190
|
+
*
|
|
191
|
+
* @param pattern - The glob pattern
|
|
192
|
+
* @param options - Matching options
|
|
193
|
+
* @returns RegExp or false if pattern is invalid
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const re = minimatch.makeRe('*.js');
|
|
198
|
+
* re.test('foo.js'); // true
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
function makeRe(pattern, options = {}) {
|
|
202
|
+
return (0, cache_js_1.getOrCreateMatcher)(pattern, options).makeRe();
|
|
203
|
+
}
|
|
204
|
+
minimatch.makeRe = makeRe;
|
|
205
|
+
/**
|
|
206
|
+
* Match a list of paths against a glob pattern
|
|
207
|
+
*
|
|
208
|
+
* Uses cached Minimatch instance for better performance.
|
|
209
|
+
*
|
|
210
|
+
* @param list - Array of paths to filter
|
|
211
|
+
* @param pattern - The glob pattern
|
|
212
|
+
* @param options - Matching options
|
|
213
|
+
* @returns Array of matching paths
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* minimatch.match(['a.js', 'b.txt', 'c.js'], '*.js'); // ['a.js', 'c.js']
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
function match(list, pattern, options = {}) {
|
|
221
|
+
const mm = (0, cache_js_1.getOrCreateMatcher)(pattern, options);
|
|
222
|
+
const result = list.filter((f) => mm.match(f));
|
|
223
|
+
// If nonull option is set and no matches, return the pattern
|
|
224
|
+
if (mm.options.nonull && result.length === 0) {
|
|
225
|
+
return [pattern];
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
minimatch.match = match;
|
|
230
|
+
/**
|
|
231
|
+
* Escape special glob characters in a string
|
|
232
|
+
*/
|
|
233
|
+
minimatch.escape = escape_js_1.escape;
|
|
234
|
+
/**
|
|
235
|
+
* Unescape special glob characters in a string
|
|
236
|
+
*/
|
|
237
|
+
minimatch.unescape = unescape_js_1.unescape;
|
|
238
|
+
/**
|
|
239
|
+
* Clear the pattern cache.
|
|
240
|
+
* Useful for testing or when memory pressure is high.
|
|
241
|
+
*/
|
|
242
|
+
minimatch.clearCache = cache_js_1.clearCache;
|
|
243
|
+
/**
|
|
244
|
+
* Get the current cache size.
|
|
245
|
+
* Useful for monitoring and testing.
|
|
246
|
+
*/
|
|
247
|
+
minimatch.getCacheSize = cache_js_1.getCacheSize;
|
|
248
|
+
// Default export
|
|
249
|
+
exports.default = minimatch;
|
|
250
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AA6DH,8BA+BC;AAsBD,wBAOC;AAeD,4BAgCC;AAuCD,wBAKC;AAkBD,sBAcC;AAzOD,yCAAsC;AAqBlB,yFArBX,mBAAQ,OAqBW;AApB5B,6DAAiD;AAoBxC,0FApBA,8BAAS,OAoBA;AAnBlB,uDAAgD;AAChD,2CAAqC;AACrC,+CAAyC;AACzC,yCAA4C;AAC5C,yCAA0E;AAC1E,mDAAgE;AAehE,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAEjB;;GA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