@@ -148,7 +148,7 @@ class Glob {
148
148
#root;
149
149
#exclude;
150
150
#cache = new Cache ( ) ;
151
- #results = [ ] ;
151
+ #results = new SafeSet ( ) ;
152
152
#queue = [ ] ;
153
153
#subpatterns = new SafeMap ( ) ;
154
154
constructor ( patterns , options = kEmptyObject ) {
@@ -193,7 +193,7 @@ class Glob {
193
193
. forEach ( ( patterns , path ) => ArrayPrototypePush ( this . #queue, { __proto__ : null , path, patterns } ) ) ;
194
194
this . #subpatterns. clear ( ) ;
195
195
}
196
- return this . #results;
196
+ return ArrayFrom ( this . #results) ;
197
197
}
198
198
#addSubpattern( path , pattern ) {
199
199
if ( ! this . #subpatterns. has ( path ) ) {
@@ -240,7 +240,7 @@ class Glob {
240
240
const p = pattern . at ( - 1 ) ;
241
241
const stat = this . #cache. statSync ( join ( fullpath , p ) ) ;
242
242
if ( stat && ( p || isDirectory ) ) {
243
- ArrayPrototypePush ( this . #results, join ( path , p ) ) ;
243
+ this . #results. add ( join ( path , p ) ) ;
244
244
}
245
245
if ( pattern . indexes . size === 1 && pattern . indexes . has ( last ) ) {
246
246
return ;
@@ -249,7 +249,7 @@ class Glob {
249
249
( path !== '.' || pattern . at ( 0 ) === '.' || ( last === 0 && stat ) ) ) {
250
250
// If pattern ends with **, add to results
251
251
// if path is ".", add it only if pattern starts with "." or pattern is exactly "**"
252
- ArrayPrototypePush ( this . #results, path ) ;
252
+ this . #results. add ( path ) ;
253
253
}
254
254
255
255
if ( ! isDirectory ) {
@@ -296,15 +296,15 @@ class Glob {
296
296
subPatterns . add ( index ) ;
297
297
} else if ( ! fromSymlink && index === last ) {
298
298
// If ** is last, add to results
299
- ArrayPrototypePush ( this . #results, entryPath ) ;
299
+ this . #results. add ( entryPath ) ;
300
300
}
301
301
302
302
// Any pattern after ** is also a potential pattern
303
303
// so we can already test it here
304
304
const nextMatches = pattern . test ( nextIndex , entry . name ) ;
305
305
if ( nextMatches && nextIndex === last && ! isLast ) {
306
306
// If next pattern is the last one, add to results
307
- ArrayPrototypePush ( this . #results, entryPath ) ;
307
+ this . #results. add ( entryPath ) ;
308
308
} else if ( nextMatches && entry . isDirectory ( ) ) {
309
309
// Pattern mached, meaning two patterns forward
310
310
// are also potential patterns
@@ -337,11 +337,11 @@ class Glob {
337
337
} else {
338
338
if ( ! this . #cache. seen ( path , pattern , nextIndex ) ) {
339
339
this . #cache. add ( path , pattern . child ( new SafeSet ( [ nextIndex ] ) ) ) ;
340
- ArrayPrototypePush ( this . #results, path ) ;
340
+ this . #results. add ( path ) ;
341
341
}
342
342
if ( ! this . #cache. seen ( path , pattern , nextIndex ) || ! this . #cache. seen ( parent , pattern , nextIndex ) ) {
343
343
this . #cache. add ( parent , pattern . child ( new SafeSet ( [ nextIndex ] ) ) ) ;
344
- ArrayPrototypePush ( this . #results, parent ) ;
344
+ this . #results. add ( parent ) ;
345
345
}
346
346
}
347
347
}
@@ -354,7 +354,7 @@ class Glob {
354
354
} else if ( current === '.' && pattern . test ( nextIndex , entry . name ) ) {
355
355
// If current pattern is ".", proceed to test next pattern
356
356
if ( nextIndex === last ) {
357
- ArrayPrototypePush ( this . #results, entryPath ) ;
357
+ this . #results. add ( entryPath ) ;
358
358
} else {
359
359
subPatterns . add ( nextIndex + 1 ) ;
360
360
}
@@ -364,7 +364,7 @@ class Glob {
364
364
// If current pattern is a regex that matches entry name (e.g *.js)
365
365
// add next pattern to potential patterns, or to results if it's the last pattern
366
366
if ( index === last ) {
367
- ArrayPrototypePush ( this . #results, entryPath ) ;
367
+ this . #results. add ( entryPath ) ;
368
368
} else if ( entry . isDirectory ( ) ) {
369
369
subPatterns . add ( nextIndex ) ;
370
370
}
0 commit comments