globlin 1.0.0-beta.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/CHANGELOG.md +114 -0
- package/LICENSE +76 -0
- package/README.md +276 -0
- package/index.d.ts +399 -0
- package/index.js +325 -0
- package/js/index.d.ts +475 -0
- package/js/index.d.ts.map +1 -0
- package/js/index.js +924 -0
- package/js/stream.d.ts +41 -0
- package/js/stream.d.ts.map +1 -0
- package/js/stream.js +94 -0
- package/js/types.d.ts +141 -0
- package/js/types.d.ts.map +1 -0
- package/js/types.js +8 -0
- package/package.json +189 -0
package/js/index.d.ts
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* globlin - A high-performance glob pattern matcher
|
|
3
|
+
*
|
|
4
|
+
* This module provides a 100% compatible drop-in replacement for glob v13,
|
|
5
|
+
* implemented in Rust for 20-30x faster performance.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Pattern warning info returned by analyzePattern/analyzePatterns
|
|
9
|
+
*/
|
|
10
|
+
export interface PatternWarningInfo {
|
|
11
|
+
/** The type of warning (e.g., "escaped_wildcard_at_start", "performance", "empty_pattern") */
|
|
12
|
+
warningType: string;
|
|
13
|
+
/** Human-readable warning message */
|
|
14
|
+
message: string;
|
|
15
|
+
/** The original problematic pattern (if applicable) */
|
|
16
|
+
pattern?: string;
|
|
17
|
+
/** Suggested fix (if applicable) */
|
|
18
|
+
suggestion?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Path data returned from native glob with withFileTypes
|
|
22
|
+
*/
|
|
23
|
+
interface NativePathData {
|
|
24
|
+
path: string;
|
|
25
|
+
isDirectory: boolean;
|
|
26
|
+
isFile: boolean;
|
|
27
|
+
isSymlink: boolean;
|
|
28
|
+
}
|
|
29
|
+
import { PathScurry, Path } from 'path-scurry';
|
|
30
|
+
export { PathScurry, Path };
|
|
31
|
+
export { Minimatch, minimatch } from 'minimatch';
|
|
32
|
+
import { Minipass } from 'minipass';
|
|
33
|
+
export { Minipass };
|
|
34
|
+
export interface GlobOptions {
|
|
35
|
+
cwd?: string;
|
|
36
|
+
root?: string;
|
|
37
|
+
dot?: boolean;
|
|
38
|
+
nobrace?: boolean;
|
|
39
|
+
noglobstar?: boolean;
|
|
40
|
+
noext?: boolean;
|
|
41
|
+
nocase?: boolean;
|
|
42
|
+
magicalBraces?: boolean;
|
|
43
|
+
follow?: boolean;
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
matchBase?: boolean;
|
|
46
|
+
absolute?: boolean;
|
|
47
|
+
dotRelative?: boolean;
|
|
48
|
+
mark?: boolean;
|
|
49
|
+
nodir?: boolean;
|
|
50
|
+
posix?: boolean;
|
|
51
|
+
withFileTypes?: boolean;
|
|
52
|
+
stat?: boolean;
|
|
53
|
+
realpath?: boolean;
|
|
54
|
+
ignore?: string | string[] | IgnorePattern;
|
|
55
|
+
includeChildMatches?: boolean;
|
|
56
|
+
platform?: 'linux' | 'darwin' | 'win32';
|
|
57
|
+
windowsPathsNoEscape?: boolean;
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
/**
|
|
60
|
+
* Enable parallel directory walking using multiple threads.
|
|
61
|
+
*
|
|
62
|
+
* When `true`, uses parallel traversal which can be faster on:
|
|
63
|
+
* - Spinning hard drives (HDDs)
|
|
64
|
+
* - Network filesystems (NFS, CIFS)
|
|
65
|
+
* - Very large directory trees (100k+ files)
|
|
66
|
+
*
|
|
67
|
+
* When `false` (default), uses serial traversal which is:
|
|
68
|
+
* - Faster on SSDs for small to medium directories
|
|
69
|
+
* - Deterministic result ordering
|
|
70
|
+
* - Lower memory overhead
|
|
71
|
+
*
|
|
72
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
73
|
+
* Results may be returned in a different order when `parallel: true`.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
parallel?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Enable directory caching for repeated glob operations.
|
|
80
|
+
*
|
|
81
|
+
* When `true`, caches directory listings in memory with a TTL-based invalidation
|
|
82
|
+
* strategy. This provides significant speedup when:
|
|
83
|
+
* - Running multiple glob operations on the same directories
|
|
84
|
+
* - Using the Glob class with cache reuse (passing Glob as options)
|
|
85
|
+
* - Patterns with overlapping directory prefixes
|
|
86
|
+
*
|
|
87
|
+
* When `false` (default), directories are read fresh each time, which is:
|
|
88
|
+
* - More accurate if the filesystem is changing
|
|
89
|
+
* - Lower memory usage (no cached directory listings)
|
|
90
|
+
* - Slightly slower for repeated operations
|
|
91
|
+
*
|
|
92
|
+
* The cache has a 5-second TTL to balance freshness with performance.
|
|
93
|
+
* Use `cache: false` when you expect filesystem changes during the operation.
|
|
94
|
+
*
|
|
95
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
cache?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Use optimized native I/O operations on Linux and macOS.
|
|
102
|
+
*
|
|
103
|
+
* When `true`, uses platform-specific optimizations:
|
|
104
|
+
* - Linux: `getdents64` syscall for faster directory reading (bypasses libc overhead)
|
|
105
|
+
* - macOS: Low-level BSD directory APIs with d_type for early file type detection
|
|
106
|
+
*
|
|
107
|
+
* Performance characteristics:
|
|
108
|
+
* - Linux: Expected 1.3-1.5x speedup on directory-heavy workloads
|
|
109
|
+
* - macOS: May provide speedup on some filesystems; benchmark for your use case
|
|
110
|
+
*
|
|
111
|
+
* When `false` (default), uses the standard `walkdir` library which is:
|
|
112
|
+
* - Cross-platform compatible
|
|
113
|
+
* - Well-tested and stable
|
|
114
|
+
* - Sufficient for most use cases
|
|
115
|
+
*
|
|
116
|
+
* On Windows, this option is ignored and the standard walker is used.
|
|
117
|
+
*
|
|
118
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
119
|
+
*
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
useNativeIO?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Use Grand Central Dispatch (GCD) for parallel walking on macOS.
|
|
125
|
+
*
|
|
126
|
+
* When `true` on macOS, uses Apple's Grand Central Dispatch framework for
|
|
127
|
+
* parallel directory traversal. This provides:
|
|
128
|
+
* - Native macOS scheduler integration
|
|
129
|
+
* - Automatic handling of efficiency vs performance cores on Apple Silicon
|
|
130
|
+
* - Better power management than generic thread pools
|
|
131
|
+
* - Lower overhead than rayon for I/O-bound workloads
|
|
132
|
+
*
|
|
133
|
+
* When `false` (default), uses the standard walker which is often faster
|
|
134
|
+
* on modern SSDs due to reduced coordination overhead.
|
|
135
|
+
*
|
|
136
|
+
* **When to use:**
|
|
137
|
+
* - Large directory trees (100k+ files) on Macs with many cores
|
|
138
|
+
* - Network filesystems where I/O latency dominates
|
|
139
|
+
* - When power efficiency matters (GCD respects system power state)
|
|
140
|
+
*
|
|
141
|
+
* **When NOT to use:**
|
|
142
|
+
* - Small to medium directories on SSD
|
|
143
|
+
* - When deterministic ordering is required
|
|
144
|
+
* - On non-macOS platforms (option is ignored)
|
|
145
|
+
*
|
|
146
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
147
|
+
*
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
useGcd?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Custom ignore pattern object. Compatible with glob v13's IgnoreLike interface.
|
|
154
|
+
*
|
|
155
|
+
* Both methods receive Path objects from path-scurry, allowing for rich
|
|
156
|
+
* filtering based on file properties (name, isDirectory, isFile, etc.)
|
|
157
|
+
*/
|
|
158
|
+
export interface IgnorePattern {
|
|
159
|
+
/**
|
|
160
|
+
* Called for each path to determine if it should be excluded from results.
|
|
161
|
+
* @param path - The Path object representing the file/directory
|
|
162
|
+
* @returns true if the path should be ignored (excluded from results)
|
|
163
|
+
*/
|
|
164
|
+
ignored?: (path: Path) => boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Called for each directory to determine if its children should be ignored.
|
|
167
|
+
* When this returns true, the directory's contents are not traversed.
|
|
168
|
+
* @param path - The Path object representing the directory
|
|
169
|
+
* @returns true if the directory's children should be skipped
|
|
170
|
+
*/
|
|
171
|
+
childrenIgnored?: (path: Path) => boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Options for glob with withFileTypes: true
|
|
175
|
+
*/
|
|
176
|
+
export interface GlobOptionsWithFileTypesTrue extends GlobOptions {
|
|
177
|
+
withFileTypes: true;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Options for glob with withFileTypes: false or undefined
|
|
181
|
+
*/
|
|
182
|
+
export interface GlobOptionsWithFileTypesFalse extends GlobOptions {
|
|
183
|
+
withFileTypes?: false | undefined;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Result type for glob with withFileTypes: true.
|
|
187
|
+
* Returns GloblinPath objects which are 85% faster to create than PathScurry Path objects.
|
|
188
|
+
* Use .toPath() on any result if you need the full PathScurry Path.
|
|
189
|
+
*/
|
|
190
|
+
export type GlobPathResult = GloblinPath;
|
|
191
|
+
/**
|
|
192
|
+
* GloblinPath - A lazy Path-like wrapper that provides fast access to common properties
|
|
193
|
+
* while deferring expensive PathScurry resolution until needed.
|
|
194
|
+
*
|
|
195
|
+
* This class implements the most commonly used Path interface methods using cached
|
|
196
|
+
* values from Rust, avoiding the expensive `scurry.cwd.resolve()` call for each result.
|
|
197
|
+
* When advanced features are needed, call `toPath()` to get the full PathScurry Path.
|
|
198
|
+
*
|
|
199
|
+
* **Performance Characteristics:**
|
|
200
|
+
* - Creation: ~0.5µs (vs ~16µs for PathScurry Path)
|
|
201
|
+
* - isFile()/isDirectory()/isSymbolicLink(): ~0.06µs (uses cached values)
|
|
202
|
+
* - fullpath()/relative(): ~0.1µs (string operations)
|
|
203
|
+
* - toPath(): ~16µs (creates full PathScurry Path on demand)
|
|
204
|
+
*
|
|
205
|
+
* This optimization provides ~85% speedup for withFileTypes compared to eagerly
|
|
206
|
+
* creating PathScurry Path objects for every result.
|
|
207
|
+
*/
|
|
208
|
+
export declare class GloblinPath {
|
|
209
|
+
/** The relative path string */
|
|
210
|
+
readonly path: string;
|
|
211
|
+
/** The absolute working directory */
|
|
212
|
+
private readonly _cwd;
|
|
213
|
+
/** Cached file type information from Rust */
|
|
214
|
+
private readonly _isDir;
|
|
215
|
+
private readonly _isFileVal;
|
|
216
|
+
private readonly _isSymlinkVal;
|
|
217
|
+
/** Whether stat option was enabled (if false, isFile/isDirectory return false like PathScurry) */
|
|
218
|
+
private readonly _stat;
|
|
219
|
+
/** Lazily resolved PathScurry Path (only created if toPath() is called) */
|
|
220
|
+
private _pathScurryPath?;
|
|
221
|
+
private _pathScurry?;
|
|
222
|
+
/** Cached fullpath string */
|
|
223
|
+
private _fullpath?;
|
|
224
|
+
/** The name (basename) of this path entry */
|
|
225
|
+
readonly name: string;
|
|
226
|
+
constructor(relativePath: string, cwd: string, isDirectory: boolean, isFile: boolean, isSymlink: boolean, stat?: boolean);
|
|
227
|
+
/**
|
|
228
|
+
* Returns true if this is a regular file.
|
|
229
|
+
* Without stat: true, returns false (unknown type) to match PathScurry behavior.
|
|
230
|
+
* With stat: true, uses cached value from Rust - no filesystem access needed.
|
|
231
|
+
*/
|
|
232
|
+
isFile(): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Returns true if this is a directory.
|
|
235
|
+
* Without stat: true, returns false (unknown type) to match PathScurry behavior.
|
|
236
|
+
* With stat: true, uses cached value from Rust - no filesystem access needed.
|
|
237
|
+
*/
|
|
238
|
+
isDirectory(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Returns true if this is a symbolic link.
|
|
241
|
+
* Uses cached value from Rust - no filesystem access needed.
|
|
242
|
+
*/
|
|
243
|
+
isSymbolicLink(): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the full absolute path.
|
|
246
|
+
* This is a fast string operation (no filesystem access).
|
|
247
|
+
*/
|
|
248
|
+
fullpath(): string;
|
|
249
|
+
/**
|
|
250
|
+
* Returns the path relative to the cwd.
|
|
251
|
+
* This is a fast string operation (no filesystem access).
|
|
252
|
+
*/
|
|
253
|
+
relative(): string;
|
|
254
|
+
/**
|
|
255
|
+
* Returns the full absolute path as a string.
|
|
256
|
+
* Alias for fullpath() for compatibility.
|
|
257
|
+
*/
|
|
258
|
+
fullpathPosix(): string;
|
|
259
|
+
/**
|
|
260
|
+
* Returns the relative path as a string.
|
|
261
|
+
* Alias for relative() for compatibility.
|
|
262
|
+
*/
|
|
263
|
+
relativePosix(): string;
|
|
264
|
+
/**
|
|
265
|
+
* Convert to a full PathScurry Path object.
|
|
266
|
+
* This is an expensive operation (~16µs) that should only be called
|
|
267
|
+
* when you need advanced Path features not provided by GloblinPath.
|
|
268
|
+
*
|
|
269
|
+
* The PathScurry Path is cached, so subsequent calls are fast.
|
|
270
|
+
*
|
|
271
|
+
* @returns A full PathScurry Path object
|
|
272
|
+
*/
|
|
273
|
+
toPath(): Path;
|
|
274
|
+
/**
|
|
275
|
+
* Get the parent directory as a GloblinPath.
|
|
276
|
+
* Note: This creates a new GloblinPath for the parent.
|
|
277
|
+
* For advanced parent traversal, use toPath().parent.
|
|
278
|
+
*/
|
|
279
|
+
get parent(): GloblinPath | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* String representation (returns the relative path).
|
|
282
|
+
*/
|
|
283
|
+
toString(): string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Type representing either a PathScurry Path or a GloblinPath wrapper.
|
|
287
|
+
* GloblinPath provides the same common interface with better performance.
|
|
288
|
+
*/
|
|
289
|
+
export type GlobPath = Path | GloblinPath;
|
|
290
|
+
/**
|
|
291
|
+
* LEGACY: Convert native PathData to full PathScurry Path objects.
|
|
292
|
+
* This is the slow path (~16µs per result) that was used before optimization.
|
|
293
|
+
* Kept for compatibility and when full PathScurry features are needed.
|
|
294
|
+
*
|
|
295
|
+
* @deprecated Use convertToPathObjects() instead for better performance.
|
|
296
|
+
*/
|
|
297
|
+
declare function convertToFullPathObjects(data: NativePathData[], cwd: string, performLstat?: boolean): Path[];
|
|
298
|
+
export { convertToFullPathObjects };
|
|
299
|
+
/**
|
|
300
|
+
* Synchronous glob pattern matching
|
|
301
|
+
*
|
|
302
|
+
* @param pattern - Glob pattern or array of patterns
|
|
303
|
+
* @param options - Glob options
|
|
304
|
+
* @returns Array of matching file paths (or GloblinPath objects if withFileTypes: true)
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* When `withFileTypes: true`, returns GloblinPath objects which are 85% faster to create
|
|
308
|
+
* than PathScurry Path objects. GloblinPath provides the same common interface (isFile,
|
|
309
|
+
* isDirectory, isSymbolicLink, fullpath, relative) using cached values from Rust.
|
|
310
|
+
* Call `.toPath()` on any result if you need the full PathScurry Path.
|
|
311
|
+
*/
|
|
312
|
+
export declare function globSync(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): GloblinPath[];
|
|
313
|
+
export declare function globSync(pattern: string | string[], options?: GlobOptionsWithFileTypesFalse): string[];
|
|
314
|
+
export declare function globSync(pattern: string | string[], options?: GlobOptions): string[] | GloblinPath[];
|
|
315
|
+
/**
|
|
316
|
+
* Asynchronous glob pattern matching
|
|
317
|
+
*
|
|
318
|
+
* @param pattern - Glob pattern or array of patterns
|
|
319
|
+
* @param options - Glob options
|
|
320
|
+
* @returns Promise resolving to array of matching file paths (or GloblinPath objects if withFileTypes: true)
|
|
321
|
+
*
|
|
322
|
+
* @remarks
|
|
323
|
+
* When `withFileTypes: true`, returns GloblinPath objects which are 85% faster to create
|
|
324
|
+
* than PathScurry Path objects. GloblinPath provides the same common interface (isFile,
|
|
325
|
+
* isDirectory, isSymbolicLink, fullpath, relative) using cached values from Rust.
|
|
326
|
+
* Call `.toPath()` on any result if you need the full PathScurry Path.
|
|
327
|
+
*/
|
|
328
|
+
export declare function glob(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Promise<GloblinPath[]>;
|
|
329
|
+
export declare function glob(pattern: string | string[], options?: GlobOptionsWithFileTypesFalse): Promise<string[]>;
|
|
330
|
+
export declare function glob(pattern: string | string[], options?: GlobOptions): Promise<string[] | GloblinPath[]>;
|
|
331
|
+
/**
|
|
332
|
+
* Streaming glob pattern matching
|
|
333
|
+
*
|
|
334
|
+
* Uses native streaming to reduce peak memory usage for large result sets.
|
|
335
|
+
* Results are streamed directly from Rust as they are found, rather than
|
|
336
|
+
* collecting all results before sending to JavaScript.
|
|
337
|
+
*
|
|
338
|
+
* @param pattern - Glob pattern or array of patterns
|
|
339
|
+
* @param options - Glob options
|
|
340
|
+
* @returns Minipass stream of matching file paths
|
|
341
|
+
*/
|
|
342
|
+
export declare function globStream(pattern: string | string[], options?: GlobOptions): Minipass<string, string>;
|
|
343
|
+
/**
|
|
344
|
+
* Synchronous streaming glob pattern matching
|
|
345
|
+
*
|
|
346
|
+
* @param pattern - Glob pattern or array of patterns
|
|
347
|
+
* @param options - Glob options
|
|
348
|
+
* @returns Minipass stream of matching file paths
|
|
349
|
+
*/
|
|
350
|
+
export declare function globStreamSync(pattern: string | string[], options?: GlobOptions): Minipass<string, string>;
|
|
351
|
+
/**
|
|
352
|
+
* Async iterator for glob results
|
|
353
|
+
*
|
|
354
|
+
* @param pattern - Glob pattern or array of patterns
|
|
355
|
+
* @param options - Glob options
|
|
356
|
+
* @yields Matching file paths
|
|
357
|
+
*/
|
|
358
|
+
export declare function globIterate(pattern: string | string[], options?: GlobOptions): AsyncGenerator<string, void, void>;
|
|
359
|
+
/**
|
|
360
|
+
* Sync iterator for glob results
|
|
361
|
+
*
|
|
362
|
+
* @param pattern - Glob pattern or array of patterns
|
|
363
|
+
* @param options - Glob options
|
|
364
|
+
* @yields Matching file paths
|
|
365
|
+
*/
|
|
366
|
+
export declare function globIterateSync(pattern: string | string[], options?: GlobOptions): Generator<string, void, void>;
|
|
367
|
+
/**
|
|
368
|
+
* Check if a pattern contains any magic glob characters.
|
|
369
|
+
* Takes into account escaped characters - escaped magic chars don't count.
|
|
370
|
+
*
|
|
371
|
+
* @param pattern - Glob pattern or array of patterns
|
|
372
|
+
* @param options - Glob options
|
|
373
|
+
* @returns True if the pattern has magic (unescaped) glob characters
|
|
374
|
+
*/
|
|
375
|
+
export declare function hasMagic(pattern: string | string[], options?: GlobOptions): boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Escape magic glob characters in a pattern.
|
|
378
|
+
* After escaping, the pattern will match the literal string.
|
|
379
|
+
*
|
|
380
|
+
* @param pattern - Pattern to escape
|
|
381
|
+
* @param options - Glob options (windowsPathsNoEscape affects escape style)
|
|
382
|
+
* @returns Escaped pattern
|
|
383
|
+
*/
|
|
384
|
+
export declare function escape(pattern: string, options?: GlobOptions): string;
|
|
385
|
+
/**
|
|
386
|
+
* Unescape magic glob characters in a pattern.
|
|
387
|
+
* This reverses the effect of `escape()`.
|
|
388
|
+
*
|
|
389
|
+
* @param pattern - Pattern to unescape
|
|
390
|
+
* @param options - Glob options (windowsPathsNoEscape affects unescape style)
|
|
391
|
+
* @returns Unescaped pattern
|
|
392
|
+
*/
|
|
393
|
+
export declare function unescape(pattern: string, options?: GlobOptions): string;
|
|
394
|
+
/**
|
|
395
|
+
* Analyze a pattern for potential issues and return warnings.
|
|
396
|
+
* This is useful for providing helpful feedback about common mistakes.
|
|
397
|
+
*
|
|
398
|
+
* @param pattern - The glob pattern to analyze
|
|
399
|
+
* @param options - Options affecting analysis (windowsPathsNoEscape, platform)
|
|
400
|
+
* @returns Array of warnings (empty if no issues detected)
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* import { analyzePattern } from 'globlin'
|
|
405
|
+
*
|
|
406
|
+
* // Check for trailing spaces
|
|
407
|
+
* const warnings = analyzePattern('*.txt ')
|
|
408
|
+
* // [{ warningType: 'trailing_spaces', suggestion: '*.txt', ... }]
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @remarks
|
|
412
|
+
* This function detects common mistakes such as:
|
|
413
|
+
* - Escaped wildcards at the start of patterns
|
|
414
|
+
* - Double-escaped characters
|
|
415
|
+
* - Backslash path separators on Windows without windowsPathsNoEscape
|
|
416
|
+
* - Performance issues (multiple globstars, redundant patterns)
|
|
417
|
+
* - Trailing spaces in patterns
|
|
418
|
+
* - Empty patterns
|
|
419
|
+
* - Null bytes in patterns
|
|
420
|
+
*/
|
|
421
|
+
export declare function analyzePattern(pattern: string, options?: GlobOptions): PatternWarningInfo[];
|
|
422
|
+
/**
|
|
423
|
+
* Analyze multiple patterns for potential issues and return all warnings.
|
|
424
|
+
*
|
|
425
|
+
* @param patterns - Array of glob patterns to analyze
|
|
426
|
+
* @param options - Options affecting analysis (windowsPathsNoEscape, platform)
|
|
427
|
+
* @returns Array of warnings for all patterns (empty if no issues detected)
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* import { analyzePatterns } from 'globlin'
|
|
432
|
+
*
|
|
433
|
+
* const warnings = analyzePatterns(['*.js', '*.txt '])
|
|
434
|
+
* // Returns warnings for escaped wildcard and performance issue
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
export declare function analyzePatterns(patterns: string[], options?: GlobOptions): PatternWarningInfo[];
|
|
438
|
+
/**
|
|
439
|
+
* Glob class for reusable glob operations
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* // Basic usage
|
|
444
|
+
* const g = new Glob('*.js', { cwd: '/path' })
|
|
445
|
+
* const files = g.walkSync()
|
|
446
|
+
*
|
|
447
|
+
* // Cache reuse - pass a Glob instance as options to reuse settings
|
|
448
|
+
* const g2 = new Glob('*.ts', g) // Reuses cwd, dot, nocase, etc. from g
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
export declare class Glob {
|
|
452
|
+
readonly pattern: string[];
|
|
453
|
+
readonly options: GlobOptions;
|
|
454
|
+
/**
|
|
455
|
+
* Create a new Glob instance.
|
|
456
|
+
*
|
|
457
|
+
* @param pattern - Glob pattern or array of patterns
|
|
458
|
+
* @param options - Glob options or a previous Glob instance to reuse settings
|
|
459
|
+
*
|
|
460
|
+
* When a Glob instance is passed as options, its settings (cwd, dot, nocase, etc.)
|
|
461
|
+
* are copied to the new instance. This allows for efficient reuse of settings
|
|
462
|
+
* when running multiple glob operations with similar configurations.
|
|
463
|
+
*/
|
|
464
|
+
constructor(pattern: string | string[], options?: GlobOptions | Glob);
|
|
465
|
+
walk(): Promise<string[]>;
|
|
466
|
+
walkSync(): string[];
|
|
467
|
+
stream(): Minipass<string, string>;
|
|
468
|
+
streamSync(): Minipass<string, string>;
|
|
469
|
+
iterate(): AsyncGenerator<string, void, void>;
|
|
470
|
+
iterateSync(): Generator<string, void, void>;
|
|
471
|
+
[Symbol.asyncIterator](): AsyncGenerator<string, void, void>;
|
|
472
|
+
[Symbol.iterator](): Generator<string, void, void>;
|
|
473
|
+
}
|
|
474
|
+
export default glob;
|
|
475
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8FAA8F;IAC9F,WAAW,EAAE,MAAM,CAAA;IACnB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAsCD;;GAEG;AACH,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;CACnB;AAuBD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE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