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/index.d.ts
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Path data returned by glob with withFileTypes: true.
|
|
8
|
+
* This struct is converted to PathScurry Path objects in the JavaScript wrapper.
|
|
9
|
+
*/
|
|
10
|
+
export interface PathData {
|
|
11
|
+
/** The path relative to cwd (or absolute if absolute option is set) */
|
|
12
|
+
path: string
|
|
13
|
+
/** True if this is a directory */
|
|
14
|
+
isDirectory: boolean
|
|
15
|
+
/** True if this is a file */
|
|
16
|
+
isFile: boolean
|
|
17
|
+
/** True if this is a symbolic link */
|
|
18
|
+
isSymlink: boolean
|
|
19
|
+
}
|
|
20
|
+
export declare function globSync(pattern: string | Array<string>, options?: GlobOptions | undefined | null): Array<string>
|
|
21
|
+
export declare function glob(pattern: string | Array<string>, options?: GlobOptions | undefined | null): Promise<Array<string>>
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous glob pattern matching with file type information.
|
|
24
|
+
* Returns PathData objects instead of strings.
|
|
25
|
+
*/
|
|
26
|
+
export declare function globSyncWithFileTypes(pattern: string | Array<string>, options?: GlobOptions | undefined | null): Array<PathData>
|
|
27
|
+
/**
|
|
28
|
+
* Asynchronous glob pattern matching with file type information.
|
|
29
|
+
* Returns PathData objects instead of strings.
|
|
30
|
+
*/
|
|
31
|
+
export declare function globWithFileTypes(pattern: string | Array<string>, options?: GlobOptions | undefined | null): Promise<Array<PathData>>
|
|
32
|
+
/**
|
|
33
|
+
* Streaming glob pattern matching.
|
|
34
|
+
* Streams results back to JavaScript via a callback function.
|
|
35
|
+
* This reduces peak memory usage for large result sets by not collecting all results before sending.
|
|
36
|
+
*
|
|
37
|
+
* @param pattern - Glob pattern or array of patterns
|
|
38
|
+
* @param options - Glob options
|
|
39
|
+
* @param callback - Function called with each result string
|
|
40
|
+
* @returns Promise that resolves when all results have been streamed
|
|
41
|
+
*/
|
|
42
|
+
export declare function globStream(pattern: string | Array<string>, options: GlobOptions | undefined | null, callback: (result: string) => void): void
|
|
43
|
+
/**
|
|
44
|
+
* Streaming glob pattern matching with file type information.
|
|
45
|
+
* Streams PathData results back to JavaScript via a callback function.
|
|
46
|
+
*
|
|
47
|
+
* @param pattern - Glob pattern or array of patterns
|
|
48
|
+
* @param options - Glob options
|
|
49
|
+
* @param callback - Function called with each PathData result
|
|
50
|
+
* @returns Promise that resolves when all results have been streamed
|
|
51
|
+
*/
|
|
52
|
+
export declare function globStreamWithFileTypes(pattern: string | Array<string>, options: GlobOptions | undefined | null, callback: (result: { path: string, isDirectory: boolean, isFile: boolean, isSymlink: boolean }) => void): void
|
|
53
|
+
/**
|
|
54
|
+
* Complete GlobOptions struct with all glob v13 options.
|
|
55
|
+
*
|
|
56
|
+
* All options are optional and false by default unless otherwise noted.
|
|
57
|
+
* This struct is designed to be 100% API-compatible with glob v13.0.0.
|
|
58
|
+
*/
|
|
59
|
+
export interface GlobOptions {
|
|
60
|
+
/**
|
|
61
|
+
* The current working directory in which to search.
|
|
62
|
+
* Defaults to `process.cwd()`.
|
|
63
|
+
*
|
|
64
|
+
* May be either a string path or a `file://` URL object or string.
|
|
65
|
+
* URL handling is done in the JavaScript wrapper.
|
|
66
|
+
*/
|
|
67
|
+
cwd?: string
|
|
68
|
+
/**
|
|
69
|
+
* A string path resolved against the `cwd` option, which is used as the
|
|
70
|
+
* starting point for absolute patterns that start with `/`.
|
|
71
|
+
*
|
|
72
|
+
* Note that this doesn't necessarily limit the walk to the `root` directory,
|
|
73
|
+
* and doesn't affect the cwd starting point for non-absolute patterns.
|
|
74
|
+
* A pattern containing `..` will still be able to traverse out of the root
|
|
75
|
+
* directory, if it is not an actual root directory on the filesystem.
|
|
76
|
+
*/
|
|
77
|
+
root?: string
|
|
78
|
+
/**
|
|
79
|
+
* Include `.dot` files in normal matches and `globstar` matches.
|
|
80
|
+
* Note that an explicit dot in a portion of the pattern will always match dot files.
|
|
81
|
+
*/
|
|
82
|
+
dot?: boolean
|
|
83
|
+
/** Do not expand `{a,b}` and `{1..3}` brace sets. */
|
|
84
|
+
nobrace?: boolean
|
|
85
|
+
/**
|
|
86
|
+
* Do not match `**` against multiple filenames.
|
|
87
|
+
* (Ie, treat it as a normal `*` instead.)
|
|
88
|
+
*
|
|
89
|
+
* Conflicts with `matchBase`.
|
|
90
|
+
*/
|
|
91
|
+
noglobstar?: boolean
|
|
92
|
+
/** Do not match "extglob" patterns such as `+(a|b)`. */
|
|
93
|
+
noext?: boolean
|
|
94
|
+
/**
|
|
95
|
+
* Perform a case-insensitive match.
|
|
96
|
+
*
|
|
97
|
+
* Defaults to `true` on macOS and Windows systems, and `false` on all others.
|
|
98
|
+
*
|
|
99
|
+
* **Note:** `nocase` should only be explicitly set when it is known that the
|
|
100
|
+
* filesystem's case sensitivity differs from the platform default.
|
|
101
|
+
*/
|
|
102
|
+
nocase?: boolean
|
|
103
|
+
/**
|
|
104
|
+
* Treat brace expansion like `{a,b}` as a "magic" pattern.
|
|
105
|
+
* Has no effect if `nobrace` is set.
|
|
106
|
+
*
|
|
107
|
+
* Only affects the `hasMagic` function.
|
|
108
|
+
*/
|
|
109
|
+
magicalBraces?: boolean
|
|
110
|
+
/**
|
|
111
|
+
* Follow symlinked directories when expanding `**` patterns.
|
|
112
|
+
* This can result in a lot of duplicate references in the presence of
|
|
113
|
+
* cyclic links, and make performance quite bad.
|
|
114
|
+
*
|
|
115
|
+
* By default, a `**` in a pattern will follow 1 symbolic link if it is not
|
|
116
|
+
* the first item in the pattern, or none if it is the first item in the
|
|
117
|
+
* pattern, following the same behavior as Bash.
|
|
118
|
+
*/
|
|
119
|
+
follow?: boolean
|
|
120
|
+
/**
|
|
121
|
+
* Limit the directory traversal to a given depth below the cwd.
|
|
122
|
+
*
|
|
123
|
+
* - `undefined`/`None`: No limit (traverse all levels)
|
|
124
|
+
* - `0`: Only the starting directory itself
|
|
125
|
+
* - `1`: Starting directory and immediate children
|
|
126
|
+
* - `n`: Up to n levels deep from the starting directory
|
|
127
|
+
*
|
|
128
|
+
* Negative values result in empty results.
|
|
129
|
+
* Note that this does NOT prevent traversal to sibling folders, root patterns,
|
|
130
|
+
* and so on. It only limits the maximum folder depth that the walk will descend.
|
|
131
|
+
*/
|
|
132
|
+
maxDepth?: number
|
|
133
|
+
/**
|
|
134
|
+
* Perform a basename-only match if the pattern does not contain any slash
|
|
135
|
+
* characters. That is, a pattern like "*.js" would be treated as equivalent
|
|
136
|
+
* to a recursive pattern matching all js files in all directories.
|
|
137
|
+
*
|
|
138
|
+
* Cannot be used with noglobstar: true.
|
|
139
|
+
*/
|
|
140
|
+
matchBase?: boolean
|
|
141
|
+
/**
|
|
142
|
+
* Set to `true` to always receive absolute paths for matched files.
|
|
143
|
+
* Set to `false` to always return relative paths.
|
|
144
|
+
*
|
|
145
|
+
* When this option is not set, absolute paths are returned for patterns
|
|
146
|
+
* that are absolute, and otherwise paths are returned that are relative
|
|
147
|
+
* to the `cwd` setting.
|
|
148
|
+
*
|
|
149
|
+
* This does _not_ make an extra system call to get the realpath, it only
|
|
150
|
+
* does string path resolution.
|
|
151
|
+
*
|
|
152
|
+
* Conflicts with `withFileTypes`.
|
|
153
|
+
*/
|
|
154
|
+
absolute?: boolean
|
|
155
|
+
/**
|
|
156
|
+
* Prepend all relative path strings with `./` (or `.\` on Windows).
|
|
157
|
+
*
|
|
158
|
+
* Without this option, returned relative paths are "bare", so instead of
|
|
159
|
+
* returning `'./foo/bar'`, they are returned as `'foo/bar'`.
|
|
160
|
+
*
|
|
161
|
+
* Relative patterns starting with `'../'` are not prepended with `./`,
|
|
162
|
+
* even if this option is set.
|
|
163
|
+
*/
|
|
164
|
+
dotRelative?: boolean
|
|
165
|
+
/**
|
|
166
|
+
* Add a `/` character to directory matches.
|
|
167
|
+
* Note that this requires additional stat calls in some cases.
|
|
168
|
+
*/
|
|
169
|
+
mark?: boolean
|
|
170
|
+
/**
|
|
171
|
+
* Do not match directories, only files.
|
|
172
|
+
* (Note: to match _only_ directories, put a `/` at the end of the pattern.)
|
|
173
|
+
*/
|
|
174
|
+
nodir?: boolean
|
|
175
|
+
/**
|
|
176
|
+
* Return `/` delimited paths, even on Windows.
|
|
177
|
+
*
|
|
178
|
+
* On posix systems, this has no effect. But, on Windows, it means that
|
|
179
|
+
* paths will be `/` delimited, and absolute paths will be their full
|
|
180
|
+
* resolved UNC forms, eg instead of `'C:\oo\ar'`, it would return
|
|
181
|
+
* `'//?/C:/foo/bar'`
|
|
182
|
+
*/
|
|
183
|
+
posix?: boolean
|
|
184
|
+
/**
|
|
185
|
+
* Return PathScurry `Path` objects instead of strings.
|
|
186
|
+
* These are similar to a NodeJS `Dirent` object, but with additional
|
|
187
|
+
* methods and properties.
|
|
188
|
+
*
|
|
189
|
+
* Conflicts with `absolute`.
|
|
190
|
+
*
|
|
191
|
+
* Note: In globlin, this is handled in the JavaScript wrapper which converts
|
|
192
|
+
* Rust results to PathScurry objects.
|
|
193
|
+
*/
|
|
194
|
+
withFileTypes?: boolean
|
|
195
|
+
/**
|
|
196
|
+
* Call `lstat()` on all entries, whether required or not to determine
|
|
197
|
+
* if it's a valid match. When used with `withFileTypes`, this means
|
|
198
|
+
* that matches will include data such as modified time, permissions, etc.
|
|
199
|
+
*
|
|
200
|
+
* Note that this will incur a performance cost due to the added system calls.
|
|
201
|
+
*/
|
|
202
|
+
stat?: boolean
|
|
203
|
+
/**
|
|
204
|
+
* Set to true to call `fs.realpath` on all of the results.
|
|
205
|
+
* In the case of an entry that cannot be resolved, the entry is omitted.
|
|
206
|
+
*
|
|
207
|
+
* This incurs a slight performance penalty due to the added system calls.
|
|
208
|
+
*/
|
|
209
|
+
realpath?: boolean
|
|
210
|
+
/**
|
|
211
|
+
* Patterns to exclude from matching.
|
|
212
|
+
* Can be a single pattern string or an array of patterns.
|
|
213
|
+
*
|
|
214
|
+
* If an object with `ignored(path)` and/or `childrenIgnored(path)` methods
|
|
215
|
+
* is provided, those methods will be called to determine whether any Path
|
|
216
|
+
* is a match or if its children should be traversed.
|
|
217
|
+
*
|
|
218
|
+
* **Note:** `ignore` patterns are _always_ in `dot:true` mode, regardless
|
|
219
|
+
* of any other settings.
|
|
220
|
+
*
|
|
221
|
+
* Patterns ending in `/**` will ignore the directory and all its children.
|
|
222
|
+
*/
|
|
223
|
+
ignore?: string | Array<string>
|
|
224
|
+
/**
|
|
225
|
+
* Do not match any children of any matches.
|
|
226
|
+
*
|
|
227
|
+
* For example, a recursive pattern would match "a/foo" but not "a/foo/b/foo"
|
|
228
|
+
* in this mode.
|
|
229
|
+
*
|
|
230
|
+
* This is especially useful for cases like "find all `node_modules` folders,
|
|
231
|
+
* but not the ones in `node_modules`".
|
|
232
|
+
*
|
|
233
|
+
* Defaults to `true`.
|
|
234
|
+
*/
|
|
235
|
+
includeChildMatches?: boolean
|
|
236
|
+
/**
|
|
237
|
+
* Defaults to value of `process.platform` if available, or `'linux'` if not.
|
|
238
|
+
*
|
|
239
|
+
* Setting `platform:'win32'` on non-Windows systems may cause strange behavior.
|
|
240
|
+
*/
|
|
241
|
+
platform?: string
|
|
242
|
+
/**
|
|
243
|
+
* Use `\\` as a path separator _only_, and _never_ as an escape character.
|
|
244
|
+
* If set, all `\\` characters are replaced with `/` in the pattern.
|
|
245
|
+
*
|
|
246
|
+
* Note that this makes it **impossible** to match against paths containing
|
|
247
|
+
* literal glob pattern characters, but allows matching with patterns
|
|
248
|
+
* constructed using `path.join()` and `path.resolve()` on Windows platforms.
|
|
249
|
+
*/
|
|
250
|
+
windowsPathsNoEscape?: boolean
|
|
251
|
+
/**
|
|
252
|
+
* Set to false to enable `windowsPathsNoEscape`.
|
|
253
|
+
*
|
|
254
|
+
* @deprecated Use `windowsPathsNoEscape` instead.
|
|
255
|
+
*/
|
|
256
|
+
allowWindowsEscape?: boolean
|
|
257
|
+
/**
|
|
258
|
+
* Enable parallel directory walking using multiple threads.
|
|
259
|
+
*
|
|
260
|
+
* When `true`, uses parallel traversal which can be faster on:
|
|
261
|
+
* - Spinning hard drives (HDDs)
|
|
262
|
+
* - Network filesystems (NFS, CIFS)
|
|
263
|
+
* - Very large directory trees
|
|
264
|
+
*
|
|
265
|
+
* When `false` (default), uses serial traversal which is:
|
|
266
|
+
* - Faster on SSDs for small to medium directories
|
|
267
|
+
* - Deterministic result ordering
|
|
268
|
+
* - Lower memory overhead
|
|
269
|
+
*
|
|
270
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
271
|
+
* Results may be returned in a different order when `parallel: true`.
|
|
272
|
+
*/
|
|
273
|
+
parallel?: boolean
|
|
274
|
+
/**
|
|
275
|
+
* Enable directory caching for repeated glob operations.
|
|
276
|
+
*
|
|
277
|
+
* When `true`, caches directory listings in memory with a TTL-based invalidation
|
|
278
|
+
* strategy. This provides significant speedup when:
|
|
279
|
+
* - Running multiple glob operations on the same directories
|
|
280
|
+
* - Using the Glob class with cache reuse (passing Glob as options)
|
|
281
|
+
* - Patterns with overlapping directory prefixes
|
|
282
|
+
*
|
|
283
|
+
* When `false` (default), directories are read fresh each time, which is:
|
|
284
|
+
* - More accurate if the filesystem is changing
|
|
285
|
+
* - Lower memory usage (no cached directory listings)
|
|
286
|
+
* - Slightly slower for repeated operations
|
|
287
|
+
*
|
|
288
|
+
* The cache has a 5-second TTL to balance freshness with performance.
|
|
289
|
+
* Use `cache: false` when you expect filesystem changes during the operation.
|
|
290
|
+
*
|
|
291
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
292
|
+
*/
|
|
293
|
+
cache?: boolean
|
|
294
|
+
/**
|
|
295
|
+
* Use optimized I/O operations on Linux (io_uring/getdents64).
|
|
296
|
+
*
|
|
297
|
+
* When `true` on Linux, uses platform-specific optimizations:
|
|
298
|
+
* - `getdents64` syscall for faster directory reading (bypasses libc overhead)
|
|
299
|
+
* - Batched I/O operations for reduced syscall overhead
|
|
300
|
+
* - Expected 1.3-2x speedup on directory-heavy workloads
|
|
301
|
+
*
|
|
302
|
+
* When `false` (default), uses the standard `walkdir` library which is:
|
|
303
|
+
* - Cross-platform compatible
|
|
304
|
+
* - Well-tested and stable
|
|
305
|
+
* - Sufficient for most use cases
|
|
306
|
+
*
|
|
307
|
+
* On non-Linux platforms, this option is ignored and the standard walker is used.
|
|
308
|
+
*
|
|
309
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
310
|
+
* Requires Linux kernel 5.1+ for full io_uring support.
|
|
311
|
+
*/
|
|
312
|
+
useNativeIO?: boolean
|
|
313
|
+
/**
|
|
314
|
+
* Use Grand Central Dispatch (GCD) for parallel walking on macOS.
|
|
315
|
+
*
|
|
316
|
+
* When `true` on macOS, uses Apple's Grand Central Dispatch framework for
|
|
317
|
+
* parallel directory traversal. This provides:
|
|
318
|
+
* - Native macOS scheduler integration
|
|
319
|
+
* - Automatic handling of efficiency vs performance cores on Apple Silicon
|
|
320
|
+
* - Better power management than generic thread pools
|
|
321
|
+
* - Lower overhead than rayon for I/O-bound workloads
|
|
322
|
+
*
|
|
323
|
+
* When `false` (default), uses the standard walker which is often faster
|
|
324
|
+
* on modern SSDs due to reduced coordination overhead.
|
|
325
|
+
*
|
|
326
|
+
* **When to use:**
|
|
327
|
+
* - Large directory trees (100k+ files) on Macs with many cores
|
|
328
|
+
* - Network filesystems where I/O latency dominates
|
|
329
|
+
* - When power efficiency matters (GCD respects system power state)
|
|
330
|
+
*
|
|
331
|
+
* **When NOT to use:**
|
|
332
|
+
* - Small to medium directories on SSD
|
|
333
|
+
* - When deterministic ordering is required
|
|
334
|
+
* - On non-macOS platforms (option is ignored)
|
|
335
|
+
*
|
|
336
|
+
* **Note:** This is a globlin-specific option not present in the original glob package.
|
|
337
|
+
*/
|
|
338
|
+
useGcd?: boolean
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Escape magic glob characters in a pattern.
|
|
342
|
+
* After escaping, the pattern will match literally (no globbing).
|
|
343
|
+
*
|
|
344
|
+
* @param pattern - The glob pattern to escape
|
|
345
|
+
* @param windowsPathsNoEscape - If true, use `[x]` wrapping instead of backslash escapes
|
|
346
|
+
* @returns The escaped pattern
|
|
347
|
+
*/
|
|
348
|
+
export declare function escape(pattern: string, windowsPathsNoEscape?: boolean | undefined | null): string
|
|
349
|
+
/**
|
|
350
|
+
* Unescape magic glob characters in a pattern.
|
|
351
|
+
* This reverses the effect of `escape()`.
|
|
352
|
+
*
|
|
353
|
+
* @param pattern - The escaped pattern to unescape
|
|
354
|
+
* @param windowsPathsNoEscape - If true, remove `[x]` wrapping instead of backslash escapes
|
|
355
|
+
* @returns The unescaped pattern
|
|
356
|
+
*/
|
|
357
|
+
export declare function unescape(pattern: string, windowsPathsNoEscape?: boolean | undefined | null): string
|
|
358
|
+
/**
|
|
359
|
+
* Check if a pattern contains any magic glob characters.
|
|
360
|
+
* Takes into account escaped characters.
|
|
361
|
+
*
|
|
362
|
+
* @param pattern - The glob pattern to check
|
|
363
|
+
* @param options - Options affecting magic detection
|
|
364
|
+
* @returns True if the pattern has magic (unescaped) glob characters
|
|
365
|
+
*/
|
|
366
|
+
export declare function hasMagic(pattern: string, noext?: boolean | undefined | null, windowsPathsNoEscape?: boolean | undefined | null): boolean
|
|
367
|
+
/**
|
|
368
|
+
* A pattern warning with message and optional suggestion.
|
|
369
|
+
* Used for providing helpful feedback about potential pattern issues.
|
|
370
|
+
*/
|
|
371
|
+
export interface PatternWarningInfo {
|
|
372
|
+
/** The type of warning (e.g., "escaped_wildcard", "performance", "empty") */
|
|
373
|
+
warningType: string
|
|
374
|
+
/** Human-readable warning message */
|
|
375
|
+
message: string
|
|
376
|
+
/** The original problematic pattern */
|
|
377
|
+
pattern?: string
|
|
378
|
+
/** Suggested fix (if applicable) */
|
|
379
|
+
suggestion?: string
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Analyze a pattern for potential issues and return warnings.
|
|
383
|
+
* This is useful for providing helpful feedback about common mistakes.
|
|
384
|
+
*
|
|
385
|
+
* @param pattern - The glob pattern to analyze
|
|
386
|
+
* @param windowsPathsNoEscape - Whether backslashes are path separators (Windows mode)
|
|
387
|
+
* @param platform - The target platform ("win32", "darwin", "linux")
|
|
388
|
+
* @returns Array of warnings (empty if no issues detected)
|
|
389
|
+
*/
|
|
390
|
+
export declare function analyzePattern(pattern: string, windowsPathsNoEscape?: boolean | undefined | null, platform?: string | undefined | null): Array<PatternWarningInfo>
|
|
391
|
+
/**
|
|
392
|
+
* Analyze multiple patterns for potential issues and return all warnings.
|
|
393
|
+
*
|
|
394
|
+
* @param patterns - Array of glob patterns to analyze
|
|
395
|
+
* @param windowsPathsNoEscape - Whether backslashes are path separators (Windows mode)
|
|
396
|
+
* @param platform - The target platform ("win32", "darwin", "linux")
|
|
397
|
+
* @returns Array of warnings for all patterns (empty if no issues detected)
|
|
398
|
+
*/
|
|
399
|
+
export declare function analyzePatterns(patterns: Array<string>, windowsPathsNoEscape?: boolean | undefined | null, platform?: string | undefined | null): Array<PatternWarningInfo>
|