diff --git a/doc/api/fs.md b/doc/api/fs.md index 114a51c15dc5d6..76543badbe29fd 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1305,6 +1305,7 @@ changes: * `encoding` {string} **Default:** `'utf8'` * `withFileTypes` {boolean} **Default:** `false` * `recursive` {boolean} **Default:** `false` + * `depth` {number} **Default:** `1` * Returns: {Promise} Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`. @@ -1318,6 +1319,12 @@ will be passed as {Buffer} objects. If `options.withFileTypes` is set to `true`, the resolved array will contain {fs.Dirent} objects. +The `options.depth` determines the amount of recursion to apply. A value less +than 1 applies full recursion, value of 1 applies no recursion, and greater +values determine the depth of descendant directies to traverse. If +`options.recursive` is value `true` then `options.depth` defaults to a value +of `0` and otherwise defaults to a value `1`. + ```mjs import { readdir } from 'node:fs/promises'; @@ -3615,6 +3622,7 @@ changes: * `encoding` {string} **Default:** `'utf8'` * `withFileTypes` {boolean} **Default:** `false` * `recursive` {boolean} **Default:** `false` + * `depth` {number} **Default:** `1` * `callback` {Function} * `err` {Error} * `files` {string\[]|Buffer\[]|fs.Dirent\[]} @@ -3633,6 +3641,12 @@ the filenames returned will be passed as {Buffer} objects. If `options.withFileTypes` is set to `true`, the `files` array will contain {fs.Dirent} objects. +The `options.depth` determines the amount of recursion to apply. A value less +than 1 applies full recursion, value of 1 applies no recursion, and greater +values determine the depth of descendant directies to traverse. If +`options.recursive` is value `true` then `options.depth` defaults to a value +of `0` and otherwise defaults to a value `1`. + ### `fs.readFile(path[, options], callback)`