diff --git a/doc/api/fs.md b/doc/api/fs.md index 4bd7da6de39030..64e106bb12c48b 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1069,6 +1069,38 @@ including subdirectories and files. When copying a directory to another directory, globs are not supported and behavior is similar to `cp dir1/ dir2/`. +### `fsPromises.glob(patten[, options])` + + + +> Stability: 1 - Experimental + +* `patten` {string|string\[]} +* `options` {Object} + * `cwd` {string} working directory. **Default:** `process.cwd()` + * `exclude` {Function} Function to filter out files/directories. Return + `true` to exclude the item, `false` to include it. **Default:** `undefined`. +* Returns: {AsyncIterator} An AsyncIterator that yields the paths of files + that match the pattern. + +```mjs +import { glob } from 'node:fs/promises'; + +for await (const entry of glob('**/*.js')) + console.log(entry); +``` + +```cjs +const { glob } = require('node:fs/promises'); + +(async () => { + for await (const entry of glob('**/*.js')) + console.log(entry); +})(); +``` + ### `fsPromises.lchmod(path, mode)` + +> Stability: 1 - Experimental + +* `patten` {string|string\[]} +* `options` {Object} + * `cwd` {string} working directory. **Default:** `process.cwd()` + * `exclude` {Function} Function to filter out files/directories. Return + `true` to exclude the item, `false` to include it. **Default:** `undefined`. +* Returns: {string\[]} paths of files that match the pattern. + +```mjs +import { globSync } from 'node:fs'; + +console.log(globSync('**/*.js')); +``` + +```cjs +const { globSync } = require('node:fs'); + +console.log(globSync('**/*.js')); +``` + ### `fs.lchmodSync(path, mode)`