@@ -44,7 +44,7 @@ class Cache {
4444 #statsCache = new SafeMap ( ) ;
4545 #readdirCache = new SafeMap ( ) ;
4646
47- stats ( path ) {
47+ statSync ( path ) {
4848 if ( this . #statsCache. has ( path ) ) {
4949 return this . #statsCache. get ( path ) ;
5050 }
@@ -57,13 +57,13 @@ class Cache {
5757 this . #statsCache. set ( path , val ) ;
5858 return val ;
5959 }
60- readdir ( path ) {
60+ readdirSync ( path ) {
6161 if ( this . #readdirCache. has ( path ) ) {
6262 return this . #readdirCache. get ( path ) ;
6363 }
6464 let val ;
6565 try {
66- val = readdirSync ( path , { withFileTypes : true } ) ;
66+ val = readdirSync ( path , { __proto__ : null , withFileTypes : true } ) ;
6767 ArrayPrototypeForEach ( val , ( dirent ) => this . #statsCache. set ( join ( path , dirent . name ) , dirent ) ) ;
6868 } catch {
6969 val = [ ] ;
@@ -87,7 +87,7 @@ class Cache {
8787
8888}
8989
90- function glob ( patterns , options = kEmptyObject ) {
90+ function globSync ( patterns , options = kEmptyObject ) {
9191 validateObject ( options , 'options' ) ;
9292 const root = options . cwd ?? '.' ;
9393 const { exclude } = options ;
@@ -123,7 +123,7 @@ function glob(patterns, options = kEmptyObject) {
123123
124124 if ( typeof currentPattern === 'string' ) {
125125 const entryPath = join ( path , currentPattern ) ;
126- if ( isLast && cache . stats ( resolve ( root , entryPath ) ) ) {
126+ if ( isLast && cache . statSync ( resolve ( root , entryPath ) ) ) {
127127 // last path
128128 results . add ( entryPath ) ;
129129 } else if ( ! isLast ) {
@@ -134,11 +134,11 @@ function glob(patterns, options = kEmptyObject) {
134134 }
135135
136136 const fullpath = resolve ( root , path ) ;
137- const stat = cache . stats ( fullpath ) ;
137+ const stat = cache . statSync ( fullpath ) ;
138138 const isDirectory = stat ?. isDirectory ( ) || ( followSymlinks !== false && stat ?. isSymbolicLink ( ) ) ;
139139
140140 if ( isDirectory && isRegExp ( currentPattern ) ) {
141- const entries = cache . readdir ( fullpath ) ;
141+ const entries = cache . readdirSync ( fullpath ) ;
142142 for ( const entry of entries ) {
143143 const entryPath = join ( path , entry . name ) ;
144144 if ( cache . seen ( pattern , index , entryPath ) ) {
@@ -154,7 +154,7 @@ function glob(patterns, options = kEmptyObject) {
154154 }
155155
156156 if ( currentPattern === GLOBSTAR && isDirectory ) {
157- const entries = cache . readdir ( fullpath ) ;
157+ const entries = cache . readdirSync ( fullpath ) ;
158158 for ( const entry of entries ) {
159159 if ( entry . name [ 0 ] === '.' || ( exclude && exclude ( entry . name ) ) ) {
160160 continue ;
@@ -197,6 +197,7 @@ function glob(patterns, options = kEmptyObject) {
197197}
198198
199199module . exports = {
200- glob,
200+ __proto__ : null ,
201+ globSync,
201202 lazyMinimatch,
202203} ;
0 commit comments