@@ -82,6 +82,21 @@ g3.stream().on('data', path => {
8282 path .readdirSync ().map (e => e .name )
8383 )
8484})
85+
86+ // if you use stat:true and withFileTypes, you can sort results
87+ // by things like modified time, filter by permission mode, etc.
88+ // All Stats fields will be avialable in that case. Slightly
89+ // slower, though.
90+ // For example:
91+ const results = await glob (' **' , { stat: true , withFileTypes: true })
92+
93+ const timeSortedFiles = results
94+ .sort ((a , b ) => a .mtimeMS - b .mtimeMS )
95+ .map (path => path .fullpath ())
96+
97+ const groupReadableFiles = results
98+ .filter (path => path .mode & 0o040 )
99+ .map (path => path .fullpath ())
85100```
86101
87102** Note** Glob patterns should always use ` / ` as a path separator,
@@ -321,6 +336,12 @@ share the previously loaded cache.
321336- ` nodir ` Do not match directories, only files. (Note: to match
322337 _ only_ directories, put a ` / ` at the end of the pattern.)
323338
339+ - ` stat ` Call ` lstat() ` on all entries, whether required or not
340+ to determine whether it's a valid match. When used with
341+ ` withFileTypes ` , this means that matches will include data such
342+ as modified time, permissions, and so on. Note that this will
343+ incur a performance cost due to the added system calls.
344+
324345- ` ignore ` string or string[ ] . A glob pattern or array of glob
325346 patterns to exclude from matches. To ignore all children within
326347 a directory, as well as the entry itself, append ` /**' ` to the
0 commit comments