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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +950 -0
  3. package/dist/cjs/brace-expand.d.ts +42 -0
  4. package/dist/cjs/brace-expand.d.ts.map +1 -0
  5. package/dist/cjs/brace-expand.js +172 -0
  6. package/dist/cjs/brace-expand.js.map +1 -0
  7. package/dist/cjs/cache.d.ts +36 -0
  8. package/dist/cjs/cache.d.ts.map +1 -0
  9. package/dist/cjs/cache.js +91 -0
  10. package/dist/cjs/cache.js.map +1 -0
  11. package/dist/cjs/escape.d.ts +40 -0
  12. package/dist/cjs/escape.d.ts.map +1 -0
  13. package/dist/cjs/escape.js +52 -0
  14. package/dist/cjs/escape.js.map +1 -0
  15. package/dist/cjs/fast-paths.d.ts +54 -0
  16. package/dist/cjs/fast-paths.d.ts.map +1 -0
  17. package/dist/cjs/fast-paths.js +213 -0
  18. package/dist/cjs/fast-paths.js.map +1 -0
  19. package/dist/cjs/index.d.ts +150 -0
  20. package/dist/cjs/index.d.ts.map +1 -0
  21. package/dist/cjs/index.js +250 -0
  22. package/dist/cjs/index.js.map +1 -0
  23. package/dist/cjs/minimatch-class.d.ts +153 -0
  24. package/dist/cjs/minimatch-class.d.ts.map +1 -0
  25. package/dist/cjs/minimatch-class.js +618 -0
  26. package/dist/cjs/minimatch-class.js.map +1 -0
  27. package/dist/cjs/options.d.ts +31 -0
  28. package/dist/cjs/options.d.ts.map +1 -0
  29. package/dist/cjs/options.js +67 -0
  30. package/dist/cjs/options.js.map +1 -0
  31. package/dist/cjs/package.json +3 -0
  32. package/dist/cjs/types.d.ts +194 -0
  33. package/dist/cjs/types.d.ts.map +1 -0
  34. package/dist/cjs/types.js +19 -0
  35. package/dist/cjs/types.js.map +1 -0
  36. package/dist/cjs/unescape.d.ts +36 -0
  37. package/dist/cjs/unescape.d.ts.map +1 -0
  38. package/dist/cjs/unescape.js +49 -0
  39. package/dist/cjs/unescape.js.map +1 -0
  40. package/dist/cjs/utils.d.ts +62 -0
  41. package/dist/cjs/utils.d.ts.map +1 -0
  42. package/dist/cjs/utils.js +126 -0
  43. package/dist/cjs/utils.js.map +1 -0
  44. package/dist/esm/brace-expand.d.ts +42 -0
  45. package/dist/esm/brace-expand.d.ts.map +1 -0
  46. package/dist/esm/brace-expand.js +165 -0
  47. package/dist/esm/brace-expand.js.map +1 -0
  48. package/dist/esm/cache.d.ts +36 -0
  49. package/dist/esm/cache.d.ts.map +1 -0
  50. package/dist/esm/cache.js +86 -0
  51. package/dist/esm/cache.js.map +1 -0
  52. package/dist/esm/escape.d.ts +40 -0
  53. package/dist/esm/escape.d.ts.map +1 -0
  54. package/dist/esm/escape.js +49 -0
  55. package/dist/esm/escape.js.map +1 -0
  56. package/dist/esm/fast-paths.d.ts +54 -0
  57. package/dist/esm/fast-paths.d.ts.map +1 -0
  58. package/dist/esm/fast-paths.js +209 -0
  59. package/dist/esm/fast-paths.js.map +1 -0
  60. package/dist/esm/index.d.ts +150 -0
  61. package/dist/esm/index.d.ts.map +1 -0
  62. package/dist/esm/index.js +240 -0
  63. package/dist/esm/index.js.map +1 -0
  64. package/dist/esm/minimatch-class.d.ts +153 -0
  65. package/dist/esm/minimatch-class.d.ts.map +1 -0
  66. package/dist/esm/minimatch-class.js +611 -0
  67. package/dist/esm/minimatch-class.js.map +1 -0
  68. package/dist/esm/options.d.ts +31 -0
  69. package/dist/esm/options.d.ts.map +1 -0
  70. package/dist/esm/options.js +63 -0
  71. package/dist/esm/options.js.map +1 -0
  72. package/dist/esm/package.json +3 -0
  73. package/dist/esm/types.d.ts +194 -0
  74. package/dist/esm/types.d.ts.map +1 -0
  75. package/dist/esm/types.js +16 -0
  76. package/dist/esm/types.js.map +1 -0
  77. package/dist/esm/unescape.d.ts +36 -0
  78. package/dist/esm/unescape.d.ts.map +1 -0
  79. package/dist/esm/unescape.js +46 -0
  80. package/dist/esm/unescape.js.map +1 -0
  81. package/dist/esm/utils.d.ts +62 -0
  82. package/dist/esm/utils.d.ts.map +1 -0
  83. package/dist/esm/utils.js +116 -0
  84. package/dist/esm/utils.js.map +1 -0
  85. package/package.json +83 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @fileoverview Options translator: minimatch options -> picomatch options
3
+ *
4
+ * This module handles the translation of minimatch options to picomatch options.
5
+ * Since minimatch-fast uses picomatch as its matching engine, we need to map
6
+ * the options from minimatch's API to picomatch's API.
7
+ *
8
+ * Key differences between minimatch and picomatch options:
9
+ * - noext (minimatch) -> noextglob (picomatch)
10
+ * - matchBase (minimatch) -> basename (picomatch)
11
+ *
12
+ * Some options are handled specially and not passed to picomatch:
13
+ * - nocomment: Comment patterns (handled in Minimatch class)
14
+ * - nonull: Return pattern when no matches (handled in match function)
15
+ * - flipNegate: Invert negation result (handled in match function)
16
+ *
17
+ * @author 686f6c61
18
+ * @see https://github.com/686f6c61/minimatch-fast
19
+ * @license MIT
20
+ */
21
+ /**
22
+ * Translate minimatch options to picomatch options
23
+ * Handles naming differences and sets appropriate defaults
24
+ */
25
+ export function translateOptions(opts = {}) {
26
+ const picoOpts = {
27
+ // Direct mappings (same name, same meaning)
28
+ dot: opts.dot,
29
+ nocase: opts.nocase,
30
+ nonegate: opts.nonegate,
31
+ noglobstar: opts.noglobstar,
32
+ nobrace: opts.nobrace,
33
+ // Renamed options
34
+ noextglob: opts.noext, // minimatch: noext -> picomatch: noextglob
35
+ basename: opts.matchBase, // minimatch: matchBase -> picomatch: basename
36
+ // Force POSIX mode - we handle Windows paths manually via normalizePath
37
+ posix: true,
38
+ // Disable picomatch's brace handling - we use 'braces' package for full expansion
39
+ // picomatch only does brace matching, not expansion
40
+ // We expand braces ourselves, so tell picomatch not to process them
41
+ // Actually, we need nobrace: true to prevent double-processing
42
+ // The expanded patterns should be matched literally by picomatch
43
+ };
44
+ // Special options that need custom handling (not passed to picomatch)
45
+ const special = {
46
+ nocomment: opts.nocomment ?? false,
47
+ nonull: opts.nonull ?? false,
48
+ flipNegate: opts.flipNegate ?? false,
49
+ windowsPathsNoEscape: opts.windowsPathsNoEscape ?? opts.allowWindowsEscape === false,
50
+ partial: opts.partial ?? false,
51
+ magicalBraces: opts.magicalBraces ?? false,
52
+ debug: opts.debug ?? false,
53
+ optimizationLevel: opts.optimizationLevel ?? 1,
54
+ };
55
+ return { picoOpts, special };
56
+ }
57
+ /**
58
+ * Merge options with defaults
59
+ */
60
+ export function mergeOptions(defaults, options) {
61
+ return { ...defaults, ...options };
62
+ }
63
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB,EAAE;IAC1D,MAAM,QAAQ,GAAqB;QACjC,4CAA4C;QAC5C,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;QAErB,kBAAkB;QAClB,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,2CAA2C;QAClE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,8CAA8C;QAExE,wEAAwE;QACxE,KAAK,EAAE,IAAI;QAEX,kFAAkF;QAClF,oDAAoD;QACpD,oEAAoE;QACpE,+DAA+D;QAC/D,iEAAiE;KAClE,CAAC;IAEF,sEAAsE;IACtE,MAAM,OAAO,GAAG;QACd,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;QAC5B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;QACpC,oBAAoB,EAClB,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,kBAAkB,KAAK,KAAK;QAChE,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;QAC9B,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,KAAK;QAC1C,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK;QAC1B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,IAAI,CAAC;KAC/C,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,QAA0B,EAC1B,OAAyB;IAEzB,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,194 @@
1
+ /**
2
+ * @fileoverview Type definitions for minimatch-fast
3
+ *
4
+ * This file contains all TypeScript type definitions used throughout the package.
5
+ * These types are 100% compatible with minimatch v10.x, ensuring seamless migration
6
+ * for projects switching from the original minimatch package.
7
+ *
8
+ * @author 686f6c61
9
+ * @see https://github.com/686f6c61/minimatch-fast
10
+ * @license MIT
11
+ */
12
+ /**
13
+ * Supported platforms for path handling
14
+ */
15
+ export type Platform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
16
+ /**
17
+ * Path separator types
18
+ */
19
+ export type Sep = '\\' | '/';
20
+ /**
21
+ * RegExp with additional metadata
22
+ */
23
+ export type MMRegExp = RegExp & {
24
+ _src?: string;
25
+ _glob?: string;
26
+ };
27
+ /**
28
+ * Symbol representing globstar pattern (**)
29
+ */
30
+ export declare const GLOBSTAR: unique symbol;
31
+ export type GlobstarSymbol = typeof GLOBSTAR;
32
+ /**
33
+ * Parse return types
34
+ */
35
+ export type ParseReturnFiltered = string | MMRegExp | GlobstarSymbol;
36
+ export type ParseReturn = ParseReturnFiltered | false;
37
+ /**
38
+ * Options for minimatch functions
39
+ * All options are optional and default to false unless otherwise specified
40
+ */
41
+ export interface MinimatchOptions {
42
+ /**
43
+ * Do not expand {a,b} and {1..3} brace sets
44
+ * @default false
45
+ */
46
+ nobrace?: boolean;
47
+ /**
48
+ * Disable pattern comments starting with #
49
+ * When false (default), patterns starting with # are treated as comments and match nothing
50
+ * @default false
51
+ */
52
+ nocomment?: boolean;
53
+ /**
54
+ * Disable negation with leading !
55
+ * When false (default), patterns starting with ! are negated
56
+ * @default false
57
+ */
58
+ nonegate?: boolean;
59
+ /**
60
+ * Enable debug output
61
+ * @default false
62
+ */
63
+ debug?: boolean;
64
+ /**
65
+ * Disable ** matching across directory separators
66
+ * When true, ** behaves like *
67
+ * @default false
68
+ */
69
+ noglobstar?: boolean;
70
+ /**
71
+ * Disable extglob patterns like +(a|b), *(a|b), ?(a|b), @(a|b), !(a|b)
72
+ * @default false
73
+ */
74
+ noext?: boolean;
75
+ /**
76
+ * Return the pattern itself when no matches are found
77
+ * Only applies to minimatch.match()
78
+ * @default false
79
+ */
80
+ nonull?: boolean;
81
+ /**
82
+ * Treat backslash as path separator only, not as escape character
83
+ * Replaces all \ with / before processing
84
+ * Useful for Windows paths
85
+ * @default false
86
+ */
87
+ windowsPathsNoEscape?: boolean;
88
+ /**
89
+ * Legacy alias: when set to false, enables windowsPathsNoEscape
90
+ * @deprecated Use windowsPathsNoEscape instead
91
+ */
92
+ allowWindowsEscape?: boolean;
93
+ /**
94
+ * Perform partial matching
95
+ * Useful when traversing directories and full path is not yet known
96
+ * @default false
97
+ */
98
+ partial?: boolean;
99
+ /**
100
+ * Match patterns without slashes against basename of the path
101
+ * e.g., *.js will match path/to/file.js
102
+ * @default false
103
+ */
104
+ matchBase?: boolean;
105
+ /**
106
+ * Preserve multiple consecutive slashes
107
+ * By default, multiple slashes are collapsed to one
108
+ * @default false
109
+ */
110
+ preserveMultipleSlashes?: boolean;
111
+ /**
112
+ * Match dotfiles (files starting with .)
113
+ * By default, * and ** do not match dotfiles unless pattern also starts with .
114
+ * @default false
115
+ */
116
+ dot?: boolean;
117
+ /**
118
+ * Perform case-insensitive matching
119
+ * @default false
120
+ */
121
+ nocase?: boolean;
122
+ /**
123
+ * When used with nocase, only use case-insensitive regex
124
+ * but leave string comparisons case-sensitive
125
+ * Has no effect without nocase: true
126
+ * @default false
127
+ */
128
+ nocaseMagicOnly?: boolean;
129
+ /**
130
+ * Treat brace expansion as "magic" for hasMagic()
131
+ * When true, patterns like {a,b} are considered to have magic
132
+ * @default false
133
+ */
134
+ magicalBraces?: boolean;
135
+ /**
136
+ * Invert the result of negation
137
+ * When true, negated patterns return true on hit and false on miss
138
+ * @default false
139
+ */
140
+ flipNegate?: boolean;
141
+ /**
142
+ * Optimization level for pattern processing
143
+ * 0 = no optimization
144
+ * 1 = basic optimization (default)
145
+ * 2+ = aggressive optimization
146
+ * @default 1
147
+ */
148
+ optimizationLevel?: number;
149
+ /**
150
+ * Override platform detection for path handling
151
+ */
152
+ platform?: Platform;
153
+ /**
154
+ * Windows-specific: disable magic root detection for drive letters
155
+ * @default false on non-Windows, true on Windows with nocase
156
+ */
157
+ windowsNoMagicRoot?: boolean;
158
+ }
159
+ /**
160
+ * Options specifically for picomatch (internal use)
161
+ */
162
+ export interface PicomatchOptions {
163
+ dot?: boolean;
164
+ nocase?: boolean;
165
+ nonegate?: boolean;
166
+ noextglob?: boolean;
167
+ noglobstar?: boolean;
168
+ nobrace?: boolean;
169
+ basename?: boolean;
170
+ posix?: boolean;
171
+ windows?: boolean;
172
+ contains?: boolean;
173
+ flags?: string;
174
+ matchBase?: boolean;
175
+ posixSlashes?: boolean;
176
+ expandRange?: (a: string, b: string) => string;
177
+ }
178
+ /**
179
+ * Result of translating minimatch options to picomatch options
180
+ */
181
+ export interface TranslatedOptions {
182
+ picoOpts: PicomatchOptions;
183
+ special: {
184
+ nocomment: boolean;
185
+ nonull: boolean;
186
+ flipNegate: boolean;
187
+ windowsPathsNoEscape: boolean;
188
+ partial: boolean;
189
+ magicalBraces: boolean;
190
+ debug: boolean;
191
+ optimizationLevel: number;
192
+ };
193
+ }
194
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,SAAS,GACT,QAAQ,GACR,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,MAA8B,CAAC;AAC7D,MAAM,MAAM,cAAc,GAAG,OAAO,QAAQ,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,KAAK,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAA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C,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,oBAAoB,EAAE,OAAO,CAAC;QAC9B,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,OAAO,CAAC;QACvB,KAAK,EAAE,OAAO,CAAC;QACf,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @fileoverview Type definitions for minimatch-fast
3
+ *
4
+ * This file contains all TypeScript type definitions used throughout the package.
5
+ * These types are 100% compatible with minimatch v10.x, ensuring seamless migration
6
+ * for projects switching from the original minimatch package.
7
+ *
8
+ * @author 686f6c61
9
+ * @see https://github.com/686f6c61/minimatch-fast
10
+ * @license MIT
11
+ */
12
+ /**
13
+ * Symbol representing globstar pattern (**)
14
+ */
15
+ export const GLOBSTAR = Symbol('globstar **');
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA+BH;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Unescape glob magic characters
3
+ *
4
+ * This module provides functionality to unescape previously escaped glob strings,
5
+ * reversing the operation performed by the escape() function.
6
+ *
7
+ * Unescape modes:
8
+ * - Default mode: Removes backslash escaping (\\* -> *)
9
+ * - Windows mode: Removes character class escaping ([*] -> *)
10
+ *
11
+ * This is useful when you need to convert escaped patterns back to their
12
+ * original form for display or further processing.
13
+ *
14
+ * @example
15
+ * unescape('\\*.js') // Returns '*.js'
16
+ * unescape('[*].js', { windowsPathsNoEscape: true }) // Returns '*.js'
17
+ *
18
+ * @author 686f6c61
19
+ * @see https://github.com/686f6c61/minimatch-fast
20
+ * @license MIT
21
+ */
22
+ import type { MinimatchOptions } from './types.js';
23
+ /**
24
+ * Un-escape a string that has been escaped with escape().
25
+ *
26
+ * If windowsPathsNoEscape is true, square-bracket escapes are removed,
27
+ * but not backslash escapes (since backslash is a path separator in this mode).
28
+ *
29
+ * If windowsPathsNoEscape is false (default), backslash escapes are removed.
30
+ *
31
+ * @param str - The string to unescape
32
+ * @param options - Options controlling unescape behavior
33
+ * @returns Unescaped string
34
+ */
35
+ export declare function unescape(str: string, options?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>): string;
36
+ //# sourceMappingURL=unescape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,GAC3D,MAAM,CAaR"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @fileoverview Unescape glob magic characters
3
+ *
4
+ * This module provides functionality to unescape previously escaped glob strings,
5
+ * reversing the operation performed by the escape() function.
6
+ *
7
+ * Unescape modes:
8
+ * - Default mode: Removes backslash escaping (\\* -> *)
9
+ * - Windows mode: Removes character class escaping ([*] -> *)
10
+ *
11
+ * This is useful when you need to convert escaped patterns back to their
12
+ * original form for display or further processing.
13
+ *
14
+ * @example
15
+ * unescape('\\*.js') // Returns '*.js'
16
+ * unescape('[*].js', { windowsPathsNoEscape: true }) // Returns '*.js'
17
+ *
18
+ * @author 686f6c61
19
+ * @see https://github.com/686f6c61/minimatch-fast
20
+ * @license MIT
21
+ */
22
+ /**
23
+ * Un-escape a string that has been escaped with escape().
24
+ *
25
+ * If windowsPathsNoEscape is true, square-bracket escapes are removed,
26
+ * but not backslash escapes (since backslash is a path separator in this mode).
27
+ *
28
+ * If windowsPathsNoEscape is false (default), backslash escapes are removed.
29
+ *
30
+ * @param str - The string to unescape
31
+ * @param options - Options controlling unescape behavior
32
+ * @returns Unescaped string
33
+ */
34
+ export function unescape(str, options = {}) {
35
+ const { windowsPathsNoEscape = false } = options;
36
+ if (windowsPathsNoEscape) {
37
+ // Remove square-bracket escapes: [x] -> x
38
+ // But only for single non-special characters
39
+ // Don't touch things like [abc] or [a-z]
40
+ return str.replace(/\[([^\/\\[\]{}])\]/g, '$1');
41
+ }
42
+ // Default: remove backslash escapes
43
+ // \x -> x (but not for forward slash which can't be escaped)
44
+ return str.replace(/\\([^/])/g, '$1');
45
+ }
46
+ //# sourceMappingURL=unescape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unescape.js","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAW,EACX,UAA0D,EAAE;IAE5D,MAAM,EAAE,oBAAoB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEjD,IAAI,oBAAoB,EAAE,CAAC;QACzB,0CAA0C;QAC1C,6CAA6C;QAC7C,yCAAyC;QACzC,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,oCAAoC;IACpC,6DAA6D;IAC7D,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @fileoverview Path utilities for cross-platform support
3
+ *
4
+ * This module provides utility functions for handling paths across different
5
+ * operating systems. It includes functions for:
6
+ * - Platform detection (Windows vs POSIX)
7
+ * - Path normalization (backslash to forward slash conversion)
8
+ * - Path splitting with UNC path support
9
+ * - Glob magic character detection
10
+ *
11
+ * These utilities ensure minimatch-fast works correctly on all platforms
12
+ * while maintaining compatibility with the original minimatch behavior.
13
+ *
14
+ * @author 686f6c61
15
+ * @see https://github.com/686f6c61/minimatch-fast
16
+ * @license MIT
17
+ */
18
+ import type { Platform, Sep } from './types';
19
+ /**
20
+ * Get the default path separator based on platform
21
+ */
22
+ export declare const sep: Sep;
23
+ /**
24
+ * Check if the given platform is Windows
25
+ */
26
+ export declare function isWindows(platform?: Platform): boolean;
27
+ /**
28
+ * Get the current platform
29
+ */
30
+ export declare function getPlatform(): Platform;
31
+ /**
32
+ * Normalize a path by converting backslashes to forward slashes
33
+ * This is critical for Windows compatibility
34
+ *
35
+ * @param path - The path to normalize
36
+ * @param windowsPathsNoEscape - If true, treat backslash as path separator
37
+ */
38
+ export declare function normalizePath(path: string, windowsPathsNoEscape: boolean): string;
39
+ /**
40
+ * Normalize a pattern by converting backslashes to forward slashes
41
+ *
42
+ * @param pattern - The pattern to normalize
43
+ * @param windowsPathsNoEscape - If true, treat backslash as path separator
44
+ */
45
+ export declare function normalizePattern(pattern: string, windowsPathsNoEscape: boolean): string;
46
+ /**
47
+ * Split a path by slashes
48
+ *
49
+ * @param path - The path to split
50
+ * @param preserveMultipleSlashes - If true, don't collapse multiple slashes
51
+ * @param isWindowsPlatform - If true, handle UNC paths
52
+ */
53
+ export declare function slashSplit(path: string, preserveMultipleSlashes: boolean, isWindowsPlatform: boolean): string[];
54
+ /**
55
+ * Check if a pattern contains glob magic characters
56
+ */
57
+ export declare function hasMagicChars(pattern: string): boolean;
58
+ /**
59
+ * Unescape a string for regex use
60
+ */
61
+ export declare function escapeRegex(str: string): string;
62
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAc7C;;GAEG;AACH,eAAO,MAAM,GAAG,EAAE,GAA8C,CAAC;AAEjE;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,OAAO,GAC5B,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,oBAAoB,EAAE,OAAO,GAC5B,MAAM,CAKR;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,OAAO,EAChC,iBAAiB,EAAE,OAAO,GACzB,MAAM,EAAE,CA4BV;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @fileoverview Path utilities for cross-platform support
3
+ *
4
+ * This module provides utility functions for handling paths across different
5
+ * operating systems. It includes functions for:
6
+ * - Platform detection (Windows vs POSIX)
7
+ * - Path normalization (backslash to forward slash conversion)
8
+ * - Path splitting with UNC path support
9
+ * - Glob magic character detection
10
+ *
11
+ * These utilities ensure minimatch-fast works correctly on all platforms
12
+ * while maintaining compatibility with the original minimatch behavior.
13
+ *
14
+ * @author 686f6c61
15
+ * @see https://github.com/686f6c61/minimatch-fast
16
+ * @license MIT
17
+ */
18
+ /**
19
+ * Detect the current platform
20
+ */
21
+ const defaultPlatform = (typeof process === 'object' &&
22
+ process &&
23
+ typeof process.platform === 'string'
24
+ ? process.env['__MINIMATCH_TESTING_PLATFORM__'] ||
25
+ process.platform
26
+ : 'linux');
27
+ /**
28
+ * Get the default path separator based on platform
29
+ */
30
+ export const sep = defaultPlatform === 'win32' ? '\\' : '/';
31
+ /**
32
+ * Check if the given platform is Windows
33
+ */
34
+ export function isWindows(platform) {
35
+ return (platform || defaultPlatform) === 'win32';
36
+ }
37
+ /**
38
+ * Get the current platform
39
+ */
40
+ export function getPlatform() {
41
+ return defaultPlatform;
42
+ }
43
+ /**
44
+ * Normalize a path by converting backslashes to forward slashes
45
+ * This is critical for Windows compatibility
46
+ *
47
+ * @param path - The path to normalize
48
+ * @param windowsPathsNoEscape - If true, treat backslash as path separator
49
+ */
50
+ export function normalizePath(path, windowsPathsNoEscape) {
51
+ if (typeof path !== 'string')
52
+ return path;
53
+ // If windowsPathsNoEscape is true, convert all backslashes to forward slashes
54
+ // This matches minimatch behavior where backslash is path separator, not escape
55
+ if (windowsPathsNoEscape) {
56
+ return path.replace(/\\/g, '/');
57
+ }
58
+ return path;
59
+ }
60
+ /**
61
+ * Normalize a pattern by converting backslashes to forward slashes
62
+ *
63
+ * @param pattern - The pattern to normalize
64
+ * @param windowsPathsNoEscape - If true, treat backslash as path separator
65
+ */
66
+ export function normalizePattern(pattern, windowsPathsNoEscape) {
67
+ if (windowsPathsNoEscape) {
68
+ return pattern.replace(/\\/g, '/');
69
+ }
70
+ return pattern;
71
+ }
72
+ /**
73
+ * Split a path by slashes
74
+ *
75
+ * @param path - The path to split
76
+ * @param preserveMultipleSlashes - If true, don't collapse multiple slashes
77
+ * @param isWindowsPlatform - If true, handle UNC paths
78
+ */
79
+ export function slashSplit(path, preserveMultipleSlashes, isWindowsPlatform) {
80
+ // Handle empty path
81
+ if (!path) {
82
+ return [''];
83
+ }
84
+ // If preserving multiple slashes, just split on single slash
85
+ if (preserveMultipleSlashes) {
86
+ return path.split('/');
87
+ }
88
+ // Handle UNC paths on Windows (e.g., //server/share)
89
+ if (isWindowsPlatform && /^\/\/[^/]+/.test(path)) {
90
+ // Preserve the leading // for UNC paths
91
+ const parts = path.split(/\/+/);
92
+ // First element will be empty string from leading //, keep it
93
+ return ['', ...parts.filter((p, i) => i === 0 || p !== '')];
94
+ }
95
+ // Normal case: split on one or more slashes, filter empty parts except leading
96
+ const parts = path.split(/\/+/);
97
+ // Handle absolute paths (preserve leading empty string)
98
+ if (path.startsWith('/')) {
99
+ return ['', ...parts.filter((p) => p !== '')];
100
+ }
101
+ return parts.filter((p) => p !== '');
102
+ }
103
+ /**
104
+ * Check if a pattern contains glob magic characters
105
+ */
106
+ export function hasMagicChars(pattern) {
107
+ // Check for glob special characters
108
+ return /[*?[\]{}()!@+]/.test(pattern);
109
+ }
110
+ /**
111
+ * Unescape a string for regex use
112
+ */
113
+ export function escapeRegex(str) {
114
+ return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
115
+ }
116
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;GAEG;AACH,MAAM,eAAe,GAAa,CAChC,OAAO,OAAO,KAAK,QAAQ;IAC3B,OAAO;IACP,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;IAClC,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAc;QAC1D,OAAO,CAAC,QAAqB;IAChC,CAAC,CAAC,OAAO,CACA,CAAC;AAEd;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAQ,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,QAAmB;IAC3C,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,KAAK,OAAO,CAAC;AACnD,CAAC;AAED;;GAEG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IAED,+EAA+E;IAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEhC,wDAAwD;IACxD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,oCAAoC;IACpC,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "minimatch-fast",
3
+ "version": "0.2.1",
4
+ "type": "module",
5
+ "description": "Drop-in replacement for minimatch. 6-25x faster. Powered by picomatch.",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/cjs/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/esm/index.d.ts",
13
+ "default": "./dist/esm/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/cjs/index.d.ts",
17
+ "default": "./dist/cjs/index.js"
18
+ }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20"
28
+ },
29
+ "scripts": {
30
+ "build": "npm run build:cjs && npm run build:esm && npm run build:fixup",
31
+ "build:cjs": "tsc -p tsconfig.cjs.json",
32
+ "build:esm": "tsc -p tsconfig.esm.json",
33
+ "build:fixup": "node scripts/fixup.js",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "test:coverage": "vitest run --coverage",
37
+ "test:compat": "vitest run -c vitest.compat.config.ts",
38
+ "benchmark": "tsx benchmarks/run.ts",
39
+ "prepublishOnly": "npm run build && npm test",
40
+ "clean": "rm -rf dist"
41
+ },
42
+ "dependencies": {
43
+ "braces": "^3.0.3",
44
+ "picomatch": "^4.0.3"
45
+ },
46
+ "devDependencies": {
47
+ "@types/braces": "^3.0.5",
48
+ "@types/node": "^22.10.0",
49
+ "@types/picomatch": "^4.0.2",
50
+ "@vitest/coverage-v8": "^3.1.0",
51
+ "benchmark": "^2.1.4",
52
+ "minimatch": "^10.1.1",
53
+ "tsx": "^4.21.0",
54
+ "typescript": "^5.9.3",
55
+ "vitest": "^3.1.0"
56
+ },
57
+ "keywords": [
58
+ "glob",
59
+ "minimatch",
60
+ "picomatch",
61
+ "fast",
62
+ "pattern",
63
+ "matcher",
64
+ "match",
65
+ "file",
66
+ "filter",
67
+ "wildcard",
68
+ "bash",
69
+ "regex",
70
+ "regexp",
71
+ "globbing"
72
+ ],
73
+ "author": "686f6c61",
74
+ "license": "MIT",
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/686f6c61/minimatch-fast.git"
78
+ },
79
+ "bugs": {
80
+ "url": "https://github.com/686f6c61/minimatch-fast/issues"
81
+ },
82
+ "homepage": "https://minimatch-fast.onrender.com"
83
+ }