@@ -73,7 +73,7 @@ import {
7373 ERR_INVALID_ARG_VALUE ,
7474 ERR_UNSUPPORTED_OPERATION ,
7575} from 'node-internal:internal_errors' ;
76- import { type Dir } from 'node-internal:internal_fs' ;
76+ import { type Dir , Dirent } from 'node-internal:internal_fs' ;
7777import { Buffer } from 'node-internal:internal_buffer' ;
7878import { isArrayBufferView } from 'node-internal:internal_types' ;
7979import {
@@ -1416,18 +1416,28 @@ export function watchFile(): void {
14161416}
14171417
14181418export function glob (
1419- _pattern : string | readonly string [ ] ,
1420- _options :
1419+ pattern : string | readonly string [ ] ,
1420+ optionsOrCallback :
14211421 | GlobOptions
14221422 | GlobOptionsWithFileTypes
1423- | GlobOptionsWithoutFileTypes ,
1424- _callback : ErrorOnlyCallback
1423+ | GlobOptionsWithoutFileTypes
1424+ | SingleArgCallback < string [ ] | Dirent [ ] > ,
1425+ callback ?: SingleArgCallback < string [ ] | Dirent [ ] >
14251426) : void {
1426- // We do not yet implement the globSync function. In Node.js, this
1427- // function depends heavily on the third party minimatch library
1428- // which is not yet available in the workers runtime. This will be
1429- // explored for implementation separately in the future.
1430- throw new ERR_UNSUPPORTED_OPERATION ( ) ;
1427+ let options :
1428+ | GlobOptions
1429+ | GlobOptionsWithFileTypes
1430+ | GlobOptionsWithoutFileTypes ;
1431+ if ( typeof optionsOrCallback === 'function' ) {
1432+ callback = optionsOrCallback ;
1433+ options = { } ;
1434+ } else {
1435+ options = optionsOrCallback ;
1436+ }
1437+ if ( callback === undefined ) {
1438+ throw new ERR_INVALID_ARG_TYPE ( 'callback' , [ 'function' ] , callback ) ;
1439+ }
1440+ callWithSingleArgCallback ( ( ) => fssync . globSync ( pattern , options ) , callback ) ;
14311441}
14321442
14331443// An API is considered stubbed if it is not implemented by the function
@@ -1497,5 +1507,5 @@ export function glob(
14971507// [ ][ ][ ][ ] fs.createReadStream(path[, options])
14981508// [ ][ ][ ][ ] fs.createWriteStream(path[, options])
14991509//
1500- // [ ][ ][ ][ ] fs.glob(pattern[, options], callback)
1510+ // [x][x][x][x ] fs.glob(pattern[, options], callback)
15011511// [ ][ ][ ][ ] fs.openAsBlob(path[, options])
0 commit comments