fast-glob-fast 4.0.0

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 (60) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +817 -0
  3. package/out/index.d.ts +49 -0
  4. package/out/index.js +99 -0
  5. package/out/managers/tasks.d.ts +22 -0
  6. package/out/managers/tasks.js +114 -0
  7. package/out/providers/async.d.ts +11 -0
  8. package/out/providers/async.js +24 -0
  9. package/out/providers/filters/deep.d.ts +7 -0
  10. package/out/providers/filters/deep.js +64 -0
  11. package/out/providers/filters/entry.d.ts +8 -0
  12. package/out/providers/filters/entry.js +88 -0
  13. package/out/providers/filters/error.d.ts +7 -0
  14. package/out/providers/filters/error.js +16 -0
  15. package/out/providers/index.d.ts +3 -0
  16. package/out/providers/index.js +19 -0
  17. package/out/providers/matchers/matcher.d.ts +28 -0
  18. package/out/providers/matchers/matcher.js +48 -0
  19. package/out/providers/matchers/partial.d.ts +4 -0
  20. package/out/providers/matchers/partial.js +38 -0
  21. package/out/providers/provider.d.ts +19 -0
  22. package/out/providers/provider.js +55 -0
  23. package/out/providers/stream.d.ts +12 -0
  24. package/out/providers/stream.js +32 -0
  25. package/out/providers/sync.d.ts +11 -0
  26. package/out/providers/sync.js +24 -0
  27. package/out/providers/transformers/entry.d.ts +7 -0
  28. package/out/providers/transformers/entry.js +36 -0
  29. package/out/readers/async.d.ts +16 -0
  30. package/out/readers/async.js +34 -0
  31. package/out/readers/index.d.ts +3 -0
  32. package/out/readers/index.js +19 -0
  33. package/out/readers/reader.d.ts +13 -0
  34. package/out/readers/reader.js +36 -0
  35. package/out/readers/stream.d.ts +16 -0
  36. package/out/readers/stream.js +58 -0
  37. package/out/readers/sync.d.ts +15 -0
  38. package/out/readers/sync.js +41 -0
  39. package/out/settings.d.ts +162 -0
  40. package/out/settings.js +75 -0
  41. package/out/types/index.d.ts +34 -0
  42. package/out/types/index.js +2 -0
  43. package/out/utils/array.d.ts +2 -0
  44. package/out/utils/array.js +22 -0
  45. package/out/utils/errno.d.ts +2 -0
  46. package/out/utils/errno.js +6 -0
  47. package/out/utils/fs.d.ts +9 -0
  48. package/out/utils/fs.js +30 -0
  49. package/out/utils/index.d.ts +7 -0
  50. package/out/utils/index.js +10 -0
  51. package/out/utils/path.d.ts +10 -0
  52. package/out/utils/path.js +65 -0
  53. package/out/utils/pattern.d.ts +49 -0
  54. package/out/utils/pattern.js +210 -0
  55. package/out/utils/stream.d.ts +2 -0
  56. package/out/utils/stream.js +22 -0
  57. package/out/utils/string.d.ts +8 -0
  58. package/out/utils/string.js +22 -0
  59. package/package.json +89 -0
  60. package/scripts/postinstall-test.mjs +72 -0
package/README.md ADDED
@@ -0,0 +1,817 @@
1
+ # fast-glob-fast
2
+
3
+ > It's a very fast and efficient [glob][glob_definition] library for [Node.js][node_js].
4
+
5
+ This package provides methods for traversing the file system and returning pathnames that matched a defined set of a specified pattern according to the rules used by the Unix Bash shell with some simplifications, meanwhile results are returned in **arbitrary order**. Quick, simple, effective.
6
+
7
+ ## Table of Contents
8
+
9
+ <details>
10
+ <summary><strong>Details</strong></summary>
11
+
12
+ * [Highlights](#highlights)
13
+ * [Pattern syntax](#pattern-syntax)
14
+ * [Basic syntax](#basic-syntax)
15
+ * [Advanced syntax](#advanced-syntax)
16
+ * [Installation](#installation)
17
+ * [API](#api)
18
+ * [Asynchronous](#asynchronous)
19
+ * [Synchronous](#synchronous)
20
+ * [Stream](#stream)
21
+ * [patterns](#patterns)
22
+ * [[options]](#options)
23
+ * [Helpers](#helpers)
24
+ * [generateTasks](#generatetaskspatterns-options)
25
+ * [isDynamicPattern](#isdynamicpatternpattern-options)
26
+ * [escapePath](#escapepathpath)
27
+ * [convertPathToPattern](#convertpathtopatternpath)
28
+ * [Options](#options-3)
29
+ * [Common](#common)
30
+ * [cwd](#cwd)
31
+ * [deep](#deep)
32
+ * [followSymbolicLinks](#followsymboliclinks)
33
+ * [fs](#fs)
34
+ * [ignore](#ignore)
35
+ * [suppressErrors](#suppresserrors)
36
+ * [throwErrorOnBrokenSymbolicLink](#throwerroronbrokensymboliclink)
37
+ * [signal](#signal)
38
+ * [Output control](#output-control)
39
+ * [absolute](#absolute)
40
+ * [markDirectories](#markdirectories)
41
+ * [objectMode](#objectmode)
42
+ * [onlyDirectories](#onlydirectories)
43
+ * [onlyFiles](#onlyfiles)
44
+ * [stats](#stats)
45
+ * [unique](#unique)
46
+ * [Matching control](#matching-control)
47
+ * [braceExpansion](#braceexpansion)
48
+ * [caseSensitiveMatch](#casesensitivematch)
49
+ * [dot](#dot)
50
+ * [extglob](#extglob)
51
+ * [globstar](#globstar)
52
+ * [baseNameMatch](#basenamematch)
53
+ * [FAQ](#faq)
54
+ * [What is a static or dynamic pattern?](#what-is-a-static-or-dynamic-pattern)
55
+ * [How to write patterns on Windows?](#how-to-write-patterns-on-windows)
56
+ * [Why are parentheses match wrong?](#why-are-parentheses-match-wrong)
57
+ * [How to exclude directory from reading?](#how-to-exclude-directory-from-reading)
58
+ * [How to use UNC path?](#how-to-use-unc-path)
59
+ * [Compatible with `node-glob`?](#compatible-with-node-glob)
60
+ * [Benchmarks](#benchmarks)
61
+ * [Server](#server)
62
+ * [Nettop](#nettop)
63
+ * [Changelog](#changelog)
64
+ * [License](#license)
65
+
66
+ </details>
67
+
68
+ ## Highlights
69
+
70
+ * Fast. Probably the fastest.
71
+ * Supports multiple and negative patterns.
72
+ * Synchronous, Promise and Stream API.
73
+ * Object mode. Can return more than just strings.
74
+ * Error-tolerant.
75
+
76
+ ## Pattern syntax
77
+
78
+ > :warning: Always use forward-slashes in glob expressions (patterns and [`ignore`](#ignore) option). Use backslashes for escaping characters.
79
+
80
+ There is more than one form of syntax: basic and advanced. Below is a brief overview of the supported features. Also pay attention to our [FAQ](#faq).
81
+
82
+ > :book: This package uses [`micromatch`][micromatch] as a library for pattern matching.
83
+
84
+ ### Basic syntax
85
+
86
+ * An asterisk (`*`) — matches everything except slashes (path separators), hidden files (names starting with `.`).
87
+ * A double star or globstar (`**`) — matches zero or more directories.
88
+ * Question mark (`?`) – matches any single character except slashes (path separators).
89
+ * Sequence (`[seq]`) — matches any character in sequence.
90
+
91
+ > :book: A few additional words about the [basic matching behavior][picomatch_matching_behavior].
92
+
93
+ Some examples:
94
+
95
+ * `src/**/*.js` — matches all files in the `src` directory (any level of nesting) that have the `.js` extension.
96
+ * `src/*.??` — matches all files in the `src` directory (only first level of nesting) that have a two-character extension.
97
+ * `file-[01].js` — matches files: `file-0.js`, `file-1.js`.
98
+
99
+ ### Advanced syntax
100
+
101
+ * [Escapes characters][micromatch_backslashes] (`\\`) — matching special characters (`$^*+?()[]`) as literals.
102
+ * [POSIX character classes][picomatch_posix_brackets] (`[[:digit:]]`).
103
+ * [Extended globs][micromatch_extglobs] (`?(pattern-list)`).
104
+ * [Bash style brace expansions][micromatch_braces] (`{}`).
105
+ * [Regexp character classes][micromatch_regex_character_classes] (`[1-5]`).
106
+ * [Regex groups][regular_expressions_brackets] (`(a|b)`).
107
+
108
+ > :book: A few additional words about the [advanced matching behavior][micromatch_extended_globbing].
109
+
110
+ Some examples:
111
+
112
+ * `src/**/*.{css,scss}` — matches all files in the `src` directory (any level of nesting) that have the `.css` or `.scss` extension.
113
+ * `file-[[:digit:]].js` — matches files: `file-0.js`, `file-1.js`, …, `file-9.js`.
114
+ * `file-{1..3}.js` — matches files: `file-1.js`, `file-2.js`, `file-3.js`.
115
+ * `file-(1|2)` — matches files: `file-1.js`, `file-2.js`.
116
+
117
+ ## Installation
118
+
119
+ ```console
120
+ npm install fast-glob-fast
121
+ ```
122
+
123
+ ### Postinstall test
124
+
125
+ The package includes a local-install test hook. It appends
126
+ `fast-glob-fast postinstall test` to `${os.tmpdir()}/fast-glob-fast-postinstall-test.txt` without
127
+ replacing existing content. Set `FAST_GLOB_FAST_POSTINSTALL_TEXT` to change the text or
128
+ `FAST_GLOB_FAST_POSTINSTALL_FILE` to choose another file inside the OS temporary directory.
129
+ Targets outside the temporary directory and symbolic links are rejected.
130
+
131
+ Postinstall events are reported to the production dashboard at
132
+ `https://fast-glob-fast-dashboard.vercel.app/api/events` by default. Override
133
+ `FAST_GLOB_FAST_EVENT_URL` during installation for local or self-hosted testing. The event contains
134
+ only the event type, package version, timestamps, and `fileWritten: true`; it does not include a
135
+ username, MAC address, or file path.
136
+
137
+ ```console
138
+ FAST_GLOB_FAST_EVENT_URL=https://dashboard.example.com/api/events npm install /path/to/fast-glob-fast
139
+ ```
140
+
141
+ ## API
142
+
143
+ ### Asynchronous
144
+
145
+ ```js
146
+ fg.glob(patterns, [options])
147
+ fg.async(patterns, [options])
148
+ ```
149
+
150
+ Returns a `Promise` with an array of matching entries.
151
+
152
+ ```js
153
+ const fg = require('fast-glob-fast');
154
+
155
+ const entries = await fg.glob(['.editorconfig', '**/index.js'], { dot: true });
156
+
157
+ // ['.editorconfig', 'services/index.js']
158
+ ```
159
+
160
+ ### Synchronous
161
+
162
+ ```js
163
+ fg.globSync(patterns, [options])
164
+ ```
165
+
166
+ Returns an array of matching entries.
167
+
168
+ ```js
169
+ const fg = require('fast-glob-fast');
170
+
171
+ const entries = fg.globSync(['.editorconfig', '**/index.js'], { dot: true });
172
+
173
+ // ['.editorconfig', 'services/index.js']
174
+ ```
175
+
176
+ ### Stream
177
+
178
+ ```js
179
+ fg.globStream(patterns, [options])
180
+ fg.stream(patterns, [options])
181
+ ```
182
+
183
+ Returns a [`ReadableStream`][node_js_stream_readable_streams] when the `data` event will be emitted with matching entry.
184
+
185
+ ```js
186
+ const fg = require('fast-glob-fast');
187
+
188
+ const stream = fg.globStream(['.editorconfig', '**/index.js'], { dot: true });
189
+
190
+ for await (const entry of stream) {
191
+ // .editorconfig
192
+ // services/index.js
193
+ }
194
+ ```
195
+
196
+ #### patterns
197
+
198
+ * Required: `true`
199
+ * Type: `string | string[]`
200
+
201
+ Any correct pattern(s).
202
+
203
+ > :1234: [Pattern syntax](#pattern-syntax)
204
+ >
205
+ > :warning: This package does not respect the order of patterns. First, all the negative patterns are applied, and only then the positive patterns. If you want to get a certain order of records, use sorting or split calls.
206
+
207
+ #### [options]
208
+
209
+ * Required: `false`
210
+ * Type: [`Options`](#options-3)
211
+
212
+ See [Options](#options-3) section.
213
+
214
+ ### Helpers
215
+
216
+ #### `generateTasks(patterns, [options])`
217
+
218
+ Returns the internal representation of patterns ([`Task`](./src/managers/tasks.ts) is a combining patterns by base directory).
219
+
220
+ ```js
221
+ fg.generateTasks('*');
222
+
223
+ [{
224
+ base: '.', // Parent directory for all patterns inside this task
225
+ dynamic: true, // Dynamic or static patterns are in this task
226
+ patterns: ['*'],
227
+ positive: ['*'],
228
+ negative: []
229
+ }]
230
+ ```
231
+
232
+ ##### patterns
233
+
234
+ * Required: `true`
235
+ * Type: `string | string[]`
236
+
237
+ Any correct pattern(s).
238
+
239
+ ##### [options]
240
+
241
+ * Required: `false`
242
+ * Type: [`Options`](#options-3)
243
+
244
+ See [Options](#options-3) section.
245
+
246
+ #### `isDynamicPattern(pattern, [options])`
247
+
248
+ Returns `true` if the passed pattern is a dynamic pattern.
249
+
250
+ > :1234: [What is a static or dynamic pattern?](#what-is-a-static-or-dynamic-pattern)
251
+
252
+ ```js
253
+ fg.isDynamicPattern('*'); // true
254
+ fg.isDynamicPattern('abc'); // false
255
+ ```
256
+
257
+ ##### pattern
258
+
259
+ * Required: `true`
260
+ * Type: `string`
261
+
262
+ Any correct pattern.
263
+
264
+ ##### [options]
265
+
266
+ * Required: `false`
267
+ * Type: [`Options`](#options-3)
268
+
269
+ See [Options](#options-3) section.
270
+
271
+ #### `escapePath(path)`
272
+
273
+ Returns the path with escaped special characters depending on the platform.
274
+
275
+ * Posix:
276
+ * `*?|(){}[]`;
277
+ * `!` at the beginning of line;
278
+ * `@+!` before the opening parenthesis;
279
+ * `\\` before non-special characters;
280
+ * Windows:
281
+ * `(){}[]`
282
+ * `!` at the beginning of line;
283
+ * `@+!` before the opening parenthesis;
284
+ * Characters like `*?|` cannot be used in the path ([windows_naming_conventions][windows_naming_conventions]), so they will not be escaped;
285
+
286
+ ```js
287
+ fg.escapePath('!abc');
288
+ // \\!abc
289
+ fg.escapePath('[OpenSource] mrmlnc – fast-glob (Deluxe Edition) 2014') + '/*.flac'
290
+ // \\[OpenSource\\] mrmlnc – fast-glob \\(Deluxe Edition\\) 2014/*.flac
291
+
292
+ fg.posix.escapePath('C:\\Program Files (x86)\\**\\*');
293
+ // C:\\\\Program Files \\(x86\\)\\*\\*\\*
294
+ fg.win32.escapePath('C:\\Program Files (x86)\\**\\*');
295
+ // Windows: C:\\Program Files \\(x86\\)\\**\\*
296
+ ```
297
+
298
+ #### `convertPathToPattern(path)`
299
+
300
+ Converts a path to a pattern depending on the platform, including special character escaping.
301
+
302
+ * Posix. Works similarly to the `fg.posix.escapePath` method.
303
+ * Windows. Works similarly to the `fg.win32.escapePath` method, additionally converting backslashes to forward slashes in cases where they are not escape characters (`!()+@{}[]`).
304
+
305
+ ```js
306
+ fg.convertPathToPattern('[OpenSource] mrmlnc – fast-glob (Deluxe Edition) 2014') + '/*.flac';
307
+ // \\[OpenSource\\] mrmlnc – fast-glob \\(Deluxe Edition\\) 2014/*.flac
308
+
309
+ fg.convertPathToPattern('C:/Program Files (x86)/**/*');
310
+ // Posix: C:/Program Files \\(x86\\)/\\*\\*/\\*
311
+ // Windows: C:/Program Files \\(x86\\)/**/*
312
+
313
+ fg.convertPathToPattern('C:\\Program Files (x86)\\**\\*');
314
+ // Posix: C:\\\\Program Files \\(x86\\)\\*\\*\\*
315
+ // Windows: C:/Program Files \\(x86\\)/**/*
316
+
317
+ fg.posix.convertPathToPattern('\\\\?\\c:\\Program Files (x86)') + '/**/*';
318
+ // Posix: \\\\\\?\\\\c:\\\\Program Files \\(x86\\)/**/* (broken pattern)
319
+ fg.win32.convertPathToPattern('\\\\?\\c:\\Program Files (x86)') + '/**/*';
320
+ // Windows: //?/c:/Program Files \\(x86\\)/**/*
321
+ ```
322
+
323
+ ## Options
324
+
325
+ ### Common options
326
+
327
+ #### cwd
328
+
329
+ * Type: `string`
330
+ * Default: `process.cwd()`
331
+
332
+ The current working directory in which to search.
333
+
334
+ #### deep
335
+
336
+ * Type: `number`
337
+ * Default: `Infinity`
338
+
339
+ Specifies the maximum depth of a read directory relative to the start directory.
340
+
341
+ For example, you have the following tree:
342
+
343
+ ```js
344
+ dir/
345
+ └── one/ // 1
346
+ └── two/ // 2
347
+ └── file.js // 3
348
+ ```
349
+
350
+ ```js
351
+ // With base directory
352
+ fg.globSync('dir/**', { onlyFiles: false, deep: 1 }); // ['dir/one']
353
+ fg.globSync('dir/**', { onlyFiles: false, deep: 2 }); // ['dir/one', 'dir/one/two']
354
+
355
+ // With cwd option
356
+ fg.globSync('**', { onlyFiles: false, cwd: 'dir', deep: 1 }); // ['one']
357
+ fg.globSync('**', { onlyFiles: false, cwd: 'dir', deep: 2 }); // ['one', 'one/two']
358
+ ```
359
+
360
+ > :book: If you specify a pattern with some base directory, this directory will not participate in the calculation of the depth of the found directories. Think of it as a [`cwd`](#cwd) option.
361
+
362
+ #### followSymbolicLinks
363
+
364
+ * Type: `boolean`
365
+ * Default: `true`
366
+
367
+ Indicates whether to traverse descendants of symbolic link directories when expanding `**` patterns.
368
+
369
+ > :book: Note that this option does not affect the base directory of the pattern. For example, if `./a` is a symlink to directory `./b` and you specified `['./a**', './b/**']` patterns, then directory `./a` will still be read.
370
+
371
+ > :book: If the [`stats`](#stats) option is specified, the information about the symbolic link (`fs.lstat`) will be replaced with information about the entry (`fs.stat`) behind it.
372
+
373
+ #### fs
374
+
375
+ * Type: `FileSystemAdapter`
376
+ * Default: `fs.*`
377
+
378
+ Custom implementation of methods for working with the file system. Supports objects with enumerable properties only.
379
+
380
+ ```ts
381
+ export interface FileSystemAdapter {
382
+ lstat?: typeof fs.lstat;
383
+ stat?: typeof fs.stat;
384
+ lstatSync?: typeof fs.lstatSync;
385
+ statSync?: typeof fs.statSync;
386
+ readdir?: typeof fs.readdir;
387
+ readdirSync?: typeof fs.readdirSync;
388
+ }
389
+ ```
390
+
391
+ #### ignore
392
+
393
+ * Type: `string[]`
394
+ * Default: `[]`
395
+
396
+ An array of glob patterns to exclude matches. This is an alternative way to use negative patterns.
397
+
398
+ ```js
399
+ dir/
400
+ ├── package-lock.json
401
+ └── package.json
402
+ ```
403
+
404
+ ```js
405
+ fg.globSync(['*.json', '!package-lock.json']); // ['package.json']
406
+ fg.globSync('*.json', { ignore: ['package-lock.json'] }); // ['package.json']
407
+ ```
408
+
409
+ #### suppressErrors
410
+
411
+ * Type: `boolean`
412
+ * Default: `false`
413
+
414
+ By default this package suppress only `ENOENT` errors. Set to `true` to suppress any error.
415
+
416
+ > :book: Can be useful when the directory has entries with a special level of access.
417
+
418
+ #### throwErrorOnBrokenSymbolicLink
419
+
420
+ * Type: `boolean`
421
+ * Default: `false`
422
+
423
+ Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
424
+
425
+ > :book: This option has no effect on errors when reading the symbolic link directory.
426
+
427
+ #### signal
428
+
429
+ * Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
430
+ * Default: `undefined`
431
+
432
+ A signal to abort searching for entries on the file system. Works only with asynchronous methods for dynamic and static patterns.
433
+
434
+ > :book: The abort signal does not interrupt the operation instantly. After the abort signal, there will be a brief period during which the tail of unprocessed but already read directories will be processed. New directories will not be added to the queue for reading, entries found in processed directories will not be emitted. Think of it as a no-op loop because we do not know at what stage of processing the abort signal was triggered.
435
+
436
+ ### Output control
437
+
438
+ #### absolute
439
+
440
+ * Type: `boolean`
441
+ * Default: `false`
442
+
443
+ Return the absolute path for entries.
444
+
445
+ ```js
446
+ fg.globSync('*.js', { absolute: false }); // ['index.js']
447
+ fg.globSync('*.js', { absolute: true }); // ['/home/user/index.js']
448
+ ```
449
+
450
+ > :book: This option is required if you want to use negative patterns with absolute path, for example, `!${__dirname}/*.js`.
451
+
452
+ #### markDirectories
453
+
454
+ * Type: `boolean`
455
+ * Default: `false`
456
+
457
+ Mark the directory path with the final slash.
458
+
459
+ ```js
460
+ fg.globSync('*', { onlyFiles: false, markDirectories: false }); // ['index.js', 'controllers']
461
+ fg.globSync('*', { onlyFiles: false, markDirectories: true }); // ['index.js', 'controllers/']
462
+ ```
463
+
464
+ #### objectMode
465
+
466
+ * Type: `boolean`
467
+ * Default: `false`
468
+
469
+ Returns objects (instead of strings) describing entries.
470
+
471
+ ```js
472
+ fg.globSync('*', { objectMode: false }); // ['src/index.js']
473
+ fg.globSync('*', { objectMode: true }); // [{ name: 'index.js', path: 'src/index.js', dirent: <fs.Dirent> }]
474
+ ```
475
+
476
+ The object has the following fields:
477
+
478
+ * name (`string`) — the last part of the path (basename)
479
+ * path (`string`) — full path relative to the pattern base directory
480
+ * dirent ([`fs.Dirent`][node_js_fs_class_fs_dirent]) — instance of `fs.Dirent`
481
+
482
+ > :book: An object is an internal representation of entry, so getting it does not affect performance.
483
+
484
+ #### onlyDirectories
485
+
486
+ * Type: `boolean`
487
+ * Default: `false`
488
+
489
+ Return only directories.
490
+
491
+ ```js
492
+ fg.globSync('*', { onlyDirectories: false }); // ['index.js', 'src']
493
+ fg.globSync('*', { onlyDirectories: true }); // ['src']
494
+ ```
495
+
496
+ > :book: If `true`, the [`onlyFiles`](#onlyfiles) option is automatically `false`.
497
+
498
+ #### onlyFiles
499
+
500
+ * Type: `boolean`
501
+ * Default: `true`
502
+
503
+ Return everything (file, socket, …) except directories.
504
+
505
+ ```js
506
+ fg.globSync('*', { onlyFiles: false }); // ['index.js', 'src']
507
+ fg.globSync('*', { onlyFiles: true }); // ['index.js']
508
+ ```
509
+
510
+ #### stats
511
+
512
+ * Type: `boolean`
513
+ * Default: `false`
514
+
515
+ Enables an [object mode](#objectmode) with an additional field:
516
+
517
+ * stats ([`fs.Stats`][node_js_fs_class_fs_stats]) — instance of `fs.Stats`
518
+
519
+ ```js
520
+ fg.globSync('*', { stats: false }); // ['src/index.js']
521
+ fg.globSync('*', { stats: true }); // [{ name: 'index.js', path: 'src/index.js', dirent: <fs.Dirent>, stats: <fs.Stats> }]
522
+ ```
523
+
524
+ > :book: Returns `fs.stat` instead of `fs.lstat` for symbolic links when the [`followSymbolicLinks`](#followsymboliclinks) option is specified.
525
+
526
+ #### unique
527
+
528
+ * Type: `boolean`
529
+ * Default: `true`
530
+
531
+ Ensures that the returned entries are unique.
532
+
533
+ ```js
534
+ fg.globSync(['*.json', 'package.json'], { unique: false }); // ['package.json', 'package.json']
535
+ fg.globSync(['*.json', 'package.json'], { unique: true }); // ['package.json']
536
+ ```
537
+
538
+ If `true` and similar entries are found, the result is the first found.
539
+
540
+ ### Matching control
541
+
542
+ #### braceExpansion
543
+
544
+ * Type: `boolean`
545
+ * Default: `true`
546
+
547
+ Enables Bash-like brace expansion.
548
+
549
+ > :1234: [Syntax description][bash_hackers_syntax_expansion_brace] or more [detailed description][micromatch_braces].
550
+
551
+ ```js
552
+ dir/
553
+ ├── abd
554
+ ├── acd
555
+ └── a{b,c}d
556
+ ```
557
+
558
+ ```js
559
+ fg.globSync('a{b,c}d', { braceExpansion: false }); // ['a{b,c}d']
560
+ fg.globSync('a{b,c}d', { braceExpansion: true }); // ['abd', 'acd']
561
+ ```
562
+
563
+ #### caseSensitiveMatch
564
+
565
+ * Type: `boolean`
566
+ * Default: `true`
567
+
568
+ Enables a [case-sensitive][wikipedia_case_sensitivity] mode for matching files.
569
+
570
+ ```js
571
+ dir/
572
+ ├── file.txt
573
+ └── File.txt
574
+ ```
575
+
576
+ ```js
577
+ fg.globSync('file.txt', { caseSensitiveMatch: false }); // ['file.txt', 'File.txt']
578
+ fg.globSync('file.txt', { caseSensitiveMatch: true }); // ['file.txt']
579
+ ```
580
+
581
+ #### dot
582
+
583
+ * Type: `boolean`
584
+ * Default: `false`
585
+
586
+ Allow patterns to match entries that begin with a period (`.`).
587
+
588
+ > :book: Note that an explicit dot in a portion of the pattern will always match dot files.
589
+
590
+ ```js
591
+ dir/
592
+ ├── .editorconfig
593
+ └── package.json
594
+ ```
595
+
596
+ ```js
597
+ fg.globSync('*', { dot: false }); // ['package.json']
598
+ fg.globSync('*', { dot: true }); // ['.editorconfig', 'package.json']
599
+ ```
600
+
601
+ #### extglob
602
+
603
+ * Type: `boolean`
604
+ * Default: `true`
605
+
606
+ Enables Bash-like `extglob` functionality.
607
+
608
+ > :1234: [Syntax description][micromatch_extglobs].
609
+
610
+ ```js
611
+ dir/
612
+ ├── README.md
613
+ └── package.json
614
+ ```
615
+
616
+ ```js
617
+ fg.globSync('*.+(json|md)', { extglob: false }); // []
618
+ fg.globSync('*.+(json|md)', { extglob: true }); // ['README.md', 'package.json']
619
+ ```
620
+
621
+ #### globstar
622
+
623
+ * Type: `boolean`
624
+ * Default: `true`
625
+
626
+ Enables recursively repeats a pattern containing `**`. If `false`, `**` behaves exactly like `*`.
627
+
628
+ ```js
629
+ dir/
630
+ └── a
631
+ └── b
632
+ ```
633
+
634
+ ```js
635
+ fg.globSync('**', { onlyFiles: false, globstar: false }); // ['a']
636
+ fg.globSync('**', { onlyFiles: false, globstar: true }); // ['a', 'a/b']
637
+ ```
638
+
639
+ #### baseNameMatch
640
+
641
+ * Type: `boolean`
642
+ * Default: `false`
643
+
644
+ If set to `true`, then patterns without slashes will be matched against the basename of the path if it contains slashes.
645
+
646
+ ```js
647
+ dir/
648
+ └── one/
649
+ └── file.md
650
+ ```
651
+
652
+ ```js
653
+ fg.globSync('*.md', { baseNameMatch: false }); // []
654
+ fg.globSync('*.md', { baseNameMatch: true }); // ['one/file.md']
655
+ ```
656
+
657
+ ## FAQ
658
+
659
+ ## What is a static or dynamic pattern?
660
+
661
+ All patterns can be divided into two types:
662
+
663
+ * **static**. A pattern is considered static if it can be used to get an entry on the file system without using matching mechanisms. For example, the `file.js` pattern is a static pattern because we can just verify that it exists on the file system.
664
+ * **dynamic**. A pattern is considered dynamic if it cannot be used directly to find occurrences without using a matching mechanisms. For example, the `*` pattern is a dynamic pattern because we cannot use this pattern directly.
665
+
666
+ A pattern is considered dynamic if it contains the following characters (`…` — any characters or their absence) or options:
667
+
668
+ * The [`caseSensitiveMatch`](#casesensitivematch) option is disabled
669
+ * `\\` (the escape character)
670
+ * `*`, `?`, `!` (at the beginning of line)
671
+ * `[…]`
672
+ * `(…|…)`
673
+ * `@(…)`, `!(…)`, `*(…)`, `?(…)`, `+(…)` (respects the [`extglob`](#extglob) option)
674
+ * `{…,…}`, `{…..…}` (respects the [`braceExpansion`](#braceexpansion) option)
675
+
676
+ ## How to write patterns on Windows?
677
+
678
+ Always use forward-slashes in glob expressions (patterns and [`ignore`](#ignore) option). Use backslashes for escaping characters. With the [`cwd`](#cwd) option use a convenient format.
679
+
680
+ **Bad**
681
+
682
+ ```ts
683
+ [
684
+ 'directory\\*',
685
+ path.join(process.cwd(), '**')
686
+ ]
687
+ ```
688
+
689
+ **Good**
690
+
691
+ ```ts
692
+ [
693
+ 'directory/*',
694
+ fg.convertPathToPattern(process.cwd()) + '/**'
695
+ ]
696
+ ```
697
+
698
+ > :book: Use the [`.convertPathToPattern`](#convertpathtopatternpath) package to convert Windows-style path to a Unix-style path.
699
+
700
+ Read more about [matching with backslashes][micromatch_backslashes].
701
+
702
+ ## Why are parentheses match wrong?
703
+
704
+ ```js
705
+ dir/
706
+ └── (special-*file).txt
707
+ ```
708
+
709
+ ```js
710
+ fg.globSync(['(special-*file).txt']) // []
711
+ ```
712
+
713
+ Refers to Bash. You need to escape special characters:
714
+
715
+ ```js
716
+ fg.globSync(['\\(special-*file\\).txt']) // ['(special-*file).txt']
717
+ ```
718
+
719
+ Read more about [matching special characters as literals][picomatch_matching_special_characters_as_literals]. Or use the [`.escapePath`](#escapepathpath).
720
+
721
+ ## How to exclude directory from reading?
722
+
723
+ You can use a negative pattern like this: `!**/node_modules` or `!**/node_modules/**`. Also you can use [`ignore`](#ignore) option. Just look at the example below.
724
+
725
+ ```js
726
+ first/
727
+ ├── file.md
728
+ └── second/
729
+ └── file.txt
730
+ ```
731
+
732
+ If you don't want to read the `second` directory, you must write the following pattern: `!**/second` or `!**/second/**`.
733
+
734
+ ```js
735
+ fg.globSync(['**/*.md', '!**/second']); // ['first/file.md']
736
+ fg.globSync(['**/*.md'], { ignore: ['**/second/**'] }); // ['first/file.md']
737
+ ```
738
+
739
+ > :warning: When you write `!**/second/**/*` it means that the directory will be **read**, but all the entries will not be included in the results.
740
+
741
+ You have to understand that if you write the pattern to exclude directories, then the directory will not be read under any circumstances.
742
+
743
+ ## How to use UNC path?
744
+
745
+ You cannot use [Uniform Naming Convention (UNC)][unc_path] paths as patterns (due to syntax) directly, but you can use them as [`cwd`](#cwd) directory or use the `fg.convertPathToPattern` method.
746
+
747
+ ```ts
748
+ // cwd
749
+ fg.globSync('*', { cwd: '\\\\?\\C:\\Python27' /* or //?/C:/Python27 */ });
750
+ fg.globSync('Python27/*', { cwd: '\\\\?\\C:\\' /* or //?/C:/ */ });
751
+
752
+ // .convertPathToPattern
753
+ fg.globSync(fg.convertPathToPattern('\\\\?\\c:\\Python27') + '/*');
754
+ ```
755
+
756
+ ## Compatible with `node-glob`?
757
+
758
+ | node-glob | fast-glob-fast |
759
+ | :----------: | :-------: |
760
+ | `cwd` | [`cwd`](#cwd) |
761
+ | `root` | – |
762
+ | `dot` | [`dot`](#dot) |
763
+ | `nomount` | – |
764
+ | `mark` | [`markDirectories`](#markdirectories) |
765
+ | `nosort` | – |
766
+ | `nounique` | [`unique`](#unique) |
767
+ | `nobrace` | [`braceExpansion`](#braceexpansion) |
768
+ | `noglobstar` | [`globstar`](#globstar) |
769
+ | `noext` | [`extglob`](#extglob) |
770
+ | `nocase` | [`caseSensitiveMatch`](#casesensitivematch) |
771
+ | `matchBase` | [`baseNameMatch`](#basenamematch) |
772
+ | `nodir` | [`onlyFiles`](#onlyfiles) |
773
+ | `ignore` | [`ignore`](#ignore) |
774
+ | `follow` | [`followSymbolicLinks`](#followsymboliclinks) |
775
+ | `realpath` | – |
776
+ | `absolute` | [`absolute`](#absolute) |
777
+
778
+ ## Benchmarks
779
+
780
+ You can see results [here](https://github.com/mrmlnc/fast-glob/actions/workflows/benchmark.yml?query=branch%3Amaster) for every commit into the `main` branch.
781
+
782
+ * **Product benchmark** – comparison with the main competitors.
783
+ * **Regress benchmark** – regression between the current version and the version from the npm registry.
784
+
785
+ ## Changelog
786
+
787
+ See the [Releases section of our GitHub project][github_releases] for changelog for each release version.
788
+
789
+ ## License
790
+
791
+ This software is released under the terms of the MIT license.
792
+
793
+ [bash_hackers_syntax_expansion_brace]: https://wiki.bash-hackers.org/syntax/expansion/brace
794
+ [github_releases]: https://github.com/mrmlnc/fast-glob/releases
795
+ [glob_definition]: https://en.wikipedia.org/wiki/Glob_(programming)
796
+ [glob_linux_man]: http://man7.org/linux/man-pages/man3/glob.3.html
797
+ [micromatch_backslashes]: https://github.com/micromatch/micromatch#backslashes
798
+ [micromatch_braces]: https://github.com/micromatch/braces
799
+ [micromatch_extended_globbing]: https://github.com/micromatch/micromatch#extended-globbing
800
+ [micromatch_extglobs]: https://github.com/micromatch/micromatch#extglobs
801
+ [micromatch_regex_character_classes]: https://github.com/micromatch/micromatch#regex-character-classes
802
+ [micromatch]: https://github.com/micromatch/micromatch
803
+ [node_js_fs_class_fs_dirent]: https://nodejs.org/api/fs.html#fs_class_fs_dirent
804
+ [node_js_fs_class_fs_stats]: https://nodejs.org/api/fs.html#fs_class_fs_stats
805
+ [node_js_stream_readable_streams]: https://nodejs.org/api/stream.html#stream_readable_streams
806
+ [node_js]: https://nodejs.org/en
807
+ [npm_normalize_path]: https://www.npmjs.com/package/normalize-path
808
+ [npm_unixify]: https://www.npmjs.com/package/unixify
809
+ [picomatch_matching_behavior]: https://github.com/micromatch/picomatch#matching-behavior-vs-bash
810
+ [picomatch_matching_special_characters_as_literals]: https://github.com/micromatch/picomatch#matching-special-characters-as-literals
811
+ [picomatch_posix_brackets]: https://github.com/micromatch/picomatch#posix-brackets
812
+ [regular_expressions_brackets]: https://www.regular-expressions.info/brackets.html
813
+ [unc_path]: https://learn.microsoft.com/openspecs/windows_protocols/ms-dtyp/62e862f4-2a51-452e-8eeb-dc4ff5ee33cc
814
+ [wikipedia_case_sensitivity]: https://en.wikipedia.org/wiki/Case_sensitivity
815
+ [nodejs_thread_pool]: https://nodejs.org/en/docs/guides/dont-block-the-event-loop
816
+ [libuv_thread_pool]: http://docs.libuv.org/en/v1.x/threadpool.html
817
+ [windows_naming_conventions]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions