{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"fs","path":"/fs","type":"module","module":"fs","title":"File system","introducedIn":"v0.10.0","sourceLink":{"path":"lib/fs.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/fs.js"},"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:fs` module enables interacting with the file system in a\nway modeled on standard POSIX functions.\n\nTo use the promise-based APIs:\n\n```mjs\nimport * as fs from 'node:fs/promises';\n```\n\n```cjs\nconst fs = require('node:fs/promises');\n```\n\nTo use the callback and sync APIs:\n\n```mjs\nimport * as fs from 'node:fs';\n```\n\n```cjs\nconst fs = require('node:fs');\n```\n\nAll file system operations have synchronous, callback, and promise-based\nforms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).","summary":"The `node:fs` module enables interacting with the file system in a way modeled on standard POSIX functions.","examples":[{"language":"mjs","displayName":null,"code":"import * as fs from 'node:fs/promises';"},{"language":"cjs","displayName":null,"code":"const fs = require('node:fs/promises');"},{"language":"mjs","displayName":null,"code":"import * as fs from 'node:fs';"},{"language":"cjs","displayName":null,"code":"const fs = require('node:fs');"}],"children":[{"kind":"section","id":"promise-example","name":"Promise example","title":"Promise example","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Promise-based operations return a promise that is fulfilled when the\nasynchronous operation is complete.\n\n```mjs\nimport { unlink } from 'node:fs/promises';\n\ntry {\n  await unlink('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (error) {\n  console.error('there was an error:', error.message);\n}\n```\n\n```cjs\nconst { unlink } = require('node:fs/promises');\n\n(async function(path) {\n  try {\n    await unlink(path);\n    console.log(`successfully deleted ${path}`);\n  } catch (error) {\n    console.error('there was an error:', error.message);\n  }\n})('/tmp/hello');\n```","summary":"Promise-based operations return a promise that is fulfilled when the asynchronous operation is complete.","examples":[{"language":"mjs","displayName":null,"code":"import { unlink } from 'node:fs/promises';\n\ntry {\n  await unlink('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (error) {\n  console.error('there was an error:', error.message);\n}"},{"language":"cjs","displayName":null,"code":"const { unlink } = require('node:fs/promises');\n\n(async function(path) {\n  try {\n    await unlink(path);\n    console.log(`successfully deleted ${path}`);\n  } catch (error) {\n    console.error('there was an error:', error.message);\n  }\n})('/tmp/hello');"}],"children":[]},{"kind":"section","id":"callback-example","name":"Callback example","title":"Callback example","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The callback form takes a completion callback function as its last\nargument and invokes the operation asynchronously. The arguments passed to\nthe completion callback depend on the method, but the first argument is always\nreserved for an exception. If the operation is completed successfully, then\nthe first argument is `null` or `undefined`.\n\n```mjs\nimport { unlink } from 'node:fs';\n\nunlink('/tmp/hello', (err) => {\n  if (err) throw err;\n  console.log('successfully deleted /tmp/hello');\n});\n```\n\n```cjs\nconst { unlink } = require('node:fs');\n\nunlink('/tmp/hello', (err) => {\n  if (err) throw err;\n  console.log('successfully deleted /tmp/hello');\n});\n```\n\nThe callback-based versions of the `node:fs` module APIs are preferable over\nthe use of the promise APIs when maximal performance (both in terms of\nexecution time and memory allocation) is required.","summary":"The callback form takes a completion callback function as its last argument and invokes the operation asynchronously. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation is completed successfully, then the first argument is `null` or `undefined`.","examples":[{"language":"mjs","displayName":null,"code":"import { unlink } from 'node:fs';\n\nunlink('/tmp/hello', (err) => {\n  if (err) throw err;\n  console.log('successfully deleted /tmp/hello');\n});"},{"language":"cjs","displayName":null,"code":"const { unlink } = require('node:fs');\n\nunlink('/tmp/hello', (err) => {\n  if (err) throw err;\n  console.log('successfully deleted /tmp/hello');\n});"}],"children":[]},{"kind":"section","id":"synchronous-example","name":"Synchronous example","title":"Synchronous example","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The synchronous APIs block the Node.js event loop and further JavaScript\nexecution until the operation is complete. Exceptions are thrown immediately\nand can be handled using `try…catch`, or can be allowed to bubble up.\n\n```mjs\nimport { unlinkSync } from 'node:fs';\n\ntry {\n  unlinkSync('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (err) {\n  // handle the error\n}\n```\n\n```cjs\nconst { unlinkSync } = require('node:fs');\n\ntry {\n  unlinkSync('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (err) {\n  // handle the error\n}\n```","summary":"The synchronous APIs block the Node.js event loop and further JavaScript execution until the operation is complete. Exceptions are thrown immediately and can be handled using `try…catch`, or can be allowed to bubble up.","examples":[{"language":"mjs","displayName":null,"code":"import { unlinkSync } from 'node:fs';\n\ntry {\n  unlinkSync('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (err) {\n  // handle the error\n}"},{"language":"cjs","displayName":null,"code":"const { unlinkSync } = require('node:fs');\n\ntry {\n  unlinkSync('/tmp/hello');\n  console.log('successfully deleted /tmp/hello');\n} catch (err) {\n  // handle the error\n}"}],"children":[]},{"kind":"section","id":"promises-api","name":"Promises API","title":"Promises API","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31553","commit":null,"description":"Exposed as `require('fs/promises')`."},{"versions":["v11.14.0","v10.17.0"],"prUrl":"https://github.com/nodejs/node/pull/26581","commit":null,"description":"This API is no longer experimental."},{"versions":["v10.1.0"],"prUrl":"https://github.com/nodejs/node/pull/20504","commit":null,"description":"The API is accessible via `require('fs').promises` only."}],"description":"The `fs/promises` API provides asynchronous file system methods that return\npromises.\n\nThe promise APIs use the underlying Node.js threadpool to perform file\nsystem operations off the event loop thread. These operations are not\nsynchronized or threadsafe. Care must be taken when performing multiple\nconcurrent modifications on the same file or data corruption may occur.","summary":"The `fs/promises` API provides asynchronous file system methods that return promises.","examples":[],"children":[{"kind":"class","id":"class-filehandle","name":"FileHandle","title":"Class: `FileHandle`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"A {FileHandle} object is an object wrapper for a numeric file descriptor.\n\nInstances of the {FileHandle} object are created by the `fsPromises.open()`\nmethod.\n\nAll {FileHandle} objects are {EventEmitter}s.\n\nIf a {FileHandle} is not closed using the `filehandle.close()` method, it will\ntry to automatically close the file descriptor and emit a process warning,\nhelping to prevent memory leaks. Please do not rely on this behavior because\nit can be unreliable and the file may not be closed. Instead, always explicitly\nclose {FileHandle}s. Node.js may change this behavior in the future.","summary":"A {FileHandle} object is an object wrapper for a numeric file descriptor.","examples":[],"children":[{"kind":"event","id":"event-close","name":"close","title":"Event: `'close'`","scope":"module","overloadOf":null,"stability":null,"added":["v15.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'close'` event is emitted when the {FileHandle} has been closed and can no\nlonger be used.","summary":"The `'close'` event is emitted when the {FileHandle} has been closed and can no longer be used.","examples":[],"children":[]},{"kind":"method","id":"filehandleappendfiledata-options","name":"appendFile","title":"`filehandle.appendFile(data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.1.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50095","commit":null,"description":"The `flush` option is now supported."},{"versions":["v15.14.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/37490","commit":null,"description":"The `data` argument supports `AsyncIterable`, `Iterable`, and `Stream`."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `data` parameter won't coerce unsupported input to strings anymore."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView | AsyncIterable | Iterable","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39},{"name":"AsyncIterable","href":"https://tc39.github.io/ecma262/#sec-asynciterable-interface","start":42,"end":55},{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":58,"end":66}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal | undefined","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":14,"end":23}]},"description":"allows aborting an in-progress writeFile.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Alias of [`filehandle.writeFile()`](#filehandlewritefiledata-options).\n\nWhen operating on file handles, the mode cannot be changed from what it was set\nto with [`fsPromises.open()`](#fspromisesopenpath-flags-mode). Therefore, this is equivalent to\n[`filehandle.writeFile()`](#filehandlewritefiledata-options).","summary":"Alias of `filehandle.writeFile()`.","examples":[],"children":[]},{"kind":"method","id":"filehandlechmodmode","name":"chmod","title":"`filehandle.chmod(mode)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"the file mode bit mask.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).","summary":"Modifies the permissions on the file. See `chmod(2)`.","examples":[],"children":[]},{"kind":"method","id":"filehandlechownuid-gid","name":"chown","title":"`filehandle.chown(uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new owner's user id.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new group's group id.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).","summary":"Changes the ownership of the file. A wrapper for `chown(2)`.","examples":[],"children":[]},{"kind":"method","id":"filehandleclose","name":"close","title":"`filehandle.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Closes the file handle after waiting for any pending operation on the handle to\ncomplete.\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nlet filehandle;\ntry {\n  filehandle = await open('thefile.txt', 'r');\n} finally {\n  await filehandle?.close();\n}\n```","summary":"Closes the file handle after waiting for any pending operation on the handle to complete.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nlet filehandle;\ntry {\n  filehandle = await open('thefile.txt', 'r');\n} finally {\n  await filehandle?.close();\n}"}],"children":[]},{"kind":"method","id":"filehandlecreatereadstreamoptions","name":"createReadStream","title":"`filehandle.createReadStream([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.11.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"emitClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"Infinity","optional":true,"rest":false,"properties":[]},{"name":"highWaterMark","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"64 * 1024","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal | undefined","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":14,"end":23}]},"description":"","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.ReadStream","links":[{"name":"fs.ReadStream","href":"fs.html#class-fsreadstream","start":0,"end":13}]},"description":""}},"description":"`options` can include `start` and `end` values to read a range of bytes from\nthe file instead of the entire file. Both `start` and `end` are inclusive and\nstart counting at 0, allowed values are in the\n\\[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)] range. If `start` is\nomitted or `undefined`, `filehandle.createReadStream()` reads sequentially from\nthe current file position. The `encoding` can be any one of those accepted by\n{Buffer}.\n\nIf the `FileHandle` points to a character device that only supports blocking\nreads (such as keyboard or sound card), read operations do not finish until data\nis available. This can prevent the process from exiting and the stream from\nclosing naturally.\n\nBy default, the stream will emit a `'close'` event after it has been\ndestroyed.  Set the `emitClose` option to `false` to change this behavior.\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nconst fd = await open('/dev/input/event0');\n// Create a stream from some character device.\nconst stream = fd.createReadStream();\nsetTimeout(() => {\n  stream.close(); // This may not close the stream.\n  // Artificially marking end-of-stream, as if the underlying resource had\n  // indicated end-of-file by itself, allows the stream to close.\n  // This does not cancel pending read operations, and if there is such an\n  // operation, the process may still not be able to exit successfully\n  // until it finishes.\n  stream.push(null);\n  stream.read(0);\n}, 100);\n```\n\nIf `autoClose` is false, then the file descriptor won't be closed, even if\nthere's an error. It is the application's responsibility to close it and make\nsure there's no file descriptor leak. If `autoClose` is set to true (default\nbehavior), on `'error'` or `'end'` the file descriptor will be closed\nautomatically.\n\nAn example to read the last 10 bytes of a file which is 100 bytes long:\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nconst fd = await open('sample.txt');\nfd.createReadStream({ start: 90, end: 99 });\n```","summary":"`options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and start counting at 0, allowed values are in the [0, `Number.MAX_SAFE_INTEGER`] range. If `start` is omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from the current file position. The `encoding` can be any one of those accepted by {Buffer}.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nconst fd = await open('/dev/input/event0');\n// Create a stream from some character device.\nconst stream = fd.createReadStream();\nsetTimeout(() => {\n  stream.close(); // This may not close the stream.\n  // Artificially marking end-of-stream, as if the underlying resource had\n  // indicated end-of-file by itself, allows the stream to close.\n  // This does not cancel pending read operations, and if there is such an\n  // operation, the process may still not be able to exit successfully\n  // until it finishes.\n  stream.push(null);\n  stream.read(0);\n}, 100);"},{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nconst fd = await open('sample.txt');\nfd.createReadStream({ start: 90, end: 99 });"}],"children":[]},{"kind":"method","id":"filehandlecreatewritestreamoptions","name":"createWriteStream","title":"`filehandle.createWriteStream([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.11.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.0.0"],"prUrl":"https://github.com/nodejs/node/pull/52037","commit":null,"description":"bump default highWaterMark."},{"versions":["v21.0.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50093","commit":null,"description":"The `flush` option is now supported."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"emitClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":"See `stream.getDefaultHighWaterMark()`","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, the underlying file descriptor is flushed\nprior to closing it.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.WriteStream","links":[{"name":"fs.WriteStream","href":"fs.html#class-fswritestream","start":0,"end":14}]},"description":""}},"description":"`options` may also include a `start` option to allow writing data at some\nposition past the beginning of the file, allowed values are in the\n\\[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)] range. Modifying a file rather than\nreplacing it may require the `flags` `open` option to be set to `r+` rather than\nthe default `r`. The `encoding` can be any one of those accepted by {Buffer}.\n\nIf `autoClose` is set to true (default behavior) on `'error'` or `'finish'`\nthe file descriptor will be closed automatically. If `autoClose` is false,\nthen the file descriptor won't be closed, even if there's an error.\nIt is the application's responsibility to close it and make sure there's no\nfile descriptor leak.\n\nBy default, the stream will emit a `'close'` event after it has been\ndestroyed.  Set the `emitClose` option to `false` to change this behavior.","summary":"`options` may also include a `start` option to allow writing data at some position past the beginning of the file, allowed values are in the [0, `Number.MAX_SAFE_INTEGER`] range. Modifying a file rather than replacing it may require the `flags` `open` option to be set to `r+` rather than the default `r`. The `encoding` can be any one of those accepted by {Buffer}.","examples":[],"children":[]},{"kind":"method","id":"filehandledatasync","name":"datasync","title":"`filehandle.datasync()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Forces all currently queued I/O operations associated with the file to the\noperating system's synchronized I/O completion state. Refer to the POSIX\n[`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details.\n\nUnlike `filehandle.sync` this method does not flush modified metadata.","summary":"Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX `fdatasync(2)` documentation for details.","examples":[],"children":[]},{"kind":"property","id":"filehandlefd","name":"fd","title":"`filehandle.fd`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The numeric file descriptor managed by the {FileHandle} object.","summary":"","examples":[],"children":[]},{"kind":"method","id":"filehandlepulltransforms-options","name":"pull","title":"`filehandle.pull([...transforms][, options])`","scope":"module","overloadOf":null,"stability":{"index":"1","description":"Experimental"},"added":["v25.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"transforms","type":{"text":"Function | Object","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":11,"end":17}]},"description":"Optional transforms to apply via\n[`stream/iter pull()`](stream_iter.html#pullsource-transforms-options).","default":null,"optional":true,"rest":true,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Close the file handle when the stream ends.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Byte offset to begin reading from. When specified,\nreads use explicit positioning (`pread` semantics).","default":"current file position","optional":true,"rest":false,"properties":[]},{"name":"limit","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Maximum number of bytes to read before ending the\niterator. Reads stop when `limit` bytes have been delivered or EOF is\nreached, whichever comes first.","default":"read until EOF","optional":true,"rest":false,"properties":[]},{"name":"chunkSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Size in bytes of the buffer allocated for each\nread operation.","default":"`131072` (128 KB)","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"AsyncIterable","links":[{"name":"AsyncIterable","href":"https://tc39.github.io/ecma262/#sec-asynciterable-interface","start":0,"end":13}]},"description":"whose chunks fulfill with {Uint8Array[]}"}},"description":"Return the file contents as an async iterable using the\n[`node:stream/iter`](stream_iter.html) pull model. Reads are performed in `chunkSize`-byte\nchunks (default 128 KB). If transforms are provided, they are applied\nvia [`stream/iter pull()`](stream_iter.html#pullsource-transforms-options).\n\nThe file handle is locked while the iterable is being consumed and unlocked\nwhen iteration completes, an error occurs, or the consumer breaks.\n\nThis function is only available when the `--experimental-stream-iter` flag is\nenabled.\n\n```mjs\nimport { open } from 'node:fs/promises';\nimport { text } from 'node:stream/iter';\nimport { compressGzip } from 'node:zlib/iter';\n\nconst fh = await open('input.txt', 'r');\n\n// Read as text\nconsole.log(await text(fh.pull({ autoClose: true })));\n\n// Read 1 KB starting at byte 100\nconst fh2 = await open('input.txt', 'r');\nconsole.log(await text(fh2.pull({ start: 100, limit: 1024, autoClose: true })));\n\n// Read with compression\nconst fh3 = await open('input.txt', 'r');\nconst compressed = fh3.pull(compressGzip(), { autoClose: true });\n```\n\n```cjs\nconst { open } = require('node:fs/promises');\nconst { text } = require('node:stream/iter');\nconst { compressGzip } = require('node:zlib/iter');\n\nasync function run() {\n  const fh = await open('input.txt', 'r');\n\n  // Read as text\n  console.log(await text(fh.pull({ autoClose: true })));\n\n  // Read 1 KB starting at byte 100\n  const fh2 = await open('input.txt', 'r');\n  console.log(await text(fh2.pull({ start: 100, limit: 1024, autoClose: true })));\n\n  // Read with compression\n  const fh3 = await open('input.txt', 'r');\n  const compressed = fh3.pull(compressGzip(), { autoClose: true });\n}\n\nrun().catch(console.error);\n```","summary":"Return the file contents as an async iterable using the `node:stream/iter` pull model. Reads are performed in `chunkSize`-byte chunks (default 128 KB). If transforms are provided, they are applied via `stream/iter pull()`.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\nimport { text } from 'node:stream/iter';\nimport { compressGzip } from 'node:zlib/iter';\n\nconst fh = await open('input.txt', 'r');\n\n// Read as text\nconsole.log(await text(fh.pull({ autoClose: true })));\n\n// Read 1 KB starting at byte 100\nconst fh2 = await open('input.txt', 'r');\nconsole.log(await text(fh2.pull({ start: 100, limit: 1024, autoClose: true })));\n\n// Read with compression\nconst fh3 = await open('input.txt', 'r');\nconst compressed = fh3.pull(compressGzip(), { autoClose: true });"},{"language":"cjs","displayName":null,"code":"const { open } = require('node:fs/promises');\nconst { text } = require('node:stream/iter');\nconst { compressGzip } = require('node:zlib/iter');\n\nasync function run() {\n  const fh = await open('input.txt', 'r');\n\n  // Read as text\n  console.log(await text(fh.pull({ autoClose: true })));\n\n  // Read 1 KB starting at byte 100\n  const fh2 = await open('input.txt', 'r');\n  console.log(await text(fh2.pull({ start: 100, limit: 1024, autoClose: true })));\n\n  // Read with compression\n  const fh3 = await open('input.txt', 'r');\n  const compressed = fh3.pull(compressGzip(), { autoClose: true });\n}\n\nrun().catch(console.error);"}],"children":[]},{"kind":"method","id":"filehandlepullsynctransforms-options","name":"pullSync","title":"`filehandle.pullSync([...transforms][, options])`","scope":"module","overloadOf":null,"stability":{"index":"1","description":"Experimental"},"added":["v25.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"transforms","type":{"text":"Function | Object","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":11,"end":17}]},"description":"Optional transforms to apply via\n[`stream/iter pullSync()`](stream_iter.html#pullsyncsource-transforms).","default":null,"optional":true,"rest":true,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Close the file handle when the stream ends.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Byte offset to begin reading from. When specified,\nreads use explicit positioning.","default":"current file position","optional":true,"rest":false,"properties":[]},{"name":"limit","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Maximum number of bytes to read before ending the\niterator.","default":"read until EOF","optional":true,"rest":false,"properties":[]},{"name":"chunkSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Size in bytes of the buffer allocated for each\nread operation.","default":"`131072` (128 KB)","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Iterable","links":[{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":0,"end":8}]},"description":"whose chunks return {Uint8Array[]}"}},"description":"Synchronous counterpart of [`filehandle.pull()`](#filehandlepulltransforms-options). Returns a sync iterable\nthat reads the file using synchronous I/O on the main thread. Reads are\nperformed in `chunkSize`-byte chunks (default 128 KB).\n\nThe file handle is locked while the iterable is being consumed. Unlike the\nasync `pull()`, this method does not support `AbortSignal` since all\noperations are synchronous.\n\nThis function is only available when the `--experimental-stream-iter` flag is\nenabled.\n\n```mjs\nimport { open } from 'node:fs/promises';\nimport { textSync, pipeToSync } from 'node:stream/iter';\nimport { compressGzipSync, decompressGzipSync } from 'node:zlib/iter';\n\nconst fh = await open('input.txt', 'r');\n\n// Read as text (sync)\nconsole.log(textSync(fh.pullSync({ autoClose: true })));\n\n// Sync compress pipeline: file -> gzip -> file\nconst src = await open('input.txt', 'r');\nconst dst = await open('output.gz', 'w');\npipeToSync(src.pullSync(compressGzipSync(), { autoClose: true }), dst.writer({ autoClose: true }));\n```\n\n```cjs\nconst { open } = require('node:fs/promises');\nconst { textSync, pipeToSync } = require('node:stream/iter');\nconst { compressGzipSync, decompressGzipSync } = require('node:zlib/iter');\n\nasync function run() {\n  const fh = await open('input.txt', 'r');\n\n  // Read as text (sync)\n  console.log(textSync(fh.pullSync({ autoClose: true })));\n\n  // Sync compress pipeline: file -> gzip -> file\n  const src = await open('input.txt', 'r');\n  const dst = await open('output.gz', 'w');\n  pipeToSync(\n    src.pullSync(compressGzipSync(), { autoClose: true }),\n    dst.writer({ autoClose: true }),\n  );\n}\n\nrun().catch(console.error);\n```","summary":"Synchronous counterpart of `filehandle.pull()`. Returns a sync iterable that reads the file using synchronous I/O on the main thread. Reads are performed in `chunkSize`-byte chunks (default 128 KB).","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\nimport { textSync, pipeToSync } from 'node:stream/iter';\nimport { compressGzipSync, decompressGzipSync } from 'node:zlib/iter';\n\nconst fh = await open('input.txt', 'r');\n\n// Read as text (sync)\nconsole.log(textSync(fh.pullSync({ autoClose: true })));\n\n// Sync compress pipeline: file -> gzip -> file\nconst src = await open('input.txt', 'r');\nconst dst = await open('output.gz', 'w');\npipeToSync(src.pullSync(compressGzipSync(), { autoClose: true }), dst.writer({ autoClose: true }));"},{"language":"cjs","displayName":null,"code":"const { open } = require('node:fs/promises');\nconst { textSync, pipeToSync } = require('node:stream/iter');\nconst { compressGzipSync, decompressGzipSync } = require('node:zlib/iter');\n\nasync function run() {\n  const fh = await open('input.txt', 'r');\n\n  // Read as text (sync)\n  console.log(textSync(fh.pullSync({ autoClose: true })));\n\n  // Sync compress pipeline: file -> gzip -> file\n  const src = await open('input.txt', 'r');\n  const dst = await open('output.gz', 'w');\n  pipeToSync(\n    src.pullSync(compressGzipSync(), { autoClose: true }),\n    dst.writer({ autoClose: true }),\n  );\n}\n\nrun().catch(console.error);"}],"children":[]},{"kind":"method","id":"filehandlereadbuffer-offset-length-position","name":"read","title":"`filehandle.read(buffer, offset, length, position)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42835","commit":null,"description":"Accepts bigint values as `position`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"A buffer that will be filled with the\nfile data read.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The location in the buffer at which to start filling.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes to read.","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"The location where to begin reading data\nfrom the file. If `null` or `-1`, data will be read from the current file\nposition, and the position will be updated. If `position` is a non-negative\ninteger, the current file position will remain unchanged.","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills upon success with an object with two properties:"}},"description":"Reads data from the file and stores that in the given buffer.\n\nIf the file is not modified concurrently, the end-of-file is reached when the\nnumber of bytes read is zero.","summary":"Reads data from the file and stores that in the given buffer.","examples":[],"children":[]},{"kind":"method","id":"filehandlereadoptions","name":"read","title":"`filehandle.read([options])`","scope":"module","overloadOf":"filehandlereadbuffer-offset-length-position","stability":null,"added":["v13.11.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42835","commit":null,"description":"Accepts bigint values as `position`."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"A buffer that will be filled with the\nfile data read.","default":"Buffer.alloc(16384)","optional":true,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The location in the buffer at which to start filling.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes to read.","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"The location where to begin reading data\nfrom the file. If `null` or `-1`, data will be read from the current file\nposition, and the position will be updated. If `position` is a non-negative\ninteger, the current file position will remain unchanged.","default":": `null`","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills upon success with an object with two properties:"}},"description":"Reads data from the file and stores that in the given buffer.\n\nIf the file is not modified concurrently, the end-of-file is reached when the\nnumber of bytes read is zero.","summary":"Reads data from the file and stores that in the given buffer.","examples":[],"children":[]},{"kind":"method","id":"filehandlereadbuffer-options","name":"read","title":"`filehandle.read(buffer[, options])`","scope":"module","overloadOf":"filehandlereadbuffer-offset-length-position","stability":null,"added":["v18.2.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42835","commit":null,"description":"Accepts bigint values as `position`."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"A buffer that will be filled with the\nfile data read.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The location in the buffer at which to start filling.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes to read.","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"The location where to begin reading data\nfrom the file. If `null` or `-1`, data will be read from the current file\nposition, and the position will be updated. If `position` is a non-negative\ninteger, the current file position will remain unchanged.","default":": `null`","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills upon success with an object with two properties:"}},"description":"Reads data from the file and stores that in the given buffer.\n\nIf the file is not modified concurrently, the end-of-file is reached when the\nnumber of bytes read is zero.","summary":"Reads data from the file and stores that in the given buffer.","examples":[],"children":[]},{"kind":"method","id":"filehandlereadablewebstreamoptions","name":"readableWebStream","title":"`filehandle.readableWebStream([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v17.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."},{"versions":["v23.8.0","v22.15.0"],"prUrl":"https://github.com/nodejs/node/pull/55461","commit":null,"description":"Removed option to create a 'bytes' stream. Streams are now always 'bytes' streams."},{"versions":["v20.0.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/46933","commit":null,"description":"Added option to create a 'bytes' stream."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When true, causes the {FileHandle} to be closed when the\nstream is closed.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":""}},"description":"Returns a byte-oriented `ReadableStream` that may be used to read the file's\ncontents.\n\nAn error will be thrown if this method is called more than once or is called\nafter the `FileHandle` is closed or closing.\n\n```mjs\nimport {\n  open,\n} from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\n\nfor await (const chunk of file.readableWebStream())\n  console.log(chunk);\n\nawait file.close();\n```\n\n```cjs\nconst {\n  open,\n} = require('node:fs/promises');\n\n(async () => {\n  const file = await open('./some/file/to/read');\n\n  for await (const chunk of file.readableWebStream())\n    console.log(chunk);\n\n  await file.close();\n})();\n```\n\nWhile the `ReadableStream` will read the file to completion, it will not\nclose the `FileHandle` automatically. User code must still call the\n`fileHandle.close()` method unless the `autoClose` option is set to `true`.","summary":"Returns a byte-oriented `ReadableStream` that may be used to read the file's contents.","examples":[{"language":"mjs","displayName":null,"code":"import {\n  open,\n} from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\n\nfor await (const chunk of file.readableWebStream())\n  console.log(chunk);\n\nawait file.close();"},{"language":"cjs","displayName":null,"code":"const {\n  open,\n} = require('node:fs/promises');\n\n(async () => {\n  const file = await open('./some/file/to/read');\n\n  for await (const chunk of file.readableWebStream())\n    console.log(chunk);\n\n  await file.close();\n})();"}],"children":[]},{"kind":"method","id":"filehandlereadfileoptions","name":"readFile","title":"`filehandle.readFile(options)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.4.0"],"prUrl":"https://github.com/nodejs/node/pull/63634","commit":null,"description":"Added support for the `buffer` option."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows aborting an in-progress readFile","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView | Function","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":33,"end":41}]},"description":"A buffer to read into, or a\nfunction called with the file size that returns the buffer.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills upon a successful read with the contents of the\nfile. If no encoding is specified (using `options.encoding`), the data is\nreturned as a {Buffer} object. Otherwise, the data will be a string."}},"description":"Asynchronously reads the entire contents of a file.\n\nIf `options` is a string, then it specifies the `encoding`.\n\nIf `buffer` is provided and no encoding is specified, the returned {Buffer} is\na view over the supplied buffer containing only the bytes read. If the\nsupplied buffer is too small to contain the entire file, the operation will\nfail.\n\nThe {FileHandle} has to support reading.\n\nIf one or more `filehandle.read()` calls are made on a file handle and then a\n`filehandle.readFile()` call is made, the data will be read from the current\nposition till the end of the file. It doesn't always read from the beginning\nof the file.\n\nAn example using the `buffer` option with a pre-allocated buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\ntry {\n  const buf = Buffer.alloc(16384);\n  const contents = await file.readFile({ buffer: buf });\n  console.log(contents); // A view over `buf` containing only the bytes read\n} finally {\n  await file.close();\n}\n```\n\nAn example using the `buffer` option with a function returning a buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\ntry {\n  const contents = await file.readFile({\n    buffer: (size) => Buffer.alloc(size),\n  });\n  console.log(contents);\n} finally {\n  await file.close();\n}\n```","summary":"Asynchronously reads the entire contents of a file.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\ntry {\n  const buf = Buffer.alloc(16384);\n  const contents = await file.readFile({ buffer: buf });\n  console.log(contents); // A view over `buf` containing only the bytes read\n} finally {\n  await file.close();\n}"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\ntry {\n  const contents = await file.readFile({\n    buffer: (size) => Buffer.alloc(size),\n  });\n  console.log(contents);\n} finally {\n  await file.close();\n}"}],"children":[]},{"kind":"method","id":"filehandlereadlinesoptions","name":"readLines","title":"`filehandle.readLines([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v18.11.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"emitClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"Infinity","optional":true,"rest":false,"properties":[]},{"name":"highWaterMark","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"64 * 1024","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"readline.InterfaceConstructor","links":[{"name":"readline.InterfaceConstructor","href":"readline.html#class-readlineinterfaceconstructor","start":0,"end":29}]},"description":""}},"description":"Convenience method to create a `readline` interface and stream over the file.\nSee [`filehandle.createReadStream()`](#filehandlecreatereadstreamoptions) for the options.\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\n\nfor await (const line of file.readLines()) {\n  console.log(line);\n}\n```\n\n```cjs\nconst { open } = require('node:fs/promises');\n\n(async () => {\n  const file = await open('./some/file/to/read');\n\n  for await (const line of file.readLines()) {\n    console.log(line);\n  }\n})();\n```","summary":"Convenience method to create a `readline` interface and stream over the file. See `filehandle.createReadStream()` for the options.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nconst file = await open('./some/file/to/read');\n\nfor await (const line of file.readLines()) {\n  console.log(line);\n}"},{"language":"cjs","displayName":null,"code":"const { open } = require('node:fs/promises');\n\n(async () => {\n  const file = await open('./some/file/to/read');\n\n  for await (const line of file.readLines()) {\n    console.log(line);\n  }\n})();"}],"children":[]},{"kind":"method","id":"filehandlereadvbuffers-position","name":"readv","title":"`filehandle.readv(buffers[, position])`","scope":"module","overloadOf":null,"stability":null,"added":["v13.13.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffers","type":{"text":"Buffer[] | TypedArray[] | DataView[]","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":11,"end":21},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":26,"end":34}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"The offset from the beginning of the file where\nthe data should be read from. If `position` is not a `number`, the data will\nbe read from the current position.","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills upon success an object containing two properties:"}},"description":"Read from a file and write to an array of {ArrayBufferView}s","summary":"Read from a file and write to an array of {ArrayBufferView}s","examples":[],"children":[]},{"kind":"method","id":"filehandlestatoptions","name":"stat","title":"`filehandle.stat([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/57775","commit":null,"description":"Now accepts an additional `signal` property to allow aborting the operation."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned {fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An AbortSignal to cancel the operation.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with an {fs.Stats} for the file."}},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"filehandlesync","name":"sync","title":"`filehandle.sync()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Request that all data for the open file descriptor is flushed to the storage\ndevice. The specific implementation is operating system and device specific.\nRefer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.","summary":"Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX `fsync(2)` documentation for more detail.","examples":[],"children":[]},{"kind":"method","id":"filehandletruncatelen","name":"truncate","title":"`filehandle.truncate(len)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Truncates the file.\n\nIf the file was larger than `len` bytes, only the first `len` bytes will be\nretained in the file.\n\nThe following example retains only the first four bytes of the file:\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nlet filehandle = null;\ntry {\n  filehandle = await open('temp.txt', 'r+');\n  await filehandle.truncate(4);\n} finally {\n  await filehandle?.close();\n}\n```\n\nIf the file previously was shorter than `len` bytes, it is extended, and the\nextended part is filled with null bytes (`'\\0'`):\n\nIf `len` is negative then `0` will be used.","summary":"Truncates the file.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nlet filehandle = null;\ntry {\n  filehandle = await open('temp.txt', 'r+');\n  await filehandle.truncate(4);\n} finally {\n  await filehandle?.close();\n}"}],"children":[]},{"kind":"method","id":"filehandleutimesatime-mtime","name":"utimes","title":"`filehandle.utimes(atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Change the file system timestamps of the object referenced by the {FileHandle}\nthen fulfills the promise with no arguments upon success.","summary":"Change the file system timestamps of the object referenced by the {FileHandle} then fulfills the promise with no arguments upon success.","examples":[],"children":[]},{"kind":"method","id":"filehandlewritebuffer-offset-length-position","name":"write","title":"`filehandle.write(buffer, offset[, length[, position]])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `buffer` parameter won't coerce unsupported input to buffers anymore."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The start position from within `buffer` where the data\nto write begins.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes from `buffer` to write.","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"The offset from the beginning of the file where the\ndata from `buffer` should be written. If `position` is not a `number`,\nthe data will be written at the current position. See the POSIX [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html)\ndocumentation for more detail.","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Write `buffer` to the file.\n\nThe promise is fulfilled with an object containing two properties:\n\n* `bytesWritten` {integer} the number of bytes written\n* `buffer` {Buffer | TypedArray | DataView} a reference to the\n  `buffer` written.\n\nIt is unsafe to use `filehandle.write()` multiple times on the same file\nwithout waiting for the promise to be fulfilled (or rejected). For this\nscenario, use [`filehandle.createWriteStream()`](#filehandlecreatewritestreamoptions).\n\nOn Linux, positional writes do not work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.","summary":"Write `buffer` to the file.","examples":[],"children":[]},{"kind":"method","id":"filehandlewritebuffer-options","name":"write","title":"`filehandle.write(buffer[, options])`","scope":"module","overloadOf":"filehandlewritebuffer-offset-length-position","stability":null,"added":["v18.3.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Write `buffer` to the file.\n\nSimilar to the above `filehandle.write` function, this version takes an\noptional `options` object. If no `options` object is specified, it will\ndefault with the above values.","summary":"Write `buffer` to the file.","examples":[],"children":[]},{"kind":"method","id":"filehandlewritestring-position-encoding","name":"write","title":"`filehandle.write(string[, position[, encoding]])`","scope":"module","overloadOf":"filehandlewritebuffer-offset-length-position","stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `string` parameter won't coerce unsupported input to strings anymore."}],"signature":{"parameters":[{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"The offset from the beginning of the file where the\ndata from `string` should be written. If `position` is not a `number` the\ndata will be written at the current position. See the POSIX [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html)\ndocumentation for more detail.","default":"null","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The expected string encoding.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Write `string` to the file. If `string` is not a string, the promise is\nrejected with an error.\n\nThe promise is fulfilled with an object containing two properties:\n\n* `bytesWritten` {integer} the number of bytes written\n* `buffer` {string} a reference to the `string` written.\n\nIt is unsafe to use `filehandle.write()` multiple times on the same file\nwithout waiting for the promise to be fulfilled (or rejected). For this\nscenario, use [`filehandle.createWriteStream()`](#filehandlecreatewritestreamoptions).\n\nOn Linux, positional writes do not work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.","summary":"Write `string` to the file. If `string` is not a string, the promise is rejected with an error.","examples":[],"children":[]},{"kind":"method","id":"filehandlewritefiledata-options","name":"writeFile","title":"`filehandle.writeFile(data, options)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.14.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/37490","commit":null,"description":"The `data` argument supports `AsyncIterable`, `Iterable`, and `Stream`."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `data` parameter won't coerce unsupported input to strings anymore."}],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView | AsyncIterable | Iterable","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39},{"name":"AsyncIterable","href":"https://tc39.github.io/ecma262/#sec-asynciterable-interface","start":42,"end":55},{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":58,"end":66}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"The expected character encoding when `data` is a\nstring.","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal | undefined","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":14,"end":23}]},"description":"allows aborting an in-progress writeFile.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Asynchronously writes data to a file, replacing the file if it already exists.\n`data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object.\nThe promise is fulfilled with no arguments upon success.\n\nIf `options` is a string, then it specifies the `encoding`.\n\nThe {FileHandle} has to support writing.\n\nIt is unsafe to use `filehandle.writeFile()` multiple times on the same file\nwithout waiting for the promise to be fulfilled (or rejected).\n\nIf one or more `filehandle.write()` calls are made on a file handle and then a\n`filehandle.writeFile()` call is made, the data will be written from the\ncurrent position till the end of the file. It doesn't always write from the\nbeginning of the file.","summary":"Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object. The promise is fulfilled with no arguments upon success.","examples":[],"children":[]},{"kind":"method","id":"filehandlewritevbuffers-position","name":"writev","title":"`filehandle.writev(buffers[, position])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffers","type":{"text":"Buffer[] | TypedArray[] | DataView[]","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":11,"end":21},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":26,"end":34}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"The offset from the beginning of the file where the\ndata from `buffers` should be written. If `position` is not a `number`,\nthe data will be written at the current position.","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Write an array of {ArrayBufferView}s to the file.\n\nThe promise is fulfilled with an object containing a two properties:\n\n* `bytesWritten` {integer} the number of bytes written\n* `buffers` {Buffer[] | TypedArray[] | DataView[]} a reference to the `buffers`\n  input.\n\nIt is unsafe to call `writev()` multiple times on the same file without waiting\nfor the promise to be fulfilled (or rejected).\n\nOn Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.","summary":"Write an array of {ArrayBufferView}s to the file.","examples":[],"children":[]},{"kind":"method","id":"filehandlewriteroptions","name":"writer","title":"`filehandle.writer([options])`","scope":"module","overloadOf":null,"stability":{"index":"1","description":"Experimental"},"added":["v25.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Close the file handle when the writer ends or\nfails.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Byte offset to start writing at. When specified,\nwrites use explicit positioning.","default":"current file position","optional":true,"rest":false,"properties":[]},{"name":"limit","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Maximum number of bytes the writer will accept.\nAsync writes (`write()`, `writev()`) that would exceed the limit reject\nwith `ERR_OUT_OF_RANGE`. Sync writes (`writeSync()`, `writevSync()`)\nreturn `false`.","default":"no limit","optional":true,"rest":false,"properties":[]},{"name":"chunkSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Maximum chunk size in bytes for synchronous write\noperations. Writes larger than this threshold fall back to async I/O.\nSet this to match the reader's `chunkSize` for optimal `pipeTo()`\nperformance.","default":"`131072` (128 KB)","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"* `write(chunk[, options])` {Function} Returns {Promise}.\n  Accepts `Uint8Array`, `Buffer`, or string (UTF-8 encoded).\n  * `chunk` {Buffer | TypedArray | DataView | string}\n  * `options` {Object}\n    * `signal` {AbortSignal} If the signal is already aborted, the write\n      rejects with `AbortError` without performing I/O.\n* `writev(chunks[, options])` {Function} Returns {Promise}. Uses\n  scatter/gather I/O via a single `writev()` syscall. Accepts mixed\n  `Uint8Array`/string arrays.\n  * `chunks` {Buffer[] | TypedArray[] | DataView[] | string[]}\n  * `options` {Object}\n    * `signal` {AbortSignal} If the signal is already aborted, the write\n      rejects with `AbortError` without performing I/O.\n* `writeSync(chunk)` {Function} Returns {boolean}. Attempts a synchronous\n  write. Returns `true` if the write succeeded, `false` if the caller\n  should fall back to async `write()`. Returns `false` when: the writer\n  is closed/errored, an async operation is in flight, the chunk exceeds\n  `chunkSize`, or the write would exceed `limit`.\n  * `chunk` {Buffer | TypedArray | DataView | string}\n* `writevSync(chunks)` {Function} Returns {boolean}. Synchronous batch\n  write. Same fallback semantics as `writeSync()`.\n  * `chunks` {Buffer[] | TypedArray[] | DataView[] | string[]}\n* `end([options])` {Function} Returns {Promise}, fulfills with the total\n  number of bytes written. Idempotent: returns `totalBytesWritten` if already\n  closed, returns the pending promise if already closing. Rejects if the writer\n  is in an errored state.\n  * `options` {Object}\n    * `signal` {AbortSignal} If the signal is already aborted, `end()`\n      rejects with `AbortError` and the writer remains open.\n* `endSync()` {Function} Returns {number | number} total bytes written on\n  success, `-1` if the writer is errored or an async operation is in\n  flight. Idempotent when already closed.\n* `fail(reason)` {Function} Puts the writer into a terminal error state.\n  Synchronous. If the writer is already closed or errored, this is a\n  no-op. If `autoClose` is true, closes the file handle synchronously."}},"description":"Return a [`node:stream/iter`](stream_iter.html) writer backed by this file handle.\n\nThe writer supports both `Symbol.asyncDispose` and `Symbol.dispose`:\n\n* `await using w = fh.writer()` — if the writer is still open (no `end()`\n  called), `asyncDispose` calls `fail()`. If `end()` is pending, it waits\n  for it to complete.\n* `using w = fh.writer()` — calls `fail()` unconditionally.\n\nThe `writeSync()` and `writevSync()` methods enable the try-sync fast path\nused by [`stream/iter pipeTo()`](stream_iter.html#pipetosource-transforms-writer-options). When the reader's chunk size matches the\nwriter's `chunkSize`, all writes in a `pipeTo()` pipeline complete\nsynchronously with zero promise overhead.\n\nThis function is only available when the `--experimental-stream-iter` flag is\nenabled.\n\n```mjs\nimport { open } from 'node:fs/promises';\nimport { from, pipeTo } from 'node:stream/iter';\nimport { compressGzip } from 'node:zlib/iter';\n\n// Async pipeline\nconst fh = await open('output.gz', 'w');\nawait pipeTo(from('Hello!'), compressGzip(), fh.writer({ autoClose: true }));\n\n// Sync pipeline with limit\nconst src = await open('input.txt', 'r');\nconst dst = await open('output.txt', 'w');\nconst w = dst.writer({ limit: 1024 * 1024 }); // Max 1 MB\nawait pipeTo(src.pull({ autoClose: true }), w);\nawait w.end();\nawait dst.close();\n```\n\n```cjs\nconst { open } = require('node:fs/promises');\nconst { from, pipeTo } = require('node:stream/iter');\nconst { compressGzip } = require('node:zlib/iter');\n\nasync function run() {\n  // Async pipeline\n  const fh = await open('output.gz', 'w');\n  await pipeTo(from('Hello!'), compressGzip(), fh.writer({ autoClose: true }));\n\n  // Sync pipeline with limit\n  const src = await open('input.txt', 'r');\n  const dst = await open('output.txt', 'w');\n  const w = dst.writer({ limit: 1024 * 1024 }); // Max 1 MB\n  await pipeTo(src.pull({ autoClose: true }), w);\n  await w.end();\n  await dst.close();\n}\n\nrun().catch(console.error);\n```","summary":"Return a `node:stream/iter` writer backed by this file handle.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\nimport { from, pipeTo } from 'node:stream/iter';\nimport { compressGzip } from 'node:zlib/iter';\n\n// Async pipeline\nconst fh = await open('output.gz', 'w');\nawait pipeTo(from('Hello!'), compressGzip(), fh.writer({ autoClose: true }));\n\n// Sync pipeline with limit\nconst src = await open('input.txt', 'r');\nconst dst = await open('output.txt', 'w');\nconst w = dst.writer({ limit: 1024 * 1024 }); // Max 1 MB\nawait pipeTo(src.pull({ autoClose: true }), w);\nawait w.end();\nawait dst.close();"},{"language":"cjs","displayName":null,"code":"const { open } = require('node:fs/promises');\nconst { from, pipeTo } = require('node:stream/iter');\nconst { compressGzip } = require('node:zlib/iter');\n\nasync function run() {\n  // Async pipeline\n  const fh = await open('output.gz', 'w');\n  await pipeTo(from('Hello!'), compressGzip(), fh.writer({ autoClose: true }));\n\n  // Sync pipeline with limit\n  const src = await open('input.txt', 'r');\n  const dst = await open('output.txt', 'w');\n  const w = dst.writer({ limit: 1024 * 1024 }); // Max 1 MB\n  await pipeTo(src.pull({ autoClose: true }), w);\n  await w.end();\n  await dst.close();\n}\n\nrun().catch(console.error);"}],"children":[]},{"kind":"method","id":"filehandlesymbolasyncdispose","name":"[Symbol.asyncDispose]","title":"`filehandle[Symbol.asyncDispose]()`","scope":"module","overloadOf":null,"stability":null,"added":["v20.4.0","v18.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.2.0"],"prUrl":"https://github.com/nodejs/node/pull/58467","commit":null,"description":"No longer experimental."}],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Calls `filehandle.close()` and returns a promise that fulfills when the\nfilehandle is closed.\n\nThis method enables the filehandle to be used with [`await using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/await_using), which\nwill automatically close the file when the scope exits. For more information,\nsee the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using).","summary":"Calls `filehandle.close()` and returns a promise that fulfills when the filehandle is closed.","examples":[],"children":[]}]},{"kind":"method","id":"fspromisesaccesspath-mode","name":"access","title":"`fsPromises.access(path[, mode])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"fs.constants.F_OK","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Tests a user's permissions for the file or directory specified by `path`.\nThe `mode` argument is an optional integer that specifies the accessibility\nchecks to be performed. `mode` should be either the value `fs.constants.F_OK`\nor a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,\n`fs.constants.W_OK`, and `fs.constants.X_OK` (e.g.\n`fs.constants.W_OK | fs.constants.R_OK`). Check [File access constants](#file-access-constants) for\npossible values of `mode`.\n\nIf the accessibility check is successful, the promise is fulfilled with no\nvalue. If any of the accessibility checks fail, the promise is rejected\nwith an {Error} object. The following example checks if the file\n`/etc/passwd` can be read and written by the current process.\n\n```mjs\nimport { access, constants } from 'node:fs/promises';\n\ntry {\n  await access('/etc/passwd', constants.R_OK | constants.W_OK);\n  console.log('can access');\n} catch {\n  console.error('cannot access');\n}\n```\n\nUsing `fsPromises.access()` to check for the accessibility of a file before\ncalling `fsPromises.open()` is not recommended. Doing so introduces a race\ncondition, since other processes may change the file's state between the two\ncalls. Instead, user code should open/read/write the file directly and handle\nthe error raised if the file is not accessible.","summary":"Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK` (e.g. `fs.constants.W_OK | fs.constants.R_OK`). Check File access constants for possible values of `mode`.","examples":[{"language":"mjs","displayName":null,"code":"import { access, constants } from 'node:fs/promises';\n\ntry {\n  await access('/etc/passwd', constants.R_OK | constants.W_OK);\n  console.log('can access');\n} catch {\n  console.error('cannot access');\n}"}],"children":[]},{"kind":"method","id":"fspromisesappendfilepath-data-options","name":"appendFile","title":"`fsPromises.appendFile(path, data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.1.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50095","commit":null,"description":"The `flush` option is now supported."},{"versions":["v15.14.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/37490","commit":null,"description":"The `data` argument supports `AsyncIterable`, `Iterable`, and `Stream`."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | FileHandle","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"FileHandle","href":"fs.html#class-filehandle","start":24,"end":34}]},"description":"filename or {FileHandle}","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView | AsyncIterable | Iterable","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39},{"name":"AsyncIterable","href":"https://tc39.github.io/ecma262/#sec-asynciterable-interface","start":42,"end":55},{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":58,"end":66}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'a'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, the underlying file descriptor is flushed\nprior to closing it.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Asynchronously append data to a file, creating the file if it does not yet\n`data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object.\n\nIf `options` is a string, then it specifies the `encoding`.\n\nThe `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\nThe `path` may be specified as a {FileHandle} that has been opened\nfor appending (using `fsPromises.open()`).","summary":"Asynchronously append data to a file, creating the file if it does not yet `data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object.","examples":[],"children":[]},{"kind":"method","id":"fspromiseschmodpath-mode","name":"chmod","title":"`fsPromises.chmod(path, mode)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the permissions of a file.","summary":"Changes the permissions of a file.","examples":[],"children":[]},{"kind":"method","id":"fspromiseschownpath-uid-gid","name":"chown","title":"`fsPromises.chown(path, uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the ownership of a file.","summary":"Changes the ownership of a file.","examples":[],"children":[]},{"kind":"method","id":"fspromisescopyfilesrc-dest-mode","name":"copyFile","title":"`fsPromises.copyFile(src, dest[, mode])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/27044","commit":null,"description":"Changed `flags` argument to `mode` and imposed stricter type validation."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"source filename to copy","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"destination filename of the copy operation","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Optional modifiers that specify the behavior of the copy\noperation. It is possible to create a mask consisting of the bitwise OR of\ntwo or more values (e.g.\n`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)","default":"0","optional":true,"rest":false,"properties":[{"name":"fs.constants.COPYFILE_EXCL","type":null,"description":"The copy operation will fail if `dest`\nalready exists.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fs.constants.COPYFILE_FICLONE","type":null,"description":"The copy operation will attempt to create\na copy-on-write reflink. If the platform does not support copy-on-write,\nthen a fallback copy mechanism is used.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fs.constants.COPYFILE_FICLONE_FORCE","type":null,"description":"The copy operation will attempt to\ncreate a copy-on-write reflink. If the platform does not support\ncopy-on-write, then the operation will fail.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it\nalready exists.\n\nSymbolic links are followed. If `src` is a symbolic link, the target file is\ncopied. If `dest` is a symbolic link, the target file is overwritten unless\n`mode` contains `fs.constants.COPYFILE_EXCL`.\n\nNo guarantees are made about the atomicity of the copy operation. If an\nerror occurs after the destination file has been opened for writing, an attempt\nwill be made to remove the destination.\n\n```mjs\nimport { copyFile, constants } from 'node:fs/promises';\n\ntry {\n  await copyFile('source.txt', 'destination.txt');\n  console.log('source.txt was copied to destination.txt');\n} catch {\n  console.error('The file could not be copied');\n}\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ntry {\n  await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);\n  console.log('source.txt was copied to destination.txt');\n} catch {\n  console.error('The file could not be copied');\n}\n```","summary":"Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists.","examples":[{"language":"mjs","displayName":null,"code":"import { copyFile, constants } from 'node:fs/promises';\n\ntry {\n  await copyFile('source.txt', 'destination.txt');\n  console.log('source.txt was copied to destination.txt');\n} catch {\n  console.error('The file could not be copied');\n}\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ntry {\n  await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);\n  console.log('source.txt was copied to destination.txt');\n} catch {\n  console.error('The file could not be copied');\n}"}],"children":[]},{"kind":"method","id":"fspromisescpsrc-dest-options","name":"cp","title":"`fsPromises.cp(src, dest[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.3.0"],"prUrl":"https://github.com/nodejs/node/pull/53127","commit":null,"description":"This API is no longer experimental."},{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/47084","commit":null,"description":"Accept an additional `mode` option to specify the copy behavior as the `mode` argument of `fs.copyFile()`."},{"versions":["v17.6.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41819","commit":null,"description":"Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"dereference","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"dereference symlinks.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"errorOnExist","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"when `force` is `false`, and the destination\nexists, throw an error.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"filter","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"Function to filter copied files/directories. Return\n`true` to copy the item, `false` to ignore it. When ignoring a directory,\nall of its contents will be skipped as well. Can also return a `Promise`\nthat resolves to `true` or `false`","default":"undefined","optional":true,"rest":false,"properties":[{"name":"src","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"boolean | Promise","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7},{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":10,"end":17}]},"description":"A value that is coercible to `boolean` or\na `Promise` that fulfils with such value.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"overwrite existing file or directory. The copy\noperation will ignore errors if you set this to false and the destination\nexists. Use the `errorOnExist` option to change this behavior.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"modifiers for copy operation.","default":"0`. See `mode` flag of `fsPromises.copyFile()","optional":true,"rest":false,"properties":[]},{"name":"preserveTimestamps","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true` timestamps from `src` will\nbe preserved.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"copy directories recursively","default":"false","optional":true,"rest":false,"properties":[]},{"name":"verbatimSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, path resolution for symlinks will\nbe skipped.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Asynchronously copies the entire directory structure from `src` to `dest`,\nincluding subdirectories and files.\n\nWhen copying a directory to another directory, globs are not supported and\nbehavior is similar to `cp dir1/ dir2/`.","summary":"Asynchronously copies the entire directory structure from `src` to `dest`, including subdirectories and files.","examples":[],"children":[]},{"kind":"method","id":"fspromisesglobpattern-options","name":"glob","title":"`fsPromises.glob(pattern[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v22.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62695","commit":null,"description":"Add support for the `followSymlinks` option."},{"versions":["v24.1.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/58182","commit":null,"description":"Add support for `URL` instances for `cwd` option."},{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."},{"versions":["v23.7.0","v22.14.0"],"prUrl":"https://github.com/nodejs/node/pull/56489","commit":null,"description":"Add support for `exclude` option to accept glob patterns."},{"versions":["v22.2.0"],"prUrl":"https://github.com/nodejs/node/pull/52837","commit":null,"description":"Add support for `withFileTypes` as an option."}],"signature":{"parameters":[{"name":"pattern","type":{"text":"string | string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"cwd","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"current working directory.","default":"process.cwd()","optional":true,"rest":false,"properties":[]},{"name":"exclude","type":{"text":"Function | string[]","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":11,"end":17}]},"description":"Function to filter out files/directories or a\nlist of glob patterns to be excluded. If a function is provided, return\n`true` to exclude the item, `false` to include it.","default":"`undefined`. If a string array is provided, each string should be a glob pattern that specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are not supported","optional":true,"rest":false,"properties":[]},{"name":"followSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, symbolic links to directories are\nfollowed while expanding `**` patterns.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the glob should return paths as Dirents,\n`false` otherwise.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"AsyncIterator","links":[{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":0,"end":13}]},"description":"An AsyncIterator that yields the paths of files\nthat match the pattern."}},"description":"When `followSymlinks` is enabled, detected symbolic link cycles are not\ntraversed recursively.\n\n```mjs\nimport { glob } from 'node:fs/promises';\n\nfor await (const entry of glob('**/*.js'))\n  console.log(entry);\n```\n\n```cjs\nconst { glob } = require('node:fs/promises');\n\n(async () => {\n  for await (const entry of glob('**/*.js'))\n    console.log(entry);\n})();\n```","summary":"When `followSymlinks` is enabled, detected symbolic link cycles are not traversed recursively.","examples":[{"language":"mjs","displayName":null,"code":"import { glob } from 'node:fs/promises';\n\nfor await (const entry of glob('**/*.js'))\n  console.log(entry);"},{"language":"cjs","displayName":null,"code":"const { glob } = require('node:fs/promises');\n\n(async () => {\n  for await (const entry of glob('**/*.js'))\n    console.log(entry);\n})();"}],"children":[]},{"kind":"method","id":"fspromiseslchmodpath-mode","name":"lchmod","title":"`fsPromises.lchmod(path, mode)`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v10.0.0"],"deprecated":["v10.0.0"],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the permissions on a symbolic link.\n\nThis method is only implemented on macOS.","summary":"Changes the permissions on a symbolic link.","examples":[],"children":[]},{"kind":"method","id":"fspromiseslchownpath-uid-gid","name":"lchown","title":"`fsPromises.lchown(path, uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.6.0"],"prUrl":"https://github.com/nodejs/node/pull/21498","commit":null,"description":"This API is no longer deprecated."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the ownership on a symbolic link.","summary":"Changes the ownership on a symbolic link.","examples":[],"children":[]},{"kind":"method","id":"fspromiseslutimespath-atime-mtime","name":"lutimes","title":"`fsPromises.lutimes(path, atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v14.5.0","v12.19.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Changes the access and modification times of a file in the same way as\n[`fsPromises.utimes()`](#fspromisesutimespath-atime-mtime), with the difference that if the path refers to a\nsymbolic link, then the link is not dereferenced: instead, the timestamps of\nthe symbolic link itself are changed.","summary":"Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a symbolic link, then the link is not dereferenced: instead, the timestamps of the symbolic link itself are changed.","examples":[],"children":[]},{"kind":"method","id":"fspromiseslinkexistingpath-newpath","name":"link","title":"`fsPromises.link(existingPath, newPath)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"existingPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX\n[`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.","summary":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX `link(2)` documentation for more detail.","examples":[],"children":[]},{"kind":"method","id":"fspromiseslstatpath-options","name":"lstat","title":"`fsPromises.lstat(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63143","commit":null,"description":"Accepts an additional `signal` option to allow aborting the operation."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An AbortSignal to cancel the operation.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the {fs.Stats} object for the given\nsymbolic link `path`."}},"description":"Equivalent to [`fsPromises.stat()`](#fspromisesstatpath-options) unless `path` refers to a symbolic link,\nin which case the link itself is stat-ed, not the file that it refers to.\nRefer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.","summary":"Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to. Refer to the POSIX `lstat(2)` document for more detail.","examples":[],"children":[]},{"kind":"method","id":"fspromisesmkdirpath-options","name":"mkdir","title":"`fsPromises.mkdir(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | integer","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"Not supported on Windows. See [File modes](#file-modes)\nfor more details.","default":"0o777","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Upon success, fulfills with `undefined` if `recursive`\nis `false`, or the first directory path created if `recursive` is `true`."}},"description":"Asynchronously creates a directory.\n\nThe optional `options` argument can be an integer specifying `mode` (permission\nand sticky bits), or an object with a `mode` property and a `recursive`\nproperty indicating whether parent directories should be created. Calling\n`fsPromises.mkdir()` when `path` is a directory that exists results in a\nrejection only when `recursive` is false.\n\n```mjs\nimport { mkdir } from 'node:fs/promises';\n\ntry {\n  const projectFolder = new URL('./test/project/', import.meta.url);\n  const createDir = await mkdir(projectFolder, { recursive: true });\n\n  console.log(`created ${createDir}`);\n} catch (err) {\n  console.error(err.message);\n}\n```\n\n```cjs\nconst { mkdir } = require('node:fs/promises');\nconst { join } = require('node:path');\n\nasync function makeDirectory() {\n  const projectFolder = join(__dirname, 'test', 'project');\n  const dirCreation = await mkdir(projectFolder, { recursive: true });\n\n  console.log(dirCreation);\n  return dirCreation;\n}\n\nmakeDirectory().catch(console.error);\n```","summary":"Asynchronously creates a directory.","examples":[{"language":"mjs","displayName":null,"code":"import { mkdir } from 'node:fs/promises';\n\ntry {\n  const projectFolder = new URL('./test/project/', import.meta.url);\n  const createDir = await mkdir(projectFolder, { recursive: true });\n\n  console.log(`created ${createDir}`);\n} catch (err) {\n  console.error(err.message);\n}"},{"language":"cjs","displayName":null,"code":"const { mkdir } = require('node:fs/promises');\nconst { join } = require('node:path');\n\nasync function makeDirectory() {\n  const projectFolder = join(__dirname, 'test', 'project');\n  const dirCreation = await mkdir(projectFolder, { recursive: true });\n\n  console.log(dirCreation);\n  return dirCreation;\n}\n\nmakeDirectory().catch(console.error);"}],"children":[]},{"kind":"method","id":"fspromisesmkdtempprefix-options","name":"mkdtemp","title":"`fsPromises.mkdtemp(prefix[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.6.0","v18.19.0"],"prUrl":"https://github.com/nodejs/node/pull/48828","commit":null,"description":"The `prefix` parameter now accepts buffers and URL."},{"versions":["v16.5.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/39028","commit":null,"description":"The `prefix` parameter now accepts an empty string."}],"signature":{"parameters":[{"name":"prefix","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a string containing the file system path\nof the newly created temporary directory."}},"description":"Creates a unique temporary directory. A unique directory name is generated by\nappending six random characters to the end of the provided `prefix`. Due to\nplatform inconsistencies, avoid trailing `X` characters in `prefix`. Some\nplatforms, notably the BSDs, can return more than six random characters, and\nreplace trailing `X` characters in `prefix` with random characters.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use.\n\n```mjs\nimport { mkdtemp } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\ntry {\n  await mkdtemp(join(tmpdir(), 'foo-'));\n} catch (err) {\n  console.error(err);\n}\n```\n\nThe `fsPromises.mkdtemp()` method will append the six randomly selected\ncharacters directly to the `prefix` string. For instance, given a directory\n`/tmp`, if the intention is to create a temporary directory *within* `/tmp`, the\n`prefix` must end with a trailing platform-specific path separator\n(`require('node:path').sep`).","summary":"Creates a unique temporary directory. A unique directory name is generated by appending six random characters to the end of the provided `prefix`. Due to platform inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms, notably the BSDs, can return more than six random characters, and replace trailing `X` characters in `prefix` with random characters.","examples":[{"language":"mjs","displayName":null,"code":"import { mkdtemp } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\ntry {\n  await mkdtemp(join(tmpdir(), 'foo-'));\n} catch (err) {\n  console.error(err);\n}"}],"children":[]},{"kind":"method","id":"fspromisesmkdtempdisposableprefix-options","name":"mkdtempDisposable","title":"`fsPromises.mkdtempDisposable(prefix[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v24.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"prefix","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a Promise for an async-disposable Object:"}},"description":"The resulting Promise holds an async-disposable object whose `path` property\nholds the created directory path. When the object is disposed, the directory\nand its contents will be removed asynchronously if it still exists. If the\ndirectory cannot be deleted, disposal will throw an error. The object has an\nasync `remove()` method which will perform the same task.\n\nBoth this function and the disposal function on the resulting object are\nasync, so it should be used with `await` + [`await using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/await_using) as in\n`await using dir = await fsPromises.mkdtempDisposable('prefix')`.\n\nSee the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using) for more information about\nexplicit resource management.\n\nFor detailed information, see the documentation of [`fsPromises.mkdtemp()`](#fspromisesmkdtempprefix-options).\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use.","summary":"The resulting Promise holds an async-disposable object whose `path` property holds the created directory path. When the object is disposed, the directory and its contents will be removed asynchronously if it still exists. If the directory cannot be deleted, disposal will throw an error. The object has an async `remove()` method which will perform the same task.","examples":[],"children":[]},{"kind":"method","id":"fspromisesopenpath-flags-mode","name":"open","title":"`fsPromises.open(path, flags[, mode])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v11.1.0"],"prUrl":"https://github.com/nodejs/node/pull/23767","commit":null,"description":"The `flags` argument is now optional and defaults to `'r'`."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"flags","type":{"text":"string | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":15}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"Sets the file mode (permission and sticky bits)\nif the file is created. See [File modes](#file-modes) for more details.","default":"`0o666` (readable and writable)","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {FileHandle} object."}},"description":"Opens a {FileHandle}.\n\nRefer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.\n\nSome characters (`< > : \" / \\ | ? *`) are reserved under Windows as documented\nby [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains\na colon, Node.js will open a file system stream, as described by\n[this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).","summary":"Opens a {FileHandle}.","examples":[],"children":[]},{"kind":"method","id":"fspromisesopendirpath-options","name":"opendir","title":"`fsPromises.opendir(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v13.1.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30114","commit":null,"description":"The `bufferSize` option was introduced."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"bufferSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number of directory entries that are buffered\ninternally when reading from the directory. Higher values lead to better\nperformance but higher memory usage.","default":"32","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Resolved `Dir` will be an {AsyncIterable}\ncontaining all sub files and directories.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with an {fs.Dir}."}},"description":"Asynchronously open a directory for iterative scanning. See the POSIX\n[`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.\n\nCreates an {fs.Dir}, which contains all further functions for reading from\nand cleaning up the directory.\n\nThe `encoding` option sets the encoding for the `path` while opening the\ndirectory and subsequent read operations.\n\nExample using async iteration:\n\n```mjs\nimport { opendir } from 'node:fs/promises';\n\ntry {\n  const dir = await opendir('./');\n  for await (const dirent of dir)\n    console.log(dirent.name);\n} catch (err) {\n  console.error(err);\n}\n```\n\nWhen using the async iterator, the {fs.Dir} object will be automatically\nclosed after the iterator exits.","summary":"Asynchronously open a directory for iterative scanning. See the POSIX `opendir(3)` documentation for more detail.","examples":[{"language":"mjs","displayName":null,"code":"import { opendir } from 'node:fs/promises';\n\ntry {\n  const dir = await opendir('./');\n  for await (const dirent of dir)\n    console.log(dirent.name);\n} catch (err) {\n  console.error(err);\n}"}],"children":[]},{"kind":"method","id":"fspromisesreaddirpath-options","name":"readdir","title":"`fsPromises.readdir(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v10.11.0"],"prUrl":"https://github.com/nodejs/node/pull/22020","commit":null,"description":"New option `withFileTypes` was added."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, reads the contents of a directory\nrecursively. In recursive mode, it will list all files, sub files, and\ndirectories.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with an array of the names of the files in\nthe directory excluding `'.'` and `'..'`."}},"description":"Reads the contents of a directory.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe filenames. If the `encoding` is set to `'buffer'`, the filenames returned\nwill be passed as {Buffer} objects.\n\nIf `options.withFileTypes` is set to `true`, the returned array will contain\n{fs.Dirent} objects.\n\n```mjs\nimport { readdir } from 'node:fs/promises';\n\ntry {\n  const files = await readdir(path);\n  for (const file of files)\n    console.log(file);\n} catch (err) {\n  console.error(err);\n}\n```","summary":"Reads the contents of a directory.","examples":[{"language":"mjs","displayName":null,"code":"import { readdir } from 'node:fs/promises';\n\ntry {\n  const files = await readdir(path);\n  for (const file of files)\n    console.log(file);\n} catch (err) {\n  console.error(err);\n}"}],"children":[]},{"kind":"method","id":"fspromisesreadfilepath-options","name":"readFile","title":"`fsPromises.readFile(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.4.0"],"prUrl":"https://github.com/nodejs/node/pull/63634","commit":null,"description":"Added support for the `buffer` option."},{"versions":["v15.2.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/35911","commit":null,"description":"The options argument may include an AbortSignal to abort an ongoing readFile request."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | FileHandle","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"FileHandle","href":"fs.html#class-filehandle","start":24,"end":34}]},"description":"filename or `FileHandle`","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows aborting an in-progress readFile","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView | Function","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":33,"end":41}]},"description":"A buffer to read into, or a\nfunction called with the file size that returns the buffer.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the contents of the file."}},"description":"Asynchronously reads the entire contents of a file.\n\nIf no encoding is specified (using `options.encoding`), the data is returned\nas a {Buffer} object. Otherwise, the data will be a string.\n\nIf `options` is a string, then it specifies the encoding.\n\nIf `buffer` is provided and no encoding is specified, the returned {Buffer} is\na view over the supplied buffer containing only the bytes read. If the\nsupplied buffer is too small to contain the entire file, the promise will be\nrejected.\n\nWhen the `path` is a directory, the behavior of `fsPromises.readFile()` is\nplatform-specific. On macOS, Linux, and Windows, the promise will be rejected\nwith an error. On FreeBSD, a representation of the directory's contents will be\nreturned.\n\nAn example of reading a `package.json` file located in the same directory of the\nrunning code:\n\n```mjs\nimport { readFile } from 'node:fs/promises';\ntry {\n  const filePath = new URL('./package.json', import.meta.url);\n  const contents = await readFile(filePath, { encoding: 'utf8' });\n  console.log(contents);\n} catch (err) {\n  console.error(err.message);\n}\n```\n\n```cjs\nconst { readFile } = require('node:fs/promises');\nconst { resolve } = require('node:path');\nasync function logFile() {\n  try {\n    const filePath = resolve('./package.json');\n    const contents = await readFile(filePath, { encoding: 'utf8' });\n    console.log(contents);\n  } catch (err) {\n    console.error(err.message);\n  }\n}\nlogFile();\n```\n\nIt is possible to abort an ongoing `readFile` using an {AbortSignal}. If a\nrequest is aborted the promise returned is rejected with an `AbortError`:\n\n```mjs\nimport { readFile } from 'node:fs/promises';\n\ntry {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const promise = readFile(fileName, { signal });\n\n  // Abort the request before the promise settles.\n  controller.abort();\n\n  await promise;\n} catch (err) {\n  // When a request is aborted - err is an AbortError\n  console.error(err);\n}\n```\n\nAborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering `fs.readFile` performs.\n\nAny specified {FileHandle} has to support reading.\n\nAn example using the `buffer` option with a pre-allocated buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs/promises';\n\nconst buf = Buffer.alloc(16384);\nconst contents = await readFile('/path/to/file', { buffer: buf });\nconsole.log(contents); // A view over `buf` containing only the bytes read\n```\n\nAn example using the `buffer` option with a function returning a buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs/promises';\n\nconst contents = await readFile('/path/to/file', {\n  buffer: (size) => Buffer.alloc(size),\n});\nconsole.log(contents);\n```","summary":"Asynchronously reads the entire contents of a file.","examples":[{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs/promises';\ntry {\n  const filePath = new URL('./package.json', import.meta.url);\n  const contents = await readFile(filePath, { encoding: 'utf8' });\n  console.log(contents);\n} catch (err) {\n  console.error(err.message);\n}"},{"language":"cjs","displayName":null,"code":"const { readFile } = require('node:fs/promises');\nconst { resolve } = require('node:path');\nasync function logFile() {\n  try {\n    const filePath = resolve('./package.json');\n    const contents = await readFile(filePath, { encoding: 'utf8' });\n    console.log(contents);\n  } catch (err) {\n    console.error(err.message);\n  }\n}\nlogFile();"},{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs/promises';\n\ntry {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const promise = readFile(fileName, { signal });\n\n  // Abort the request before the promise settles.\n  controller.abort();\n\n  await promise;\n} catch (err) {\n  // When a request is aborted - err is an AbortError\n  console.error(err);\n}"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs/promises';\n\nconst buf = Buffer.alloc(16384);\nconst contents = await readFile('/path/to/file', { buffer: buf });\nconsole.log(contents); // A view over `buf` containing only the bytes read"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs/promises';\n\nconst contents = await readFile('/path/to/file', {\n  buffer: (size) => Buffer.alloc(size),\n});\nconsole.log(contents);"}],"children":[]},{"kind":"method","id":"fspromisesreadlinkpath-options","name":"readlink","title":"`fsPromises.readlink(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the `linkString` upon success."}},"description":"Reads the contents of the symbolic link referred to by `path`. See the POSIX\n[`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is fulfilled with the `linkString` upon success.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe link path returned. If the `encoding` is set to `'buffer'`, the link path\nreturned will be passed as a {Buffer} object.","summary":"Reads the contents of the symbolic link referred to by `path`. See the POSIX `readlink(2)` documentation for more detail. The promise is fulfilled with the `linkString` upon success.","examples":[],"children":[]},{"kind":"method","id":"fspromisesrealpathpath-options","name":"realpath","title":"`fsPromises.realpath(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the resolved path upon success."}},"description":"Determines the actual location of `path` using the same semantics as the\n`fs.realpath.native()` function.\n\nOnly paths that can be converted to UTF8 strings are supported.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe path. If the `encoding` is set to `'buffer'`, the path returned will be\npassed as a {Buffer} object.\n\nOn Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on `/proc` in order for this function to work. Glibc does not have\nthis restriction.","summary":"Determines the actual location of `path` using the same semantics as the `fs.realpath.native()` function.","examples":[],"children":[]},{"kind":"method","id":"fspromisesrenameoldpath-newpath","name":"rename","title":"`fsPromises.rename(oldPath, newPath)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"oldPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Renames `oldPath` to `newPath`.","summary":"Renames `oldPath` to `newPath`.","examples":[],"children":[]},{"kind":"method","id":"fspromisesrmdirpath-options","name":"rmdir","title":"`fsPromises.rmdir(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.0.0"],"prUrl":"https://github.com/nodejs/node/pull/58616","commit":null,"description":"Remove `recursive` option."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fsPromises.rmdir(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fsPromises.rmdir(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37302","commit":null,"description":"The `recursive` option is deprecated, using it triggers a deprecation warning."},{"versions":["v14.14.0"],"prUrl":"https://github.com/nodejs/node/pull/35579","commit":null,"description":"The `recursive` option is deprecated, use `fsPromises.rm` instead."},{"versions":["v13.3.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30644","commit":null,"description":"The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."},{"versions":["v12.10.0"],"prUrl":"https://github.com/nodejs/node/pull/29168","commit":null,"description":"The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"There are currently no options exposed. There used to\nbe options for `recursive`, `maxBusyTries`, and `emfileWait` but they were\ndeprecated and removed. The `options` argument is still accepted for\nbackwards compatibility but it is not used.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Removes the directory identified by `path`.\n\nUsing `fsPromises.rmdir()` on a file (not a directory) results in the\npromise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`\nerror on POSIX.\n\nTo get a behavior similar to the `rm -rf` Unix command, use\n[`fsPromises.rm()`](#fspromisesrmpath-options) with options `{ recursive: true, force: true }`.","summary":"Removes the directory identified by `path`.","examples":[],"children":[]},{"kind":"method","id":"fspromisesrmpath-options","name":"rm","title":"`fsPromises.rm(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v14.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, exceptions will be ignored if `path` does\nnot exist.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"maxRetries","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n`EPERM` error is encountered, Node.js will retry the operation with a linear\nbackoff wait of `retryDelay` milliseconds longer on each try. This option\nrepresents the number of retries. This option is ignored if the `recursive`\noption is not `true`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, perform a recursive directory removal. In\nrecursive mode operations are retried on failure.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"retryDelay","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The amount of time in milliseconds to wait between\nretries. This option is ignored if the `recursive` option is not `true`.","default":"100","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Removes files and directories (modeled on the standard POSIX `rm` utility).","summary":"Removes files and directories (modeled on the standard POSIX `rm` utility).","examples":[],"children":[]},{"kind":"method","id":"fspromisesstatpath-options","name":"stat","title":"`fsPromises.stat(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63143","commit":null,"description":"Accepts an additional `signal` option to allow aborting the operation."},{"versions":["v25.7.0"],"prUrl":"https://github.com/nodejs/node/pull/61178","commit":null,"description":"Accepts a `throwIfNoEntry` option to specify whether an exception should be thrown if the entry does not exist."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"throwIfNoEntry","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether an exception will be thrown\nif no file system entry exists, rather than returning `undefined`.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An AbortSignal to cancel the operation.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the {fs.Stats} object for the\ngiven `path`."}},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"fspromisesstatfspath-options","name":"statfs","title":"`fsPromises.statfs(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.StatFs} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with the {fs.StatFs} object for the\ngiven `path`."}},"description":"","summary":"","examples":[],"children":[]},{"kind":"method","id":"fspromisessymlinktarget-path-type","name":"symlink","title":"`fsPromises.symlink(target, path[, type])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v19.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42894","commit":null,"description":"If the `type` argument is `null` or omitted, Node.js will autodetect `target` type and automatically select `dir` or `file`."}],"signature":{"parameters":[{"name":"target","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"type","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Creates a symbolic link.\n\nThe `type` argument is only used on Windows platforms and can be one of `'dir'`,\n`'file'`, or `'junction'`. If the `type` argument is `null`, Node.js will\nautodetect `target` type and use `'file'` or `'dir'`. If the `target` does not\nexist, `'file'` will be used. Windows junction points require the destination\npath to be absolute. When using `'junction'`, the `target` argument will\nautomatically be normalized to absolute path. Junction points on NTFS volumes\ncan only point to directories.","summary":"Creates a symbolic link.","examples":[],"children":[]},{"kind":"method","id":"fspromisestruncatepath-len","name":"truncate","title":"`fsPromises.truncate(path[, len])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Truncates (shortens or extends the length) of the content at `path` to `len`\nbytes.","summary":"Truncates (shortens or extends the length) of the content at `path` to `len` bytes.","examples":[],"children":[]},{"kind":"method","id":"fspromisesunlinkpath","name":"unlink","title":"`fsPromises.unlink(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"If `path` refers to a symbolic link, then the link is removed without affecting\nthe file or directory to which that link refers. If the `path` refers to a file\npath that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html)\ndocumentation for more detail.","summary":"If `path` refers to a symbolic link, then the link is removed without affecting the file or directory to which that link refers. If the `path` refers to a file path that is not a symbolic link, the file is deleted. See the POSIX `unlink(2)` documentation for more detail.","examples":[],"children":[]},{"kind":"method","id":"fspromisesutimespath-atime-mtime","name":"utimes","title":"`fsPromises.utimes(path, atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Change the file system timestamps of the object referenced by `path`.\n\nThe `atime` and `mtime` arguments follow these rules:\n\n* Values can be either numbers representing Unix epoch time, `Date`s, or a\n  numeric string like `'123456789.0'`.\n* If the value can not be converted to a number, or is `NaN`, `Infinity`, or\n  `-Infinity`, an `Error` will be thrown.","summary":"Change the file system timestamps of the object referenced by `path`.","examples":[],"children":[]},{"kind":"method","id":"fspromiseswatchfilename-options","name":"watch","title":"`fsPromises.watch(filename[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.9.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"filename","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"persistent","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Indicates whether the process should continue to run\nas long as files are being watched.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Indicates whether all subdirectories should be\nwatched, or only the current directory. This applies when a directory is\nspecified, and only on supported platforms (See [caveats](#caveats)).","default":"false","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Specifies the character encoding to be used for the\nfilename passed to the listener.","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An {AbortSignal} used to signal when the watcher\nshould stop.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"maxQueue","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Specifies the number of events to queue between iterations\nof the {AsyncIterator} returned.","default":"2048","optional":true,"rest":false,"properties":[]},{"name":"overflow","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Either `'ignore'` or `'throw'` when there are more events to be\nqueued than `maxQueue` allows. `'ignore'` means overflow events are dropped and a\nwarning is emitted, while `'throw'` means to throw an exception.","default":"'ignore'","optional":true,"rest":false,"properties":[]},{"name":"ignore","type":{"text":"string | RegExp | Function | Array","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"RegExp","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp","start":9,"end":15},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":18,"end":26},{"name":"Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array","start":29,"end":34}]},"description":"Pattern(s) to ignore. Strings are\nglob patterns (using [`minimatch`](https://github.com/isaacs/minimatch)), RegExp patterns are tested against\nthe filename, and functions receive the filename and return `true` to\nignore.","default":"undefined","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"AsyncIterator","links":[{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":0,"end":13}]},"description":"of objects with the properties:"}},"description":"Returns an async iterator that watches for changes on `filename`, where `filename`\nis either a file or a directory.\n\n```js\nconst { watch } = require('node:fs/promises');\n\nconst ac = new AbortController();\nconst { signal } = ac;\nsetTimeout(() => ac.abort(), 10000);\n\n(async () => {\n  try {\n    const watcher = watch(__filename, { signal });\n    for await (const event of watcher)\n      console.log(event);\n  } catch (err) {\n    if (err.name === 'AbortError')\n      return;\n    throw err;\n  }\n})();\n```\n\nOn most platforms, `'rename'` is emitted whenever a filename appears or\ndisappears in the directory.\n\nAll the [caveats](#caveats) for `fs.watch()` also apply to `fsPromises.watch()`.","summary":"Returns an async iterator that watches for changes on `filename`, where `filename` is either a file or a directory.","examples":[{"language":"js","displayName":null,"code":"const { watch } = require('node:fs/promises');\n\nconst ac = new AbortController();\nconst { signal } = ac;\nsetTimeout(() => ac.abort(), 10000);\n\n(async () => {\n  try {\n    const watcher = watch(__filename, { signal });\n    for await (const event of watcher)\n      console.log(event);\n  } catch (err) {\n    if (err.name === 'AbortError')\n      return;\n    throw err;\n  }\n})();"}],"children":[]},{"kind":"method","id":"fspromiseswritefilefile-data-options","name":"writeFile","title":"`fsPromises.writeFile(file, data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50009","commit":null,"description":"The `flush` option is now supported."},{"versions":["v15.14.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/37490","commit":null,"description":"The `data` argument supports `AsyncIterable`, `Iterable`, and `Stream`."},{"versions":["v15.2.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/35993","commit":null,"description":"The options argument may include an AbortSignal to abort an ongoing writeFile request."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `data` parameter won't coerce unsupported input to strings anymore."}],"signature":{"parameters":[{"name":"file","type":{"text":"string | Buffer | URL | FileHandle","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"FileHandle","href":"fs.html#class-filehandle","start":24,"end":34}]},"description":"filename or `FileHandle`","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView | AsyncIterable | Iterable","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39},{"name":"AsyncIterable","href":"https://tc39.github.io/ecma262/#sec-asynciterable-interface","start":42,"end":55},{"name":"Iterable","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol","start":58,"end":66}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'w'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If all data is successfully written to the file, and\n`flush` is `true`, `filehandle.sync()` is used to flush the data.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows aborting an in-progress writeFile","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with `undefined` upon success."}},"description":"Asynchronously writes data to a file, replacing the file if it already exists.\n`data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object.\n\nThe `encoding` option is ignored if `data` is a buffer.\n\nIf `options` is a string, then it specifies the encoding.\n\nThe `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\nAny specified {FileHandle} has to support writing.\n\nIt is unsafe to use `fsPromises.writeFile()` multiple times on the same file\nwithout waiting for the promise to be settled.\n\nSimilarly to `fsPromises.readFile` - `fsPromises.writeFile` is a convenience\nmethod that performs multiple `write` calls internally to write the buffer\npassed to it. For performance sensitive code consider using\n[`fs.createWriteStream()`](#fscreatewritestreampath-options) or [`filehandle.createWriteStream()`](#filehandlecreatewritestreamoptions).\n\nIt is possible to use an {AbortSignal} to cancel an `fsPromises.writeFile()`.\nCancelation is \"best effort\", and some amount of data is likely still\nto be written.\n\n```mjs\nimport { writeFile } from 'node:fs/promises';\nimport { Buffer } from 'node:buffer';\n\ntry {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const data = new Uint8Array(Buffer.from('Hello Node.js'));\n  const promise = writeFile('message.txt', data, { signal });\n\n  // Abort the request before the promise settles.\n  controller.abort();\n\n  await promise;\n} catch (err) {\n  // When a request is aborted - err is an AbortError\n  console.error(err);\n}\n```\n\nAborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering `fs.writeFile` performs.","summary":"Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object.","examples":[{"language":"mjs","displayName":null,"code":"import { writeFile } from 'node:fs/promises';\nimport { Buffer } from 'node:buffer';\n\ntry {\n  const controller = new AbortController();\n  const { signal } = controller;\n  const data = new Uint8Array(Buffer.from('Hello Node.js'));\n  const promise = writeFile('message.txt', data, { signal });\n\n  // Abort the request before the promise settles.\n  controller.abort();\n\n  await promise;\n} catch (err) {\n  // When a request is aborted - err is an AbortError\n  console.error(err);\n}"}],"children":[]},{"kind":"property","id":"fspromisesconstants","name":"constants","title":"`fsPromises.constants`","scope":"module","overloadOf":null,"stability":null,"added":["v18.4.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"Returns an object containing commonly used constants for file system\noperations. The object is the same as `fs.constants`. See [FS constants](#fs-constants)\nfor more details.","summary":"Returns an object containing commonly used constants for file system operations. The object is the same as `fs.constants`. See FS constants for more details.","examples":[],"children":[]}]},{"kind":"section","id":"callback-api","name":"Callback API","title":"Callback API","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The callback APIs perform all operations asynchronously, without blocking the\nevent loop, then invoke a callback function upon completion or error.\n\nThe callback APIs use the underlying Node.js threadpool to perform file\nsystem operations off the event loop thread. These operations are not\nsynchronized or threadsafe. Care must be taken when performing multiple\nconcurrent modifications on the same file or data corruption may occur.","summary":"The callback APIs perform all operations asynchronously, without blocking the event loop, then invoke a callback function upon completion or error.","examples":[],"children":[{"kind":"method","id":"fsaccesspath-mode-callback","name":"access","title":"`fs.access(path[, mode], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.0.0"],"prUrl":"https://github.com/nodejs/node/pull/55862","commit":null,"description":"The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK` which were present directly on `fs` are removed."},{"versions":["v20.8.0"],"prUrl":"https://github.com/nodejs/node/pull/49683","commit":null,"description":"The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK` which were present directly on `fs` are deprecated."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v6.3.0"],"prUrl":"https://github.com/nodejs/node/pull/6534","commit":null,"description":"The constants like `fs.R_OK`, etc which were present directly on `fs` were moved into `fs.constants` as a soft deprecation. Thus for Node.js `< v6.3.0` use `fs` to access those constants, or do something like `(fs.constants || fs).R_OK` to work with all versions."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"fs.constants.F_OK","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Tests a user's permissions for the file or directory specified by `path`.\nThe `mode` argument is an optional integer that specifies the accessibility\nchecks to be performed. `mode` should be either the value `fs.constants.F_OK`\nor a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,\n`fs.constants.W_OK`, and `fs.constants.X_OK` (e.g.\n`fs.constants.W_OK | fs.constants.R_OK`). Check [File access constants](#file-access-constants) for\npossible values of `mode`.\n\nThe final argument, `callback`, is a callback function that is invoked with\na possible error argument. If any of the accessibility checks fail, the error\nargument will be an `Error` object. The following examples check if\n`package.json` exists, and if it is readable or writable.\n\n```mjs\nimport { access, constants } from 'node:fs';\n\nconst file = 'package.json';\n\n// Check if the file exists in the current directory.\naccess(file, constants.F_OK, (err) => {\n  console.log(`${file} ${err ? 'does not exist' : 'exists'}`);\n});\n\n// Check if the file is readable.\naccess(file, constants.R_OK, (err) => {\n  console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);\n});\n\n// Check if the file is writable.\naccess(file, constants.W_OK, (err) => {\n  console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);\n});\n\n// Check if the file is readable and writable.\naccess(file, constants.R_OK | constants.W_OK, (err) => {\n  console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);\n});\n```\n\nDo not use `fs.access()` to check for the accessibility of a file before calling\n`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file is not accessible.\n\n**write (NOT RECOMMENDED)**\n\n```mjs\nimport { access, open, close } from 'node:fs';\n\naccess('myfile', (err) => {\n  if (!err) {\n    console.error('myfile already exists');\n    return;\n  }\n\n  open('myfile', 'wx', (err, fd) => {\n    if (err) throw err;\n\n    try {\n      writeMyData(fd);\n    } finally {\n      close(fd, (err) => {\n        if (err) throw err;\n      });\n    }\n  });\n});\n```\n\n**write (RECOMMENDED)**\n\n```mjs\nimport { open, close } from 'node:fs';\n\nopen('myfile', 'wx', (err, fd) => {\n  if (err) {\n    if (err.code === 'EEXIST') {\n      console.error('myfile already exists');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    writeMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});\n```\n\n**read (NOT RECOMMENDED)**\n\n```mjs\nimport { access, open, close } from 'node:fs';\naccess('myfile', (err) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  open('myfile', 'r', (err, fd) => {\n    if (err) throw err;\n\n    try {\n      readMyData(fd);\n    } finally {\n      close(fd, (err) => {\n        if (err) throw err;\n      });\n    }\n  });\n});\n```\n\n**read (RECOMMENDED)**\n\n```mjs\nimport { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    readMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});\n```\n\nThe \"not recommended\" examples above check for accessibility and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.\n\nIn general, check for the accessibility of a file only if the file will not be\nused directly, for example when its accessibility is a signal from another\nprocess.\n\nOn Windows, access-control policies (ACLs) on a directory may limit access to\na file or directory. The `fs.access()` function, however, does not check the\nACL and therefore may report that a path is accessible even if the ACL restricts\nthe user from reading or writing to it.","summary":"Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK` (e.g. `fs.constants.W_OK | fs.constants.R_OK`). Check File access constants for possible values of `mode`.","examples":[{"language":"mjs","displayName":null,"code":"import { access, constants } from 'node:fs';\n\nconst file = 'package.json';\n\n// Check if the file exists in the current directory.\naccess(file, constants.F_OK, (err) => {\n  console.log(`${file} ${err ? 'does not exist' : 'exists'}`);\n});\n\n// Check if the file is readable.\naccess(file, constants.R_OK, (err) => {\n  console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);\n});\n\n// Check if the file is writable.\naccess(file, constants.W_OK, (err) => {\n  console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);\n});\n\n// Check if the file is readable and writable.\naccess(file, constants.R_OK | constants.W_OK, (err) => {\n  console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);\n});"},{"language":"mjs","displayName":null,"code":"import { access, open, close } from 'node:fs';\n\naccess('myfile', (err) => {\n  if (!err) {\n    console.error('myfile already exists');\n    return;\n  }\n\n  open('myfile', 'wx', (err, fd) => {\n    if (err) throw err;\n\n    try {\n      writeMyData(fd);\n    } finally {\n      close(fd, (err) => {\n        if (err) throw err;\n      });\n    }\n  });\n});"},{"language":"mjs","displayName":null,"code":"import { open, close } from 'node:fs';\n\nopen('myfile', 'wx', (err, fd) => {\n  if (err) {\n    if (err.code === 'EEXIST') {\n      console.error('myfile already exists');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    writeMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});"},{"language":"mjs","displayName":null,"code":"import { access, open, close } from 'node:fs';\naccess('myfile', (err) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  open('myfile', 'r', (err, fd) => {\n    if (err) throw err;\n\n    try {\n      readMyData(fd);\n    } finally {\n      close(fd, (err) => {\n        if (err) throw err;\n      });\n    }\n  });\n});"},{"language":"mjs","displayName":null,"code":"import { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    readMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});"}],"children":[]},{"kind":"method","id":"fsappendfilepath-data-options-callback","name":"appendFile","title":"`fs.appendFile(path, data[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.6.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.1.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50095","commit":null,"description":"The `flush` option is now supported."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7831","commit":null,"description":"The passed `options` object will never be modified."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `file` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":30}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'a'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, the underlying file descriptor is flushed\nprior to closing it.","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously append data to a file, creating the file if it does not yet\nexist. `data` can be a string or a {Buffer}.\n\nThe `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\n```mjs\nimport { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', (err) => {\n  if (err) throw err;\n  console.log('The \"data to append\" was appended to file!');\n});\n```\n\nIf `options` is a string, then it specifies the encoding:\n\n```mjs\nimport { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', 'utf8', callback);\n```\n\nThe `path` may be specified as a numeric file descriptor that has been opened\nfor appending (using `fs.open()` or `fs.openSync()`). The file descriptor will\nnot be closed automatically.\n\n```mjs\nimport { open, close, appendFile } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('message.txt', 'a', (err, fd) => {\n  if (err) throw err;\n\n  try {\n    appendFile(fd, 'data to append', 'utf8', (err) => {\n      closeFd(fd);\n      if (err) throw err;\n    });\n  } catch (err) {\n    closeFd(fd);\n    throw err;\n  }\n});\n```","summary":"Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a {Buffer}.","examples":[{"language":"mjs","displayName":null,"code":"import { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', (err) => {\n  if (err) throw err;\n  console.log('The \"data to append\" was appended to file!');\n});"},{"language":"mjs","displayName":null,"code":"import { appendFile } from 'node:fs';\n\nappendFile('message.txt', 'data to append', 'utf8', callback);"},{"language":"mjs","displayName":null,"code":"import { open, close, appendFile } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('message.txt', 'a', (err, fd) => {\n  if (err) throw err;\n\n  try {\n    appendFile(fd, 'data to append', 'utf8', (err) => {\n      closeFd(fd);\n      if (err) throw err;\n    });\n  } catch (err) {\n    closeFd(fd);\n    throw err;\n  }\n});"}],"children":[]},{"kind":"method","id":"fschmodpath-mode-callback","name":"chmod","title":"`fs.chmod(path, mode, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.30"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously changes the permissions of a file. No arguments other than a\npossible exception are given to the completion callback.\n\nSee the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.\n\n```mjs\nimport { chmod } from 'node:fs';\n\nchmod('my_file.txt', 0o775, (err) => {\n  if (err) throw err;\n  console.log('The permissions for file \"my_file.txt\" have been changed!');\n});\n```","summary":"Asynchronously changes the permissions of a file. No arguments other than a possible exception are given to the completion callback.","examples":[{"language":"mjs","displayName":null,"code":"import { chmod } from 'node:fs';\n\nchmod('my_file.txt', 0o775, (err) => {\n  if (err) throw err;\n  console.log('The permissions for file \"my_file.txt\" have been changed!');\n});"}],"children":[{"kind":"section","id":"file-modes","name":"File modes","title":"File modes","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `mode` argument used in both the `fs.chmod()` and `fs.chmodSync()`\nmethods is a numeric bitmask created using a logical OR of the following\nconstants:\n\n| Constant               | Octal   | Description              |\n| ---------------------- | ------- | ------------------------ |\n| `fs.constants.S_IRUSR` | `0o400` | read by owner            |\n| `fs.constants.S_IWUSR` | `0o200` | write by owner           |\n| `fs.constants.S_IXUSR` | `0o100` | execute/search by owner  |\n| `fs.constants.S_IRGRP` | `0o40`  | read by group            |\n| `fs.constants.S_IWGRP` | `0o20`  | write by group           |\n| `fs.constants.S_IXGRP` | `0o10`  | execute/search by group  |\n| `fs.constants.S_IROTH` | `0o4`   | read by others           |\n| `fs.constants.S_IWOTH` | `0o2`   | write by others          |\n| `fs.constants.S_IXOTH` | `0o1`   | execute/search by others |\n\nAn easier method of constructing the `mode` is to use a sequence of three\noctal digits (e.g. `765`). The left-most digit (`7` in the example), specifies\nthe permissions for the file owner. The middle digit (`6` in the example),\nspecifies permissions for the group. The right-most digit (`5` in the example),\nspecifies the permissions for others.\n\n| Number | Description              |\n| ------ | ------------------------ |\n| `7`    | read, write, and execute |\n| `6`    | read and write           |\n| `5`    | read and execute         |\n| `4`    | read only                |\n| `3`    | write and execute        |\n| `2`    | write only               |\n| `1`    | execute only             |\n| `0`    | no permission            |\n\nFor example, the octal value `0o765` means:\n\n* The owner may read, write, and execute the file.\n* The group may read and write the file.\n* Others may read and execute the file.\n\nWhen using raw numbers where file modes are expected, any value larger than\n`0o777` may result in platform-specific behaviors that are not supported to work\nconsistently. Therefore constants like `S_ISVTX`, `S_ISGID`, or `S_ISUID` are\nnot exposed in `fs.constants`.\n\nCaveats: on Windows only the write permission can be changed, and the\ndistinction among the permissions of group, owner, or others is not\nimplemented.","summary":"The `mode` argument used in both the `fs.chmod()` and `fs.chmodSync()` methods is a numeric bitmask created using a logical OR of the following constants:","examples":[],"children":[]}]},{"kind":"method","id":"fschownpath-uid-gid-callback","name":"chown","title":"`fs.chown(path, uid, gid, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.97"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously changes owner and group of a file. No arguments other than a\npossible exception are given to the completion callback.\n\nSee the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.","summary":"Asynchronously changes owner and group of a file. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsclosefd-callback","name":"close","title":"`fs.close(fd[, callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v15.9.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/37174","commit":null,"description":"A default callback is now used if one is not provided."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Closes the file descriptor. No arguments other than a possible exception are\ngiven to the completion callback.\n\nCalling `fs.close()` on any file descriptor (`fd`) that is currently in use\nthrough any other `fs` operation may lead to undefined behavior.\n\nSee the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.","summary":"Closes the file descriptor. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fscopyfilesrc-dest-mode-callback","name":"copyFile","title":"`fs.copyFile(src, dest[, mode], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v8.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/27044","commit":null,"description":"Changed `flags` argument to `mode` and imposed stricter type validation."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"source filename to copy","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"destination filename of the copy operation","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"modifiers for copy operation.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it\nalready exists. No arguments other than a possible exception are given to the\ncallback function. Node.js makes no guarantees about the atomicity of the copy\noperation. If an error occurs after the destination file has been opened for\nwriting, Node.js will attempt to remove the destination.\n\nSymbolic links are followed. If `src` is a symbolic link, the target file is\ncopied. If `dest` is a symbolic link, the target file is overwritten unless\n`mode` contains `fs.constants.COPYFILE_EXCL`.\n\n`mode` is an optional integer that specifies the behavior\nof the copy operation. It is possible to create a mask consisting of the bitwise\nOR of two or more values (e.g.\n`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).\n\n* `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already\n  exists.\n* `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a\n  copy-on-write reflink. If the platform does not support copy-on-write, then a\n  fallback copy mechanism is used.\n* `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to\n  create a copy-on-write reflink. If the platform does not support\n  copy-on-write, then the operation will fail.\n\n```mjs\nimport { copyFile, constants } from 'node:fs';\n\nfunction callback(err) {\n  if (err) throw err;\n  console.log('source.txt was copied to destination.txt');\n}\n\n// destination.txt will be created or overwritten by default.\ncopyFile('source.txt', 'destination.txt', callback);\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ncopyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);\n```","summary":"Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.","examples":[{"language":"mjs","displayName":null,"code":"import { copyFile, constants } from 'node:fs';\n\nfunction callback(err) {\n  if (err) throw err;\n  console.log('source.txt was copied to destination.txt');\n}\n\n// destination.txt will be created or overwritten by default.\ncopyFile('source.txt', 'destination.txt', callback);\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ncopyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);"}],"children":[]},{"kind":"method","id":"fscpsrc-dest-options-callback","name":"cp","title":"`fs.cp(src, dest[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.3.0"],"prUrl":"https://github.com/nodejs/node/pull/53127","commit":null,"description":"This API is no longer experimental."},{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/47084","commit":null,"description":"Accept an additional `mode` option to specify the copy behavior as the `mode` argument of `fs.copyFile()`."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v17.6.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41819","commit":null,"description":"Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"dereference","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"dereference symlinks.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"errorOnExist","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"when `force` is `false`, and the destination\nexists, throw an error.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"filter","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"Function to filter copied files/directories. Return\n`true` to copy the item, `false` to ignore it. When ignoring a directory,\nall of its contents will be skipped as well. Can also return a `Promise`\nthat fulfills with `true` or `false`.","default":"undefined","optional":true,"rest":false,"properties":[{"name":"src","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"boolean | Promise","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7},{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":10,"end":17}]},"description":"A value that is coercible to `boolean` or\na `Promise` that fulfils with such value.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"overwrite existing file or directory. The copy\noperation will ignore errors if you set this to false and the destination\nexists. Use the `errorOnExist` option to change this behavior.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"modifiers for copy operation.","default":"0`. See `mode` flag of `fs.copyFile()","optional":true,"rest":false,"properties":[]},{"name":"preserveTimestamps","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true` timestamps from `src` will\nbe preserved.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"copy directories recursively","default":"false","optional":true,"rest":false,"properties":[]},{"name":"verbatimSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, path resolution for symlinks will\nbe skipped.","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously copies the entire directory structure from `src` to `dest`,\nincluding subdirectories and files.\n\nWhen copying a directory to another directory, globs are not supported and\nbehavior is similar to `cp dir1/ dir2/`.","summary":"Asynchronously copies the entire directory structure from `src` to `dest`, including subdirectories and files.","examples":[],"children":[]},{"kind":"method","id":"fscreatereadstreampath-options","name":"createReadStream","title":"`fs.createReadStream(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63851","commit":null,"description":"Add the `windowsHandle` option."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/40013","commit":null,"description":"The `fs` option does not need `open` method if an `fd` was provided."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/40013","commit":null,"description":"The `fs` option does not need `close` method if `autoClose` is `false`."},{"versions":["v15.5.0"],"prUrl":"https://github.com/nodejs/node/pull/36431","commit":null,"description":"Add support for `AbortSignal`."},{"versions":["v15.4.0"],"prUrl":"https://github.com/nodejs/node/pull/35922","commit":null,"description":"The `fd` option accepts FileHandle arguments."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31408","commit":null,"description":"Change `emitClose` default to `true`."},{"versions":["v13.6.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/29083","commit":null,"description":"The `fs` options allow overriding the used `fs` implementation."},{"versions":["v12.10.0"],"prUrl":"https://github.com/nodejs/node/pull/29212","commit":null,"description":"Enable `emitClose` option."},{"versions":["v11.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19898","commit":null,"description":"Impose new restrictions on `start` and `end`, throwing more appropriate errors in cases when we cannot reasonably handle the input values."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7831","commit":null,"description":"The passed `options` object will never be modified."},{"versions":["v2.3.0"],"prUrl":"https://github.com/nodejs/node/pull/1845","commit":null,"description":"The passed `options` object can be a string now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"flags","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"fd","type":{"text":"integer | FileHandle","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"FileHandle","href":"fs.html#class-filehandle","start":10,"end":20}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"emitClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"Infinity","optional":true,"rest":false,"properties":[]},{"name":"highWaterMark","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"64 * 1024","optional":true,"rest":false,"properties":[]},{"name":"fs","type":{"text":"Object | null","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal | null","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":14,"end":18}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"windowsHandle","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"A raw Win32 `HANDLE` value to read from, in place\nof `fd`. Windows only.","default":"null","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.ReadStream","links":[{"name":"fs.ReadStream","href":"fs.html#class-fsreadstream","start":0,"end":13}]},"description":""}},"description":"`options` can include `start` and `end` values to read a range of bytes from\nthe file instead of the entire file. Both `start` and `end` are inclusive and\nstart counting at 0, allowed values are in the\n\\[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)] range. If `fd` is specified and `start` is\nomitted or `undefined`, `fs.createReadStream()` reads sequentially from the\ncurrent file position. The `encoding` can be any one of those accepted by\n{Buffer}.\n\nIf `fd` is specified, `ReadStream` will ignore the `path` argument and will use\nthe specified file descriptor. This means that no `'open'` event will be\nemitted. `fd` should be blocking; non-blocking `fd`s should be passed to\n{net.Socket}.\n\nIf `fd` points to a character device that only supports blocking reads\n(such as keyboard or sound card), read operations do not finish until data is\navailable. This can prevent the process from exiting and the stream from\nclosing naturally.\n\nOn Windows, a value passed in `fd` is interpreted as a CRT file descriptor. To\nuse a raw Win32 `HANDLE` instead, such as an inherited anonymous pipe handle\nobtained from another process, pass it as `windowsHandle`. The handle is wrapped\nin a file descriptor that the stream owns and closes. The `windowsHandle` option\nthrows on non-Windows platforms and cannot be combined with the `fs` option.\n\nBy default, the stream will emit a `'close'` event after it has been\ndestroyed.  Set the `emitClose` option to `false` to change this behavior.\n\nBy providing the `fs` option, it is possible to override the corresponding `fs`\nimplementations for `open`, `read`, and `close`. When providing the `fs` option,\nan override for `read` is required. If no `fd` is provided, an override for\n`open` is also required. If `autoClose` is `true`, an override for `close` is\nalso required.\n\n```mjs\nimport { createReadStream } from 'node:fs';\n\n// Create a stream from some character device.\nconst stream = createReadStream('/dev/input/event0');\nsetTimeout(() => {\n  stream.close(); // This may not close the stream.\n  // Artificially marking end-of-stream, as if the underlying resource had\n  // indicated end-of-file by itself, allows the stream to close.\n  // This does not cancel pending read operations, and if there is such an\n  // operation, the process may still not be able to exit successfully\n  // until it finishes.\n  stream.push(null);\n  stream.read(0);\n}, 100);\n```\n\nIf `autoClose` is false, then the file descriptor won't be closed, even if\nthere's an error. It is the application's responsibility to close it and make\nsure there's no file descriptor leak. If `autoClose` is set to true (default\nbehavior), on `'error'` or `'end'` the file descriptor will be closed\nautomatically.\n\n`mode` sets the file mode (permission and sticky bits), but only if the\nfile was created.\n\nAn example to read the last 10 bytes of a file which is 100 bytes long:\n\n```mjs\nimport { createReadStream } from 'node:fs';\n\ncreateReadStream('sample.txt', { start: 90, end: 99 });\n```\n\nIf `options` is a string, then it specifies the encoding.","summary":"`options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and start counting at 0, allowed values are in the [0, `Number.MAX_SAFE_INTEGER`] range. If `fd` is specified and `start` is omitted or `undefined`, `fs.createReadStream()` reads sequentially from the current file position. The `encoding` can be any one of those accepted by {Buffer}.","examples":[{"language":"mjs","displayName":null,"code":"import { createReadStream } from 'node:fs';\n\n// Create a stream from some character device.\nconst stream = createReadStream('/dev/input/event0');\nsetTimeout(() => {\n  stream.close(); // This may not close the stream.\n  // Artificially marking end-of-stream, as if the underlying resource had\n  // indicated end-of-file by itself, allows the stream to close.\n  // This does not cancel pending read operations, and if there is such an\n  // operation, the process may still not be able to exit successfully\n  // until it finishes.\n  stream.push(null);\n  stream.read(0);\n}, 100);"},{"language":"mjs","displayName":null,"code":"import { createReadStream } from 'node:fs';\n\ncreateReadStream('sample.txt', { start: 90, end: 99 });"}],"children":[]},{"kind":"method","id":"fscreatewritestreampath-options","name":"createWriteStream","title":"`fs.createWriteStream(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63851","commit":null,"description":"Add the `windowsHandle` option."},{"versions":["v22.0.0"],"prUrl":"https://github.com/nodejs/node/pull/52037","commit":null,"description":"bump default highWaterMark."},{"versions":["v21.0.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50093","commit":null,"description":"The `flush` option is now supported."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/40013","commit":null,"description":"The `fs` option does not need `open` method if an `fd` was provided."},{"versions":["v16.10.0"],"prUrl":"https://github.com/nodejs/node/pull/40013","commit":null,"description":"The `fs` option does not need `close` method if `autoClose` is `false`."},{"versions":["v15.5.0"],"prUrl":"https://github.com/nodejs/node/pull/36431","commit":null,"description":"Add support for `AbortSignal`."},{"versions":["v15.4.0"],"prUrl":"https://github.com/nodejs/node/pull/35922","commit":null,"description":"The `fd` option accepts FileHandle arguments."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31408","commit":null,"description":"Change `emitClose` default to `true`."},{"versions":["v13.6.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/29083","commit":null,"description":"The `fs` options allow overriding the used `fs` implementation."},{"versions":["v12.10.0"],"prUrl":"https://github.com/nodejs/node/pull/29212","commit":null,"description":"Enable `emitClose` option."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7831","commit":null,"description":"The passed `options` object will never be modified."},{"versions":["v5.5.0"],"prUrl":"https://github.com/nodejs/node/pull/3679","commit":null,"description":"The `autoClose` option is supported now."},{"versions":["v2.3.0"],"prUrl":"https://github.com/nodejs/node/pull/1845","commit":null,"description":"The passed `options` object can be a string now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"flags","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'w'","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"fd","type":{"text":"integer | FileHandle","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"FileHandle","href":"fs.html#class-filehandle","start":10,"end":20}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"autoClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"emitClose","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fs","type":{"text":"Object | null","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal | null","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":14,"end":18}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"highWaterMark","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":"See `stream.getDefaultHighWaterMark()`","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, the underlying file descriptor is flushed\nprior to closing it.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"windowsHandle","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"A raw Win32 `HANDLE` value to write to, in place\nof `fd`. Windows only.","default":"null","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.WriteStream","links":[{"name":"fs.WriteStream","href":"fs.html#class-fswritestream","start":0,"end":14}]},"description":""}},"description":"`options` may also include a `start` option to allow writing data at some\nposition past the beginning of the file, allowed values are in the\n\\[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)] range. Modifying a file rather than\nreplacing it may require the `flags` option to be set to `r+` rather than the\ndefault `w`. The `encoding` can be any one of those accepted by {Buffer}.\n\nIf `autoClose` is set to true (default behavior) on `'error'` or `'finish'`\nthe file descriptor will be closed automatically. If `autoClose` is false,\nthen the file descriptor won't be closed, even if there's an error.\nIt is the application's responsibility to close it and make sure there's no\nfile descriptor leak.\n\nOn Windows, a value passed in `fd` is interpreted as a CRT file descriptor. To\nuse a raw Win32 `HANDLE` instead, such as an inherited anonymous pipe handle\nobtained from another process, pass it as `windowsHandle`. The handle is wrapped\nin a file descriptor that the stream owns and closes. The `windowsHandle` option\nthrows on non-Windows platforms and cannot be combined with the `fs` option.\n\nBy default, the stream will emit a `'close'` event after it has been\ndestroyed.  Set the `emitClose` option to `false` to change this behavior.\n\nBy providing the `fs` option it is possible to override the corresponding `fs`\nimplementations for `open`, `write`, `writev`, and `close`. Overriding `write()`\nwithout `writev()` can reduce performance as some optimizations (`_writev()`)\nwill be disabled. When providing the `fs` option, overrides for at least one of\n`write` and `writev` are required. If no `fd` option is supplied, an override\nfor `open` is also required. If `autoClose` is `true`, an override for `close`\nis also required.\n\nLike {fs.ReadStream}, if `fd` is specified, {fs.WriteStream} will ignore the\n`path` argument and will use the specified file descriptor. This means that no\n`'open'` event will be emitted. `fd` should be blocking; non-blocking `fd`s\nshould be passed to {net.Socket}.\n\nIf `options` is a string, then it specifies the encoding.","summary":"`options` may also include a `start` option to allow writing data at some position past the beginning of the file, allowed values are in the [0, `Number.MAX_SAFE_INTEGER`] range. Modifying a file rather than replacing it may require the `flags` option to be set to `r+` rather than the default `w`. The `encoding` can be any one of those accepted by {Buffer}.","examples":[],"children":[]},{"kind":"method","id":"fsexistspath-callback","name":"exists","title":"`fs.exists(path, callback)`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated: Use [`fs.stat()`](#fsstatpath-options-callback) or [`fs.access()`](#fsaccesspath-mode-callback) instead."},"added":["v0.0.2"],"deprecated":["v1.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"exists","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Test whether or not the element at the given `path` exists by checking with the file system.\nThen call the `callback` argument with either true or false:\n\n```mjs\nimport { exists } from 'node:fs';\n\nexists('/etc/passwd', (e) => {\n  console.log(e ? 'it exists' : 'no passwd!');\n});\n```\n\n**The parameters for this callback are not consistent with other Node.js\ncallbacks.** Normally, the first parameter to a Node.js callback is an `err`\nparameter, optionally followed by other parameters. The `fs.exists()` callback\nhas only one boolean parameter. This is one reason `fs.access()` is recommended\ninstead of `fs.exists()`.\n\nIf `path` is a symbolic link, it is followed. Thus, if `path` exists but points\nto a non-existent element, the callback will receive the value `false`.\n\nUsing `fs.exists()` to check for the existence of a file before calling\n`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file does not exist.\n\n**write (NOT RECOMMENDED)**\n\n```mjs\nimport { exists, open, close } from 'node:fs';\n\nexists('myfile', (e) => {\n  if (e) {\n    console.error('myfile already exists');\n  } else {\n    open('myfile', 'wx', (err, fd) => {\n      if (err) throw err;\n\n      try {\n        writeMyData(fd);\n      } finally {\n        close(fd, (err) => {\n          if (err) throw err;\n        });\n      }\n    });\n  }\n});\n```\n\n**write (RECOMMENDED)**\n\n```mjs\nimport { open, close } from 'node:fs';\nopen('myfile', 'wx', (err, fd) => {\n  if (err) {\n    if (err.code === 'EEXIST') {\n      console.error('myfile already exists');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    writeMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});\n```\n\n**read (NOT RECOMMENDED)**\n\n```mjs\nimport { open, close, exists } from 'node:fs';\n\nexists('myfile', (e) => {\n  if (e) {\n    open('myfile', 'r', (err, fd) => {\n      if (err) throw err;\n\n      try {\n        readMyData(fd);\n      } finally {\n        close(fd, (err) => {\n          if (err) throw err;\n        });\n      }\n    });\n  } else {\n    console.error('myfile does not exist');\n  }\n});\n```\n\n**read (RECOMMENDED)**\n\n```mjs\nimport { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    readMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});\n```\n\nThe \"not recommended\" examples above check for existence and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.\n\nIn general, check for the existence of a file only if the file won't be\nused directly, for example when its existence is a signal from another\nprocess.","summary":"Test whether or not the element at the given `path` exists by checking with the file system. Then call the `callback` argument with either true or false:","examples":[{"language":"mjs","displayName":null,"code":"import { exists } from 'node:fs';\n\nexists('/etc/passwd', (e) => {\n  console.log(e ? 'it exists' : 'no passwd!');\n});"},{"language":"mjs","displayName":null,"code":"import { exists, open, close } from 'node:fs';\n\nexists('myfile', (e) => {\n  if (e) {\n    console.error('myfile already exists');\n  } else {\n    open('myfile', 'wx', (err, fd) => {\n      if (err) throw err;\n\n      try {\n        writeMyData(fd);\n      } finally {\n        close(fd, (err) => {\n          if (err) throw err;\n        });\n      }\n    });\n  }\n});"},{"language":"mjs","displayName":null,"code":"import { open, close } from 'node:fs';\nopen('myfile', 'wx', (err, fd) => {\n  if (err) {\n    if (err.code === 'EEXIST') {\n      console.error('myfile already exists');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    writeMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});"},{"language":"mjs","displayName":null,"code":"import { open, close, exists } from 'node:fs';\n\nexists('myfile', (e) => {\n  if (e) {\n    open('myfile', 'r', (err, fd) => {\n      if (err) throw err;\n\n      try {\n        readMyData(fd);\n      } finally {\n        close(fd, (err) => {\n          if (err) throw err;\n        });\n      }\n    });\n  } else {\n    console.error('myfile does not exist');\n  }\n});"},{"language":"mjs","displayName":null,"code":"import { open, close } from 'node:fs';\n\nopen('myfile', 'r', (err, fd) => {\n  if (err) {\n    if (err.code === 'ENOENT') {\n      console.error('myfile does not exist');\n      return;\n    }\n\n    throw err;\n  }\n\n  try {\n    readMyData(fd);\n  } finally {\n    close(fd, (err) => {\n      if (err) throw err;\n    });\n  }\n});"}],"children":[]},{"kind":"method","id":"fsfchmodfd-mode-callback","name":"fchmod","title":"`fs.fchmod(fd, mode, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Sets the permissions on the file. No arguments other than a possible exception\nare given to the completion callback.\n\nSee the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.","summary":"Sets the permissions on the file. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsfchownfd-uid-gid-callback","name":"fchown","title":"`fs.fchown(fd, uid, gid, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Sets the owner of the file. No arguments other than a possible exception are\ngiven to the completion callback.\n\nSee the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.","summary":"Sets the owner of the file. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsfdatasyncfd-callback","name":"fdatasync","title":"`fs.fdatasync(fd, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.96"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Forces all currently queued I/O operations associated with the file to the\noperating system's synchronized I/O completion state. Refer to the POSIX\n[`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other than a possible\nexception are given to the completion callback.","summary":"Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX `fdatasync(2)` documentation for details. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsfstatfd-options-callback","name":"fstat","title":"`fs.fstat(fd[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.95"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63143","commit":null,"description":"Accepts an additional `signal` option to allow aborting the operation."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An AbortSignal to cancel the operation.","default":"undefined","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stats","type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Invokes the callback with the {fs.Stats} for the file descriptor.\n\nSee the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.","summary":"Invokes the callback with the {fs.Stats} for the file descriptor.","examples":[],"children":[]},{"kind":"method","id":"fsfsyncfd-callback","name":"fsync","title":"`fs.fsync(fd, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.96"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Request that all data for the open file descriptor is flushed to the storage\ndevice. The specific implementation is operating system and device specific.\nRefer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other\nthan a possible exception are given to the completion callback.","summary":"Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX `fsync(2)` documentation for more detail. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsftruncatefd-len-callback","name":"ftruncate","title":"`fs.ftruncate(fd[, len], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.8.6"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Truncates the file descriptor. No arguments other than a possible exception are\ngiven to the completion callback.\n\nSee the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.\n\nIf the file referred to by the file descriptor was larger than `len` bytes, only\nthe first `len` bytes will be retained in the file.\n\nFor example, the following program retains only the first four bytes of the\nfile:\n\n```mjs\nimport { open, close, ftruncate } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('temp.txt', 'r+', (err, fd) => {\n  if (err) throw err;\n\n  try {\n    ftruncate(fd, 4, (err) => {\n      closeFd(fd);\n      if (err) throw err;\n    });\n  } catch (err) {\n    closeFd(fd);\n    if (err) throw err;\n  }\n});\n```\n\nIf the file previously was shorter than `len` bytes, it is extended, and the\nextended part is filled with null bytes (`'\\0'`):\n\nIf `len` is negative then `0` will be used.","summary":"Truncates the file descriptor. No arguments other than a possible exception are given to the completion callback.","examples":[{"language":"mjs","displayName":null,"code":"import { open, close, ftruncate } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('temp.txt', 'r+', (err, fd) => {\n  if (err) throw err;\n\n  try {\n    ftruncate(fd, 4, (err) => {\n      closeFd(fd);\n      if (err) throw err;\n    });\n  } catch (err) {\n    closeFd(fd);\n    if (err) throw err;\n  }\n});"}],"children":[]},{"kind":"method","id":"fsfutimesfd-atime-mtime-callback","name":"futimes","title":"`fs.futimes(fd, atime, mtime, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v4.1.0"],"prUrl":"https://github.com/nodejs/node/pull/2387","commit":null,"description":"Numeric strings, `NaN`, and `Infinity` are now allowed time specifiers."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Change the file system timestamps of the object referenced by the supplied file\ndescriptor. See [`fs.utimes()`](#fsutimespath-atime-mtime-callback).","summary":"Change the file system timestamps of the object referenced by the supplied file descriptor. See `fs.utimes()`.","examples":[],"children":[]},{"kind":"method","id":"fsglobpattern-options-callback","name":"glob","title":"`fs.glob(pattern[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v22.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62695","commit":null,"description":"Add support for the `followSymlinks` option."},{"versions":["v24.1.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/58182","commit":null,"description":"Add support for `URL` instances for `cwd` option."},{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."},{"versions":["v23.7.0","v22.14.0"],"prUrl":"https://github.com/nodejs/node/pull/56489","commit":null,"description":"Add support for `exclude` option to accept glob patterns."},{"versions":["v22.2.0"],"prUrl":"https://github.com/nodejs/node/pull/52837","commit":null,"description":"Add support for `withFileTypes` as an option."}],"signature":{"parameters":[{"name":"pattern","type":{"text":"string | string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"cwd","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"current working directory.","default":"process.cwd()","optional":true,"rest":false,"properties":[]},{"name":"exclude","type":{"text":"Function | string[]","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":11,"end":17}]},"description":"Function to filter out files/directories or a\nlist of glob patterns to be excluded. If a function is provided, return\n`true` to exclude the item, `false` to include it.","default":"undefined","optional":true,"rest":false,"properties":[]},{"name":"followSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, symbolic links to directories are\nfollowed while expanding `**` patterns.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the glob should return paths as Dirents,\n`false` otherwise.","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"* Retrieves the files matching the specified pattern.\n\nWhen `followSymlinks` is enabled, detected symbolic link cycles are not\ntraversed recursively.\n\n```mjs\nimport { glob } from 'node:fs';\n\nglob('**/*.js', (err, matches) => {\n  if (err) throw err;\n  console.log(matches);\n});\n```\n\n```cjs\nconst { glob } = require('node:fs');\n\nglob('**/*.js', (err, matches) => {\n  if (err) throw err;\n  console.log(matches);\n});\n```","summary":"When `followSymlinks` is enabled, detected symbolic link cycles are not traversed recursively.","examples":[{"language":"mjs","displayName":null,"code":"import { glob } from 'node:fs';\n\nglob('**/*.js', (err, matches) => {\n  if (err) throw err;\n  console.log(matches);\n});"},{"language":"cjs","displayName":null,"code":"const { glob } = require('node:fs');\n\nglob('**/*.js', (err, matches) => {\n  if (err) throw err;\n  console.log(matches);\n});"}],"children":[]},{"kind":"method","id":"fslchmodpath-mode-callback","name":"lchmod","title":"`fs.lchmod(path, mode, callback)`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v0.5.0"],"deprecated":["v0.5.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37460","commit":null,"description":"The error returned may be an `AggregateError` if more than one error is returned."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error | AggregateError","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5},{"name":"AggregateError","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError","start":8,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Changes the permissions on a symbolic link. No arguments other than a possible\nexception are given to the completion callback.\n\nThis method is only implemented on macOS.\n\nSee the POSIX [`lchmod(2)`](http://man7.org/linux/man-pages/man2/lchmod.2.html) documentation for more detail.","summary":"Changes the permissions on a symbolic link. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fslchownpath-uid-gid-callback","name":"lchown","title":"`fs.lchown(path, uid, gid, callback)`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.6.0"],"prUrl":"https://github.com/nodejs/node/pull/21498","commit":null,"description":"This API is no longer deprecated."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v0.4.7"],"prUrl":null,"commit":null,"description":"Documentation-only deprecation."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Set the owner of the symbolic link. No arguments other than a possible\nexception are given to the completion callback.\n\nSee the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.","summary":"Set the owner of the symbolic link. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fslutimespath-atime-mtime-callback","name":"lutimes","title":"`fs.lutimes(path, atime, mtime, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v14.5.0","v12.19.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Changes the access and modification times of a file in the same way as\n[`fs.utimes()`](#fsutimespath-atime-mtime-callback), with the difference that if the path refers to a symbolic\nlink, then the link is not dereferenced: instead, the timestamps of the\nsymbolic link itself are changed.\n\nNo arguments other than a possible exception are given to the completion\ncallback.","summary":"Changes the access and modification times of a file in the same way as `fs.utimes()`, with the difference that if the path refers to a symbolic link, then the link is not dereferenced: instead, the timestamps of the symbolic link itself are changed.","examples":[],"children":[]},{"kind":"method","id":"fslinkexistingpath-newpath-callback","name":"link","title":"`fs.link(existingPath, newPath, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `existingPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"existingPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX\n[`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than a possible\nexception are given to the completion callback.","summary":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX `link(2)` documentation for more detail. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fslstatpath-options-callback","name":"lstat","title":"`fs.lstat(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.30"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/63143","commit":null,"description":"Accepts an additional `signal` option to allow aborting the operation."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"An AbortSignal to cancel the operation.","default":"undefined","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stats","type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Retrieves the {fs.Stats} for the symbolic link referred to by the path.\nThe callback gets two arguments `(err, stats)` where `stats` is a {fs.Stats}\nobject. `lstat()` is identical to `stat()`, except that if `path` is a symbolic\nlink, then the link itself is stat-ed, not the file that it refers to.\n\nSee the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.","summary":"Retrieves the {fs.Stats} for the symbolic link referred to by the path. The callback gets two arguments `(err, stats)` where `stats` is a {fs.Stats} object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic link, then the link itself is stat-ed, not the file that it refers to.","examples":[],"children":[]},{"kind":"method","id":"fsmkdirpath-options-callback","name":"mkdir","title":"`fs.mkdir(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v13.11.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31530","commit":null,"description":"In `recursive` mode, the callback now receives the first created path as an argument."},{"versions":["v10.12.0"],"prUrl":"https://github.com/nodejs/node/pull/21875","commit":null,"description":"The second argument can now be an `options` object with `recursive` and `mode` properties."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | integer","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"Not supported on Windows. See [File modes](#file-modes)\nfor more details.","default":"0o777","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"path","type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":"Present only if a directory is created with\n`recursive` set to `true`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously creates a directory.\n\nThe callback is given a possible exception and, if `recursive` is `true`, the\nfirst directory path created, `(err[, path])`.\n`path` can still be `undefined` when `recursive` is `true`, if no directory was\ncreated (for instance, if it was previously created).\n\nThe optional `options` argument can be an integer specifying `mode` (permission\nand sticky bits), or an object with a `mode` property and a `recursive`\nproperty indicating whether parent directories should be created. Calling\n`fs.mkdir()` when `path` is a directory that exists results in an error only\nwhen `recursive` is false. If `recursive` is false and the directory exists,\nan `EEXIST` error occurs.\n\n```mjs\nimport { mkdir } from 'node:fs';\n\n// Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.\nmkdir('./tmp/a/apple', { recursive: true }, (err) => {\n  if (err) throw err;\n});\n```\n\nOn Windows, using `fs.mkdir()` on the root directory even with recursion will\nresult in an error:\n\n```mjs\nimport { mkdir } from 'node:fs';\n\nmkdir('/', { recursive: true }, (err) => {\n  // => [Error: EPERM: operation not permitted, mkdir 'C:\\']\n});\n```\n\nSee the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.","summary":"Asynchronously creates a directory.","examples":[{"language":"mjs","displayName":null,"code":"import { mkdir } from 'node:fs';\n\n// Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.\nmkdir('./tmp/a/apple', { recursive: true }, (err) => {\n  if (err) throw err;\n});"},{"language":"mjs","displayName":null,"code":"import { mkdir } from 'node:fs';\n\nmkdir('/', { recursive: true }, (err) => {\n  // => [Error: EPERM: operation not permitted, mkdir 'C:\\']\n});"}],"children":[]},{"kind":"method","id":"fsmkdtempprefix-options-callback","name":"mkdtemp","title":"`fs.mkdtemp(prefix[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.6.0","v18.19.0"],"prUrl":"https://github.com/nodejs/node/pull/48828","commit":null,"description":"The `prefix` parameter now accepts buffers and URL."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.5.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/39028","commit":null,"description":"The `prefix` parameter now accepts an empty string."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v6.2.1"],"prUrl":"https://github.com/nodejs/node/pull/6828","commit":null,"description":"The `callback` parameter is optional now."}],"signature":{"parameters":[{"name":"prefix","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"directory","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates a unique temporary directory.\n\nGenerates six random characters to be appended behind a required\n`prefix` to create a unique temporary directory. Due to platform\ninconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,\nnotably the BSDs, can return more than six random characters, and replace\ntrailing `X` characters in `prefix` with random characters.\n\nThe created directory path is passed as a string to the callback's second\nparameter.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use.\n\n```mjs\nimport { mkdtemp } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\nmkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Prints: /tmp/foo-itXde2 or C:\\Users\\...\\AppData\\Local\\Temp\\foo-itXde2\n});\n```\n\nThe `fs.mkdtemp()` method will append the six randomly selected characters\ndirectly to the `prefix` string. For instance, given a directory `/tmp`, if the\nintention is to create a temporary directory *within* `/tmp`, the `prefix`\nmust end with a trailing platform-specific path separator\n(`require('node:path').sep`).\n\n```mjs\nimport { tmpdir } from 'node:os';\nimport { mkdtemp } from 'node:fs';\n\n// The parent directory for the new temporary directory\nconst tmpDir = tmpdir();\n\n// This method is *INCORRECT*:\nmkdtemp(tmpDir, (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Will print something similar to `/tmpabc123`.\n  // A new temporary directory is created at the file system root\n  // rather than *within* the /tmp directory.\n});\n\n// This method is *CORRECT*:\nimport { sep } from 'node:path';\nmkdtemp(`${tmpDir}${sep}`, (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Will print something similar to `/tmp/abc123`.\n  // A new temporary directory is created within\n  // the /tmp directory.\n});\n```","summary":"Creates a unique temporary directory.","examples":[{"language":"mjs","displayName":null,"code":"import { mkdtemp } from 'node:fs';\nimport { join } from 'node:path';\nimport { tmpdir } from 'node:os';\n\nmkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Prints: /tmp/foo-itXde2 or C:\\Users\\...\\AppData\\Local\\Temp\\foo-itXde2\n});"},{"language":"mjs","displayName":null,"code":"import { tmpdir } from 'node:os';\nimport { mkdtemp } from 'node:fs';\n\n// The parent directory for the new temporary directory\nconst tmpDir = tmpdir();\n\n// This method is *INCORRECT*:\nmkdtemp(tmpDir, (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Will print something similar to `/tmpabc123`.\n  // A new temporary directory is created at the file system root\n  // rather than *within* the /tmp directory.\n});\n\n// This method is *CORRECT*:\nimport { sep } from 'node:path';\nmkdtemp(`${tmpDir}${sep}`, (err, directory) => {\n  if (err) throw err;\n  console.log(directory);\n  // Will print something similar to `/tmp/abc123`.\n  // A new temporary directory is created within\n  // the /tmp directory.\n});"}],"children":[]},{"kind":"method","id":"fsopenpath-flags-mode-callback","name":"open","title":"`fs.open(path[, flags[, mode]], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v11.1.0"],"prUrl":"https://github.com/nodejs/node/pull/23767","commit":null,"description":"The `flags` argument is now optional and defaults to `'r'`."},{"versions":["v9.9.0"],"prUrl":"https://github.com/nodejs/node/pull/18801","commit":null,"description":"The `as` and `as+` flags are supported now."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"flags","type":{"text":"string | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":15}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":"`0o666` (readable and writable)","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details.\n\n`mode` sets the file mode (permission and sticky bits), but only if the file was\ncreated. On Windows, only the write permission can be manipulated; see\n[`fs.chmod()`](#fschmodpath-mode-callback).\n\nThe callback gets two arguments `(err, fd)`.\n\nSome characters (`< > : \" / \\ | ? *`) are reserved under Windows as documented\nby [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains\na colon, Node.js will open a file system stream, as described by\n[this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).\n\nFunctions based on `fs.open()` exhibit this behavior as well:\n`fs.writeFile()`, `fs.readFile()`, etc.","summary":"Asynchronous file open. See the POSIX `open(2)` documentation for more details.","examples":[],"children":[]},{"kind":"method","id":"fsopenasblobpath-options","name":"openAsBlob","title":"`fs.openAsBlob(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v19.8.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"An optional mime type for the blob.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {Blob} upon success."}},"description":"Returns a {Blob} whose data is backed by the given file.\n\nThe file must not be modified after the {Blob} is created. Any modifications\nwill cause reading the {Blob} data to fail with a `DOMException` error.\nSynchronous stat operations on the file when the `Blob` is created, and before\neach read in order to detect whether the file data has been modified on disk.\n\n```mjs\nimport { openAsBlob } from 'node:fs';\n\nconst blob = await openAsBlob('the.file.txt');\nconst ab = await blob.arrayBuffer();\nblob.stream();\n```\n\n```cjs\nconst { openAsBlob } = require('node:fs');\n\n(async () => {\n  const blob = await openAsBlob('the.file.txt');\n  const ab = await blob.arrayBuffer();\n  blob.stream();\n})();\n```","summary":"Returns a {Blob} whose data is backed by the given file.","examples":[{"language":"mjs","displayName":null,"code":"import { openAsBlob } from 'node:fs';\n\nconst blob = await openAsBlob('the.file.txt');\nconst ab = await blob.arrayBuffer();\nblob.stream();"},{"language":"cjs","displayName":null,"code":"const { openAsBlob } = require('node:fs');\n\n(async () => {\n  const blob = await openAsBlob('the.file.txt');\n  const ab = await blob.arrayBuffer();\n  blob.stream();\n})();"}],"children":[]},{"kind":"method","id":"fsopendirpath-options-callback","name":"opendir","title":"`fs.opendir(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v13.1.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30114","commit":null,"description":"The `bufferSize` option was introduced."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"bufferSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number of directory entries that are buffered\ninternally when reading from the directory. Higher values lead to better\nperformance but higher memory usage.","default":"32","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dir","type":{"text":"fs.Dir","links":[{"name":"fs.Dir","href":"fs.html#class-fsdir","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for\nmore details.\n\nCreates an {fs.Dir}, which contains all further functions for reading from\nand cleaning up the directory.\n\nThe `encoding` option sets the encoding for the `path` while opening the\ndirectory and subsequent read operations.","summary":"Asynchronously open a directory. See the POSIX `opendir(3)` documentation for more details.","examples":[],"children":[]},{"kind":"method","id":"fsreadfd-buffer-offset-length-position-callback","name":"read","title":"`fs.read(fd, buffer, offset, length, position, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `buffer` parameter can now be any `TypedArray`, or a `DataView`."},{"versions":["v7.4.0"],"prUrl":"https://github.com/nodejs/node/pull/10382","commit":null,"description":"The `buffer` parameter can now be a `Uint8Array`."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/4518","commit":null,"description":"The `length` parameter can now be `0`."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"The buffer that the data will be\nwritten to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The position in `buffer` to write the data to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes to read.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"Specifies where to begin reading from in the\nfile. If `position` is `null` or `-1 `, data will be read from the current\nfile position, and the file position will be updated. If `position` is\na non-negative integer, the file position will be unchanged.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesRead","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Read data from the file specified by `fd`.\n\nThe callback is given the three arguments, `(err, bytesRead, buffer)`.\n\nIf the file is not modified concurrently, the end-of-file is reached when the\nnumber of bytes read is zero.\n\nIf this method is invoked as its [`util.promisify()`](util.html#utilpromisifyoriginal)ed version, it returns\na promise for an `Object` with `bytesRead` and `buffer` properties.\n\nThe `fs.read()` method reads data from the file specified\nby the file descriptor (`fd`).\nThe `length` argument indicates the maximum number\nof bytes that Node.js\nwill attempt to read from the kernel.\nHowever, the actual number of bytes read (`bytesRead`) can be lower\nthan the specified `length` for various reasons.\n\nFor example:\n\n* If the file is shorter than the specified `length`, `bytesRead`\n  will be set to the actual number of bytes read.\n* If the file encounters EOF (End of File) before the buffer could\n  be filled, Node.js will read all available bytes until EOF is encountered,\n  and the `bytesRead` parameter in the callback will indicate\n  the actual number of bytes read, which may be less than the specified `length`.\n* If the file is on a slow network `filesystem`\n  or encounters any other issue during reading,\n  `bytesRead` can be lower than the specified `length`.\n\nTherefore, when using `fs.read()`, it's important to\ncheck the `bytesRead` value to\ndetermine how many bytes were actually read from the file.\nDepending on your application\nlogic, you may need to handle cases where `bytesRead`\nis lower than the specified `length`,\nsuch as by wrapping the read call in a loop if you require\na minimum amount of bytes.\n\nThis behavior is similar to the POSIX `preadv2` function.","summary":"Read data from the file specified by `fd`.","examples":[],"children":[]},{"kind":"method","id":"fsreadfd-options-callback","name":"read","title":"`fs.read(fd[, options], callback)`","scope":"module","overloadOf":"fsreadfd-buffer-offset-length-position-callback","stability":null,"added":["v13.11.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v13.11.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31402","commit":null,"description":"Options object can be passed in to make buffer, offset, length, and position optional."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":"Buffer.alloc(16384)","optional":true,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesRead","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Similar to the [`fs.read()`](#fsreadfd-buffer-offset-length-position-callback) function, this version takes an optional\n`options` object. If no `options` object is specified, it will default with the\nabove values.","summary":"Similar to the `fs.read()` function, this version takes an optional `options` object. If no `options` object is specified, it will default with the above values.","examples":[],"children":[]},{"kind":"method","id":"fsreadfd-buffer-options-callback","name":"read","title":"`fs.read(fd, buffer[, options], callback)`","scope":"module","overloadOf":"fsreadfd-buffer-offset-length-position-callback","stability":null,"added":["v18.2.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"The buffer that the data will be\nwritten to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesRead","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Similar to the [`fs.read()`](#fsreadfd-buffer-offset-length-position-callback) function, this version takes an optional\n`options` object. If no `options` object is specified, it will default with the\nabove values.","summary":"Similar to the `fs.read()` function, this version takes an optional `options` object. If no `options` object is specified, it will default with the above values.","examples":[],"children":[]},{"kind":"method","id":"fsreaddirpath-options-callback","name":"readdir","title":"`fs.readdir(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22020","commit":null,"description":"New option `withFileTypes` was added."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5616","commit":null,"description":"The `options` parameter was added."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, reads the contents of a directory\nrecursively. In recursive mode, it will list all files, sub files and\ndirectories.","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"files","type":{"text":"string[] | Buffer[] | fs.Dirent[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":11,"end":17},{"name":"fs.Dirent","href":"fs.html#class-fsdirent","start":22,"end":31}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Reads the contents of a directory. The callback gets two arguments `(err, files)`\nwhere `files` is an array of the names of the files in the directory excluding\n`'.'` and `'..'`.\n\nSee the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe filenames passed to the callback. If the `encoding` is set to `'buffer'`,\nthe filenames returned will be passed as {Buffer} objects.\n\nIf `options.withFileTypes` is set to `true`, the `files` array will contain\n{fs.Dirent} objects.","summary":"Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.","examples":[],"children":[]},{"kind":"method","id":"fsreadfilepath-options-callback","name":"readFile","title":"`fs.readFile(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.29"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.4.0"],"prUrl":"https://github.com/nodejs/node/pull/63634","commit":null,"description":"Added support for the `buffer` option."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37460","commit":null,"description":"The error returned may be an `AggregateError` if more than one error is returned."},{"versions":["v15.2.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/35911","commit":null,"description":"The options argument may include an AbortSignal to abort an ongoing readFile request."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v5.1.0"],"prUrl":"https://github.com/nodejs/node/pull/3740","commit":null,"description":"The `callback` will always be called with `null` as the `error` parameter in case of success."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `path` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":31}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows aborting an in-progress readFile","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView | Function","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":33,"end":41}]},"description":"A buffer to read into, or a\nfunction called with the file size that returns the buffer.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error | AggregateError","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5},{"name":"AggregateError","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError","start":8,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously reads the entire contents of a file.\n\n```mjs\nimport { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', (err, data) => {\n  if (err) throw err;\n  console.log(data);\n});\n```\n\nThe callback is passed two arguments `(err, data)`, where `data` is the\ncontents of the file.\n\nIf no encoding is specified, then the raw buffer is returned.\n\nIf `buffer` is provided and no encoding is specified, the returned {Buffer} is\na view over the supplied buffer containing only the bytes read. If the\nsupplied buffer is too small to contain the entire file, the callback is\ncalled with an error.\n\nIf `options` is a string, then it specifies the encoding:\n\n```mjs\nimport { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', 'utf8', callback);\n```\n\nWhen the path is a directory, the behavior of `fs.readFile()` and\n[`fs.readFileSync()`](#fsreadfilesyncpath-options) is platform-specific. On macOS, Linux, and Windows, an\nerror will be returned. On FreeBSD, a representation of the directory's contents\nwill be returned.\n\n```mjs\nimport { readFile } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFile('<directory>', (err, data) => {\n  // => [Error: EISDIR: illegal operation on a directory, read <directory>]\n});\n\n//  FreeBSD\nreadFile('<directory>', (err, data) => {\n  // => null, <data>\n});\n```\n\nIt is possible to abort an ongoing request using an `AbortSignal`. If a\nrequest is aborted the callback is called with an `AbortError`:\n\n```mjs\nimport { readFile } from 'node:fs';\n\nconst controller = new AbortController();\nconst signal = controller.signal;\nreadFile(fileInfo[0].name, { signal }, (err, buf) => {\n  // ...\n});\n// When you want to abort the request\ncontroller.abort();\n```\n\nThe `fs.readFile()` function buffers the entire file. To minimize memory costs,\nwhen possible prefer streaming via `fs.createReadStream()`.\n\nAborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering `fs.readFile` performs.\n\nAn example using the `buffer` option with a pre-allocated buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs';\n\nconst buf = Buffer.alloc(16384);\nreadFile('/path/to/file', { buffer: buf }, (err, data) => {\n  if (err) throw err;\n  console.log(data); // A view over `buf` containing only the bytes read\n});\n```\n\nAn example using the `buffer` option with a function returning a buffer:\n\n```mjs\nimport { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs';\n\nreadFile('/path/to/file', {\n  buffer: (size) => Buffer.alloc(size),\n}, (err, data) => {\n  if (err) throw err;\n  console.log(data);\n});\n```","summary":"Asynchronously reads the entire contents of a file.","examples":[{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', (err, data) => {\n  if (err) throw err;\n  console.log(data);\n});"},{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs';\n\nreadFile('/etc/passwd', 'utf8', callback);"},{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFile('<directory>', (err, data) => {\n  // => [Error: EISDIR: illegal operation on a directory, read <directory>]\n});\n\n//  FreeBSD\nreadFile('<directory>', (err, data) => {\n  // => null, <data>\n});"},{"language":"mjs","displayName":null,"code":"import { readFile } from 'node:fs';\n\nconst controller = new AbortController();\nconst signal = controller.signal;\nreadFile(fileInfo[0].name, { signal }, (err, buf) => {\n  // ...\n});\n// When you want to abort the request\ncontroller.abort();"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs';\n\nconst buf = Buffer.alloc(16384);\nreadFile('/path/to/file', { buffer: buf }, (err, data) => {\n  if (err) throw err;\n  console.log(data); // A view over `buf` containing only the bytes read\n});"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\nimport { readFile } from 'node:fs';\n\nreadFile('/path/to/file', {\n  buffer: (size) => Buffer.alloc(size),\n}, (err, data) => {\n  if (err) throw err;\n  console.log(data);\n});"}],"children":[{"kind":"section","id":"file-descriptors","name":"File descriptors","title":"File descriptors","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"1. Any specified file descriptor has to support reading.\n2. If a file descriptor is specified as the `path`, it will not be closed\n   automatically.\n3. The reading will begin at the current position. For example, if the file\n   already had `'Hello World'` and six bytes are read with the file descriptor,\n   the call to `fs.readFile()` with the same file descriptor, would give\n   `'World'`, rather than `'Hello World'`.","summary":"","examples":[],"children":[]},{"kind":"section","id":"performance-considerations","name":"Performance Considerations","title":"Performance Considerations","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `fs.readFile()` method asynchronously reads the contents of a file into\nmemory one chunk at a time, allowing the event loop to turn between each chunk.\nThis allows the read operation to have less impact on other activity that may\nbe using the underlying libuv thread pool but means that it will take longer\nto read a complete file into memory.\n\nThe additional read overhead can vary broadly on different systems and depends\non the type of file being read. If the file type is not a regular file (a pipe\nfor instance) and Node.js is unable to determine an actual file size, each read\noperation will load on 64 KiB of data. For regular files, each read will process\n512 KiB of data.\n\nFor applications that require as-fast-as-possible reading of file contents, it\nis better to use `fs.read()` directly and for application code to manage\nreading the full contents of the file itself.\n\nThe Node.js GitHub issue [#25741](https://github.com/nodejs/node/issues/25741) provides more information and a detailed\nanalysis on the performance of `fs.readFile()` for multiple file sizes in\ndifferent Node.js versions.","summary":"The `fs.readFile()` method asynchronously reads the contents of a file into memory one chunk at a time, allowing the event loop to turn between each chunk. This allows the read operation to have less impact on other activity that may be using the underlying libuv thread pool but means that it will take longer to read a complete file into memory.","examples":[],"children":[]}]},{"kind":"method","id":"fsreadlinkpath-options-callback","name":"readlink","title":"`fs.readlink(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"linkString","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Reads the contents of the symbolic link referred to by `path`. The callback gets\ntwo arguments `(err, linkString)`.\n\nSee the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe link path passed to the callback. If the `encoding` is set to `'buffer'`,\nthe link path returned will be passed as a {Buffer} object.","summary":"Reads the contents of the symbolic link referred to by `path`. The callback gets two arguments `(err, linkString)`.","examples":[],"children":[]},{"kind":"method","id":"fsreadvfd-buffers-position-callback","name":"readv","title":"`fs.readv(fd, buffers[, position], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v13.13.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesRead","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Read from a file specified by `fd` and write to an array of `ArrayBufferView`s\nusing `readv()`.\n\n`position` is the offset from the beginning of the file from where data\nshould be read. If `typeof position !== 'number'`, the data will be read\nfrom the current position.\n\nThe callback will be given three arguments: `err`, `bytesRead`, and\n`buffers`. `bytesRead` is how many bytes were read from the file.\n\nIf this method is invoked as its [`util.promisify()`](util.html#utilpromisifyoriginal)ed version, it returns\na promise for an `Object` with `bytesRead` and `buffers` properties.","summary":"Read from a file specified by `fd` and write to an array of `ArrayBufferView`s using `readv()`.","examples":[],"children":[]},{"kind":"method","id":"fsrealpathpath-options-callback","name":"realpath","title":"`fs.realpath(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/13028","commit":null,"description":"Pipe/Socket resolve support was added."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v6.4.0"],"prUrl":"https://github.com/nodejs/node/pull/7899","commit":null,"description":"Calling `realpath` now works again for various edge cases on Windows."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3594","commit":null,"description":"The `cache` parameter was removed."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"resolvedPath","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously computes the canonical pathname by resolving `.`, `..`, and\nsymbolic links.\n\nA canonical pathname is not necessarily unique. Hard links and bind mounts can\nexpose a file system entity through many pathnames.\n\nThis function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions:\n\n1. No case conversion is performed on case-insensitive file systems.\n\n2. The maximum number of symbolic links is platform-independent and generally\n   (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.\n\nThe `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`\nto resolve relative paths.\n\nOnly paths that can be converted to UTF8 strings are supported.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe path passed to the callback. If the `encoding` is set to `'buffer'`,\nthe path returned will be passed as a {Buffer} object.\n\nIf `path` resolves to a socket or a pipe, the function will return a system\ndependent name for that object.\n\nA path that does not exist results in an ENOENT error.\n`error.path` is the absolute file path.","summary":"Asynchronously computes the canonical pathname by resolving `.`, `..`, and symbolic links.","examples":[],"children":[]},{"kind":"method","id":"fsrealpathnativepath-options-callback","name":"native","title":"`fs.realpath.native(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v9.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"resolvedPath","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).\n\nThe `callback` gets two arguments `(err, resolvedPath)`.\n\nOnly paths that can be converted to UTF8 strings are supported.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe path passed to the callback. If the `encoding` is set to `'buffer'`,\nthe path returned will be passed as a {Buffer} object.\n\nOn Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on `/proc` in order for this function to work. Glibc does not have\nthis restriction.","summary":"Asynchronous `realpath(3)`.","examples":[],"children":[]},{"kind":"method","id":"fsrenameoldpath-newpath-callback","name":"rename","title":"`fs.rename(oldPath, newPath, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `oldPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"oldPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously rename file at `oldPath` to the pathname provided\nas `newPath`. In the case that `newPath` already exists, it will\nbe overwritten. If there is a directory at `newPath`, an error will\nbe raised instead. No arguments other than a possible exception are\ngiven to the completion callback.\n\nSee also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).\n\n```mjs\nimport { rename } from 'node:fs';\n\nrename('oldFile.txt', 'newFile.txt', (err) => {\n  if (err) throw err;\n  console.log('Rename complete!');\n});\n```","summary":"Asynchronously rename file at `oldPath` to the pathname provided as `newPath`. In the case that `newPath` already exists, it will be overwritten. If there is a directory at `newPath`, an error will be raised instead. No arguments other than a possible exception are given to the completion callback.","examples":[{"language":"mjs","displayName":null,"code":"import { rename } from 'node:fs';\n\nrename('oldFile.txt', 'newFile.txt', (err) => {\n  if (err) throw err;\n  console.log('Rename complete!');\n});"}],"children":[]},{"kind":"method","id":"fsrmdirpath-options-callback","name":"rmdir","title":"`fs.rmdir(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.0.0"],"prUrl":"https://github.com/nodejs/node/pull/58616","commit":null,"description":"Remove `recursive` option."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fs.rmdir(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fs.rmdir(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37302","commit":null,"description":"The `recursive` option is deprecated, using it triggers a deprecation warning."},{"versions":["v14.14.0"],"prUrl":"https://github.com/nodejs/node/pull/35579","commit":null,"description":"The `recursive` option is deprecated, use `fs.rm` instead."},{"versions":["v13.3.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30644","commit":null,"description":"The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."},{"versions":["v12.10.0"],"prUrl":"https://github.com/nodejs/node/pull/29168","commit":null,"description":"The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameters can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"There are currently no options exposed. There used to\nbe options for `recursive`, `maxBusyTries`, and `emfileWait` but they were\ndeprecated and removed. The `options` argument is still accepted for\nbackwards compatibility but it is not used.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given\nto the completion callback.\n\nUsing `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on\nWindows and an `ENOTDIR` error on POSIX.\n\nTo get a behavior similar to the `rm -rf` Unix command, use [`fs.rm()`](#fsrmpath-options-callback)\nwith options `{ recursive: true, force: true }`.","summary":"Asynchronous `rmdir(2)`. No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsrmpath-options-callback","name":"rm","title":"`fs.rm(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v14.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.3.0","v16.14.0"],"prUrl":"https://github.com/nodejs/node/pull/41132","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, exceptions will be ignored if `path` does\nnot exist.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"maxRetries","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n`EPERM` error is encountered, Node.js will retry the operation with a linear\nbackoff wait of `retryDelay` milliseconds longer on each try. This option\nrepresents the number of retries. This option is ignored if the `recursive`\noption is not `true`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, perform a recursive removal. In\nrecursive mode operations are retried on failure.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"retryDelay","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The amount of time in milliseconds to wait between\nretries. This option is ignored if the `recursive` option is not `true`.","default":"100","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously removes files and directories (modeled on the standard POSIX `rm`\nutility). No arguments other than a possible exception are given to the\ncompletion callback.","summary":"Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility). No arguments other than a possible exception are given to the completion callback.","examples":[],"children":[]},{"kind":"method","id":"fsstatpath-options-callback","name":"stat","title":"`fs.stat(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.7.0"],"prUrl":"https://github.com/nodejs/node/pull/61178","commit":null,"description":"Accepts a `throwIfNoEntry` option to specify whether an exception should be thrown if the entry does not exist."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"throwIfNoEntry","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether an exception will be thrown\nif no file system entry exists, rather than returning `undefined`.","default":"true","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stats","type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where\n`stats` is an {fs.Stats} object.\n\nIn case of an error, the `err.code` will be one of [Common System Errors](errors.html#common-system-errors).\n\n[`fs.stat()`](#fsstatpath-options-callback) follows symbolic links. Use [`fs.lstat()`](#fslstatpath-options-callback) to look at the\nlinks themselves.\n\nUsing `fs.stat()` to check for the existence of a file before calling\n`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.\nInstead, user code should open/read/write the file directly and handle the\nerror raised if the file is not available.\n\nTo check if a file exists without manipulating it afterwards, [`fs.access()`](#fsaccesspath-mode-callback)\nis recommended.\n\nFor example, given the following directory structure:\n\n```text\n- txtDir\n-- file.txt\n- app.js\n```\n\nThe next program will check for the stats of the given paths:\n\n```mjs\nimport { stat } from 'node:fs';\n\nconst pathsToCheck = ['./txtDir', './txtDir/file.txt'];\n\nfor (let i = 0; i < pathsToCheck.length; i++) {\n  stat(pathsToCheck[i], (err, stats) => {\n    console.log(stats.isDirectory());\n    console.log(stats);\n  });\n}\n```\n\nThe resulting output will resemble:\n\n```console\ntrue\nStats {\n  dev: 16777220,\n  mode: 16877,\n  nlink: 3,\n  uid: 501,\n  gid: 20,\n  rdev: 0,\n  blksize: 4096,\n  ino: 14214262,\n  size: 96,\n  blocks: 0,\n  atimeMs: 1561174653071.963,\n  mtimeMs: 1561174614583.3518,\n  ctimeMs: 1561174626623.5366,\n  birthtimeMs: 1561174126937.2893,\n  atime: 2019-06-22T03:37:33.072Z,\n  mtime: 2019-06-22T03:36:54.583Z,\n  ctime: 2019-06-22T03:37:06.624Z,\n  birthtime: 2019-06-22T03:28:46.937Z,\n  atimeInstant: 2019-06-22T03:37:33.071963Z,\n  mtimeInstant: 2019-06-22T03:36:54.5833518Z,\n  ctimeInstant: 2019-06-22T03:37:06.6235366Z,\n  birthtimeInstant: 2019-06-22T03:28:46.9372893Z\n}\nfalse\nStats {\n  dev: 16777220,\n  mode: 33188,\n  nlink: 1,\n  uid: 501,\n  gid: 20,\n  rdev: 0,\n  blksize: 4096,\n  ino: 14214074,\n  size: 8,\n  blocks: 8,\n  atimeMs: 1561174616618.8555,\n  mtimeMs: 1561174614584,\n  ctimeMs: 1561174614583.8145,\n  birthtimeMs: 1561174007710.7478,\n  atime: 2019-06-22T03:36:56.619Z,\n  mtime: 2019-06-22T03:36:54.584Z,\n  ctime: 2019-06-22T03:36:54.584Z,\n  birthtime: 2019-06-22T03:26:47.711Z,\n  atimeInstant: 2019-06-22T03:36:56.6188555Z,\n  mtimeInstant: 2019-06-22T03:36:54.584Z,\n  ctimeInstant: 2019-06-22T03:36:54.5838145Z,\n  birthtimeInstant: 2019-06-22T03:26:47.7107478Z\n}\n```","summary":"Asynchronous `stat(2)`. The callback gets two arguments `(err, stats)` where `stats` is an {fs.Stats} object.","examples":[{"language":"text","displayName":null,"code":"- txtDir\n-- file.txt\n- app.js"},{"language":"mjs","displayName":null,"code":"import { stat } from 'node:fs';\n\nconst pathsToCheck = ['./txtDir', './txtDir/file.txt'];\n\nfor (let i = 0; i < pathsToCheck.length; i++) {\n  stat(pathsToCheck[i], (err, stats) => {\n    console.log(stats.isDirectory());\n    console.log(stats);\n  });\n}"},{"language":"console","displayName":null,"code":"true\nStats {\n  dev: 16777220,\n  mode: 16877,\n  nlink: 3,\n  uid: 501,\n  gid: 20,\n  rdev: 0,\n  blksize: 4096,\n  ino: 14214262,\n  size: 96,\n  blocks: 0,\n  atimeMs: 1561174653071.963,\n  mtimeMs: 1561174614583.3518,\n  ctimeMs: 1561174626623.5366,\n  birthtimeMs: 1561174126937.2893,\n  atime: 2019-06-22T03:37:33.072Z,\n  mtime: 2019-06-22T03:36:54.583Z,\n  ctime: 2019-06-22T03:37:06.624Z,\n  birthtime: 2019-06-22T03:28:46.937Z,\n  atimeInstant: 2019-06-22T03:37:33.071963Z,\n  mtimeInstant: 2019-06-22T03:36:54.5833518Z,\n  ctimeInstant: 2019-06-22T03:37:06.6235366Z,\n  birthtimeInstant: 2019-06-22T03:28:46.9372893Z\n}\nfalse\nStats {\n  dev: 16777220,\n  mode: 33188,\n  nlink: 1,\n  uid: 501,\n  gid: 20,\n  rdev: 0,\n  blksize: 4096,\n  ino: 14214074,\n  size: 8,\n  blocks: 8,\n  atimeMs: 1561174616618.8555,\n  mtimeMs: 1561174614584,\n  ctimeMs: 1561174614583.8145,\n  birthtimeMs: 1561174007710.7478,\n  atime: 2019-06-22T03:36:56.619Z,\n  mtime: 2019-06-22T03:36:54.584Z,\n  ctime: 2019-06-22T03:36:54.584Z,\n  birthtime: 2019-06-22T03:26:47.711Z,\n  atimeInstant: 2019-06-22T03:36:56.6188555Z,\n  mtimeInstant: 2019-06-22T03:36:54.584Z,\n  ctimeInstant: 2019-06-22T03:36:54.5838145Z,\n  birthtimeInstant: 2019-06-22T03:26:47.7107478Z\n}"}],"children":[]},{"kind":"method","id":"fsstatfspath-options-callback","name":"statfs","title":"`fs.statfs(path[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.StatFs} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stats","type":{"text":"fs.StatFs","links":[{"name":"fs.StatFs","href":"fs.html#class-fsstatfs","start":0,"end":9}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which\ncontains `path`. The callback gets two arguments `(err, stats)` where `stats`\nis an {fs.StatFs} object.\n\nIn case of an error, the `err.code` will be one of [Common System Errors](errors.html#common-system-errors).","summary":"Asynchronous `statfs(2)`. Returns information about the mounted file system which contains `path`. The callback gets two arguments `(err, stats)` where `stats` is an {fs.StatFs} object.","examples":[],"children":[]},{"kind":"method","id":"fssymlinktarget-path-type-callback","name":"symlink","title":"`fs.symlink(target, path[, type], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/23724","commit":null,"description":"If the `type` argument is left undefined, Node will autodetect `target` type and automatically select `dir` or `file`."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."}],"signature":{"parameters":[{"name":"target","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"type","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates the link called `path` pointing to `target`. No arguments other than a\npossible exception are given to the completion callback.\n\nSee the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details.\n\nThe `type` argument is only available on Windows and ignored on other platforms.\nIt can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is\n`null`, Node.js will autodetect `target` type and use `'file'` or `'dir'`.\nIf the `target` does not exist, `'file'` will be used. Windows junction points\nrequire the destination path to be absolute. When using `'junction'`, the\n`target` argument will automatically be normalized to absolute path. Junction\npoints on NTFS volumes can only point to directories.\n\nRelative targets are relative to the link's parent directory.\n\n```mjs\nimport { symlink } from 'node:fs';\n\nsymlink('./mew', './mewtwo', callback);\n```\n\nThe above example creates a symbolic link `mewtwo` which points to `mew` in the\nsame directory:\n\n```bash\n$ tree .\n.\n├── mew\n└── mewtwo -> ./mew\n```","summary":"Creates the link called `path` pointing to `target`. No arguments other than a possible exception are given to the completion callback.","examples":[{"language":"mjs","displayName":null,"code":"import { symlink } from 'node:fs';\n\nsymlink('./mew', './mewtwo', callback);"},{"language":"bash","displayName":null,"code":"$ tree .\n.\n├── mew\n└── mewtwo -> ./mew"}],"children":[]},{"kind":"method","id":"fstruncatepath-len-callback","name":"truncate","title":"`fs.truncate(path[, len], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.8.6"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37460","commit":null,"description":"The error returned may be an `AggregateError` if more than one error is returned."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error | AggregateError","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5},{"name":"AggregateError","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError","start":8,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Truncates the file. No arguments other than a possible exception are\ngiven to the completion callback. A file descriptor can also be passed as the\nfirst argument. In this case, `fs.ftruncate()` is called.\n\n```mjs\nimport { truncate } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was truncated');\n});\n```\n\n```cjs\nconst { truncate } = require('node:fs');\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was truncated');\n});\n```\n\nPassing a file descriptor is deprecated and may result in an error being thrown\nin the future.\n\nSee the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.","summary":"Truncates the file. No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case, `fs.ftruncate()` is called.","examples":[{"language":"mjs","displayName":null,"code":"import { truncate } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was truncated');\n});"},{"language":"cjs","displayName":null,"code":"const { truncate } = require('node:fs');\n// Assuming that 'path/file.txt' is a regular file.\ntruncate('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was truncated');\n});"}],"children":[]},{"kind":"method","id":"fsunlinkpath-callback","name":"unlink","title":"`fs.unlink(path, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously removes a file or symbolic link. No arguments other than a\npossible exception are given to the completion callback.\n\n```mjs\nimport { unlink } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\nunlink('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was deleted');\n});\n```\n\n`fs.unlink()` will not work on a directory, empty or otherwise. To remove a\ndirectory, use [`fs.rmdir()`](#fsrmdirpath-options-callback).\n\nSee the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details.","summary":"Asynchronously removes a file or symbolic link. No arguments other than a possible exception are given to the completion callback.","examples":[{"language":"mjs","displayName":null,"code":"import { unlink } from 'node:fs';\n// Assuming that 'path/file.txt' is a regular file.\nunlink('path/file.txt', (err) => {\n  if (err) throw err;\n  console.log('path/file.txt was deleted');\n});"}],"children":[]},{"kind":"method","id":"fsunwatchfilefilename-listener","name":"unwatchFile","title":"`fs.unwatchFile(filename[, listener])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"filename","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"listener","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"Optional, a listener previously attached using\n`fs.watchFile()`","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Stop watching for changes on `filename`. If `listener` is specified, only that\nparticular listener is removed. Otherwise, *all* listeners are removed,\neffectively stopping watching of `filename`.\n\nCalling `fs.unwatchFile()` with a filename that is not being watched is a\nno-op, not an error.\n\nUsing [`fs.watch()`](#fswatchfilename-options-listener) is more efficient than `fs.watchFile()` and\n`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`\nand `fs.unwatchFile()` when possible.","summary":"Stop watching for changes on `filename`. If `listener` is specified, only that particular listener is removed. Otherwise, _all_ listeners are removed, effectively stopping watching of `filename`.","examples":[],"children":[]},{"kind":"method","id":"fsutimespath-atime-mtime-callback","name":"utimes","title":"`fs.utimes(path, atime, mtime, callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11919","commit":null,"description":"`NaN`, `Infinity`, and `-Infinity` are no longer valid time specifiers."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v4.1.0"],"prUrl":"https://github.com/nodejs/node/pull/2387","commit":null,"description":"Numeric strings, `NaN`, and `Infinity` are now allowed time specifiers."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Change the file system timestamps of the object referenced by `path`.\n\nThe `atime` and `mtime` arguments follow these rules:\n\n* Values can be either numbers representing Unix epoch time in seconds,\n  `Date`s, or a numeric string like `'123456789.0'`.\n* If the value can not be converted to a number, or is `NaN`, `Infinity`, or\n  `-Infinity`, an `Error` will be thrown.","summary":"Change the file system timestamps of the object referenced by `path`.","examples":[],"children":[]},{"kind":"method","id":"fswatchfilename-options-listener","name":"watch","title":"`fs.watch(filename[, options][, listener])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/61870","commit":null,"description":"Added `throwIfNoEntry` option."},{"versions":["v19.1.0"],"prUrl":"https://github.com/nodejs/node/pull/45098","commit":null,"description":"Added recursive support for Linux, AIX and IBMi."},{"versions":["v15.9.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/37190","commit":null,"description":"Added support for closing the watcher with an AbortSignal."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `filename` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7831","commit":null,"description":"The passed `options` object will never be modified."}],"signature":{"parameters":[{"name":"filename","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"persistent","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Indicates whether the process should continue to run\nas long as files are being watched.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Indicates whether all subdirectories should be\nwatched, or only the current directory. This applies when a directory is\nspecified, and only on supported platforms (See [caveats](#caveats)).","default":"false","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Specifies the character encoding to be used for the\nfilename passed to the listener.","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows closing the watcher with an AbortSignal.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"throwIfNoEntry","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Indicates whether an exception should be thrown when the\npath does not exist.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"ignore","type":{"text":"string | RegExp | Function | Array","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"RegExp","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp","start":9,"end":15},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":18,"end":26},{"name":"Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array","start":29,"end":34}]},"description":"Pattern(s) to ignore. Strings are\nglob patterns (using [`minimatch`](https://github.com/isaacs/minimatch)), RegExp patterns are tested against\nthe filename, and functions receive the filename and return `true` to\nignore.","default":"undefined","optional":true,"rest":false,"properties":[]}]},{"name":"listener","type":{"text":"Function | undefined","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":11,"end":20}]},"description":"","default":"undefined","optional":true,"rest":false,"properties":[{"name":"eventType","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"filename","type":{"text":"string | Buffer | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.FSWatcher","links":[{"name":"fs.FSWatcher","href":"fs.html#fsfswatcher","start":0,"end":12}]},"description":""}},"description":"Watch for changes on `filename`, where `filename` is either a file or a\ndirectory.\n\nThe second argument is optional. If `options` is provided as a string, it\nspecifies the `encoding`. Otherwise `options` should be passed as an object.\n\nThe listener callback gets two arguments `(eventType, filename)`. `eventType`\nis either `'rename'` or `'change'`, and `filename` is the name of the file\nwhich triggered the event.\n\nOn most platforms, `'rename'` is emitted whenever a filename appears or\ndisappears in the directory.\n\nThe listener callback is attached to the `'change'` event fired by\n{fs.FSWatcher}, but it is not the same thing as the `'change'` value of\n`eventType`.\n\nIf a `signal` is passed, aborting the corresponding AbortController will close\nthe returned {fs.FSWatcher}.","summary":"Watch for changes on `filename`, where `filename` is either a file or a directory.","examples":[],"children":[{"kind":"section","id":"caveats","name":"Caveats","title":"Caveats","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `fs.watch` API is not 100% consistent across platforms, and is\nunavailable in some situations.\n\nOn Windows, no events will be emitted if the watched directory is moved or\nrenamed. An `EPERM` error is reported when the watched directory is deleted.\n\nThe `fs.watch` API does not provide any protection with respect\nto malicious actions on the file system. For example, on Windows it is\nimplemented by monitoring changes in a directory versus specific files. This\nallows substitution of a file and fs reporting changes on the new file\nwith the same filename.","summary":"The `fs.watch` API is not 100% consistent across platforms, and is unavailable in some situations.","examples":[],"children":[{"kind":"section","id":"availability","name":"Availability","title":"Availability","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"This feature depends on the underlying operating system providing a way\nto be notified of file system changes.\n\n* On Linux systems, this uses [`inotify(7)`](https://man7.org/linux/man-pages/man7/inotify.7.html).\n* On BSD systems, this uses [`kqueue(2)`](https://www.freebsd.org/cgi/man.cgi?query=kqueue\\&sektion=2).\n* On macOS, this uses [`kqueue(2)`](https://www.freebsd.org/cgi/man.cgi?query=kqueue\\&sektion=2) for files and [`FSEvents`](https://developer.apple.com/documentation/coreservices/file_system_events) for\n  directories.\n* On SunOS systems (including Solaris and SmartOS), this uses [`event ports`](https://illumos.org/man/port_create).\n* On Windows systems, this feature depends on [`ReadDirectoryChangesW`](https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw).\n* On AIX systems, this feature depends on [`AHAFS`](https://www.ibm.com/docs/en/aix/7.3.0?topic=management-aix-event-infrastructure-aix-aix-clusters-ahafs), which must be enabled.\n* On IBM i systems, this feature is not supported.\n\nIf the underlying functionality is not available for some reason, then\n`fs.watch()` will not be able to function and may throw an exception.\nFor example, watching files or directories can be unreliable, and in some\ncases impossible, on network file systems (NFS, SMB, etc) or host file systems\nwhen using virtualization software such as Vagrant or Docker.\n\nIt is still possible to use `fs.watchFile()`, which uses stat polling, but\nthis method is slower and less reliable.","summary":"This feature depends on the underlying operating system providing a way to be notified of file system changes.","examples":[],"children":[]},{"kind":"section","id":"inodes","name":"Inodes","title":"Inodes","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"On Linux and macOS systems, `fs.watch()` resolves the path to an [inode](https://en.wikipedia.org/wiki/Inode) and\nwatches the inode. If the watched path is deleted and recreated, it is assigned\na new inode. The watch will emit an event for the delete but will continue\nwatching the *original* inode. Events for the new inode will not be emitted.\nThis is expected behavior.\n\nAIX files retain the same inode for the lifetime of a file. Saving and closing a\nwatched file on AIX will result in two notifications (one for adding new\ncontent, and one for truncation).","summary":"On Linux and macOS systems, `fs.watch()` resolves the path to an inode and watches the inode. If the watched path is deleted and recreated, it is assigned a new inode. The watch will emit an event for the delete but will continue watching the _original_ inode. Events for the new inode will not be emitted. This is expected behavior.","examples":[],"children":[]},{"kind":"section","id":"filename-argument","name":"Filename argument","title":"Filename argument","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Providing `filename` argument in the callback is only supported on Linux,\nmacOS, Windows, and AIX. Even on supported platforms, `filename` is not always\nguaranteed to be provided. Therefore, don't assume that `filename` argument is\nalways provided in the callback, and have some fallback logic if it is `null`.\n\n```mjs\nimport { watch } from 'node:fs';\nwatch('somedir', (eventType, filename) => {\n  console.log(`event type is: ${eventType}`);\n  if (filename) {\n    console.log(`filename provided: ${filename}`);\n  } else {\n    console.log('filename not provided');\n  }\n});\n```","summary":"Providing `filename` argument in the callback is only supported on Linux, macOS, Windows, and AIX. Even on supported platforms, `filename` is not always guaranteed to be provided. Therefore, don't assume that `filename` argument is always provided in the callback, and have some fallback logic if it is `null`.","examples":[{"language":"mjs","displayName":null,"code":"import { watch } from 'node:fs';\nwatch('somedir', (eventType, filename) => {\n  console.log(`event type is: ${eventType}`);\n  if (filename) {\n    console.log(`filename provided: ${filename}`);\n  } else {\n    console.log('filename not provided');\n  }\n});"}],"children":[]}]}]},{"kind":"method","id":"fswatchfilefilename-options-listener","name":"watchFile","title":"`fs.watchFile(filename[, options], listener)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"The `bigint` option is now supported."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `filename` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"filename","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"persistent","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"true","optional":true,"rest":false,"properties":[]},{"name":"interval","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"5007","optional":true,"rest":false,"properties":[]}]},{"name":"listener","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"current","type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"previous","type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.StatWatcher","links":[{"name":"fs.StatWatcher","href":"fs.html#class-fsstatwatcher","start":0,"end":14}]},"description":""}},"description":"Watch for changes on `filename`. The callback `listener` will be called each\ntime the file is accessed.\n\nThe `options` argument may be omitted. If provided, it should be an object. The\n`options` object may contain a boolean named `persistent` that indicates\nwhether the process should continue to run as long as files are being watched.\nThe `options` object may specify an `interval` property indicating how often the\ntarget should be polled in milliseconds.\n\nThe `listener` gets two arguments the current stat object and the previous\nstat object:\n\n```mjs\nimport { watchFile } from 'node:fs';\n\nwatchFile('message.text', (curr, prev) => {\n  console.log(`the current mtime is: ${curr.mtime}`);\n  console.log(`the previous mtime was: ${prev.mtime}`);\n});\n```\n\nThese stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,\nthe numeric values in these objects are specified as `BigInt`s.\n\nTo be notified when the file was modified, not just accessed, it is necessary\nto compare `curr.mtimeMs` and `prev.mtimeMs`.\n\nWhen an `fs.watchFile` operation results in an `ENOENT` error, it\nwill invoke the listener once, with all the fields zeroed (or, for dates, the\nUnix Epoch). If the file is created later on, the listener will be called\nagain, with the latest stat objects. This is a change in functionality since\nv0.10.\n\nUsing [`fs.watch()`](#fswatchfilename-options-listener) is more efficient than `fs.watchFile` and\n`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and\n`fs.unwatchFile` when possible.\n\nWhen a file being watched by `fs.watchFile()` disappears and reappears,\nthen the contents of `previous` in the second callback event (the file's\nreappearance) will be the same as the contents of `previous` in the first\ncallback event (its disappearance).\n\nThis happens when:\n\n* the file is deleted, followed by a restore\n* the file is renamed and then renamed a second time back to its original name","summary":"Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.","examples":[{"language":"mjs","displayName":null,"code":"import { watchFile } from 'node:fs';\n\nwatchFile('message.text', (curr, prev) => {\n  console.log(`the current mtime is: ${curr.mtime}`);\n  console.log(`the previous mtime was: ${prev.mtime}`);\n});"}],"children":[]},{"kind":"method","id":"fswritefd-buffer-offset-length-position-callback","name":"write","title":"`fs.write(fd, buffer, offset[, length[, position]], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.0.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `buffer` parameter won't coerce unsupported input to strings anymore."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `buffer` parameter can now be any `TypedArray` or a `DataView`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.4.0"],"prUrl":"https://github.com/nodejs/node/pull/10382","commit":null,"description":"The `buffer` parameter can now be a `Uint8Array`."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/7856","commit":null,"description":"The `offset` and `length` parameters are optional now."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesWritten","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Write `buffer` to the file specified by `fd`.\n\n`offset` determines the part of the buffer to be written, and `length` is\nan integer specifying the number of bytes to write.\n\n`position` refers to the offset from the beginning of the file where this data\nshould be written. If `typeof position !== 'number'`, the data will be written\nat the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).\n\nThe callback will be given three arguments `(err, bytesWritten, buffer)` where\n`bytesWritten` specifies how many *bytes* were written from `buffer`.\n\nIf this method is invoked as its [`util.promisify()`](util.html#utilpromisifyoriginal)ed version, it returns\na promise for an `Object` with `bytesWritten` and `buffer` properties.\n\nIt is unsafe to use `fs.write()` multiple times on the same file without waiting\nfor the callback. For this scenario, [`fs.createWriteStream()`](#fscreatewritestreampath-options) is\nrecommended.\n\nOn Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.","summary":"Write `buffer` to the file specified by `fd`.","examples":[],"children":[]},{"kind":"method","id":"fswritefd-buffer-options-callback","name":"write","title":"`fs.write(fd, buffer[, options], callback)`","scope":"module","overloadOf":"fswritefd-buffer-offset-length-position-callback","stability":null,"added":["v18.3.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesWritten","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Write `buffer` to the file specified by `fd`.\n\nSimilar to the above `fs.write` function, this version takes an\noptional `options` object. If no `options` object is specified, it will\ndefault with the above values.","summary":"Write `buffer` to the file specified by `fd`.","examples":[],"children":[]},{"kind":"method","id":"fswritefd-string-position-encoding-callback","name":"write","title":"`fs.write(fd, string[, position[, encoding]], callback)`","scope":"module","overloadOf":"fswritefd-buffer-offset-length-position-callback","stability":null,"added":["v0.11.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v19.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42796","commit":null,"description":"Passing to the `string` parameter an object with an own `toString` function is no longer supported."},{"versions":["v17.8.0"],"prUrl":"https://github.com/nodejs/node/pull/42149","commit":null,"description":"Passing to the `string` parameter an object with an own `toString` function is deprecated."},{"versions":["v14.12.0"],"prUrl":"https://github.com/nodejs/node/pull/34993","commit":null,"description":"The `string` parameter will stringify an object with an explicit `toString` function."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `string` parameter won't coerce unsupported input to strings anymore."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/7856","commit":null,"description":"The `position` parameter is optional now."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"written","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Write `string` to the file specified by `fd`. If `string` is not a string,\nan exception is thrown.\n\n`position` refers to the offset from the beginning of the file where this data\nshould be written. If `typeof position !== 'number'` the data will be written at\nthe current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).\n\n`encoding` is the expected string encoding.\n\nThe callback will receive the arguments `(err, written, string)` where `written`\nspecifies how many *bytes* the passed string required to be written. Bytes\nwritten is not necessarily the same as string characters written. See\n[`Buffer.byteLength`](buffer.html#static-method-bufferbytelengthstring-encoding).\n\nIt is unsafe to use `fs.write()` multiple times on the same file without waiting\nfor the callback. For this scenario, [`fs.createWriteStream()`](#fscreatewritestreampath-options) is\nrecommended.\n\nOn Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.\n\nOn Windows, if the file descriptor is connected to the console (e.g. `fd == 1`\nor `stdout`) a string containing non-ASCII characters will not be rendered\nproperly by default, regardless of the encoding used.\nIt is possible to configure the console to render UTF-8 properly by changing the\nactive codepage with the `chcp 65001` command. See the [chcp](https://ss64.com/nt/chcp.html) docs for more\ndetails.","summary":"Write `string` to the file specified by `fd`. If `string` is not a string, an exception is thrown.","examples":[],"children":[]},{"kind":"method","id":"fswritefilefile-data-options-callback","name":"writeFile","title":"`fs.writeFile(file, data[, options], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.29"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50009","commit":null,"description":"The `flush` option is now supported."},{"versions":["v19.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42796","commit":null,"description":"Passing to the `string` parameter an object with an own `toString` function is no longer supported."},{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."},{"versions":["v17.8.0"],"prUrl":"https://github.com/nodejs/node/pull/42149","commit":null,"description":"Passing to the `string` parameter an object with an own `toString` function is deprecated."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37460","commit":null,"description":"The error returned may be an `AggregateError` if more than one error is returned."},{"versions":["v15.2.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/35993","commit":null,"description":"The options argument may include an AbortSignal to abort an ongoing writeFile request."},{"versions":["v14.12.0"],"prUrl":"https://github.com/nodejs/node/pull/34993","commit":null,"description":"The `data` parameter will stringify an object with an explicit `toString` function."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `data` parameter won't coerce unsupported input to strings anymore."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `data` parameter can now be any `TypedArray` or a `DataView`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12562","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."},{"versions":["v7.4.0"],"prUrl":"https://github.com/nodejs/node/pull/10382","commit":null,"description":"The `data` parameter can now be a `Uint8Array`."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7897","commit":null,"description":"The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `file` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"file","type":{"text":"string | Buffer | URL | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":31}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'w'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If all data is successfully written to the file, and\n`flush` is `true`, `fs.fsync()` is used to flush the data.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"allows aborting an in-progress writeFile","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error | AggregateError","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5},{"name":"AggregateError","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError","start":8,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"When `file` is a filename, asynchronously writes data to the file, replacing the\nfile if it already exists. `data` can be a string or a buffer.\n\nWhen `file` is a file descriptor, the behavior is similar to calling\n`fs.write()` directly (which is recommended). See the notes below on using\na file descriptor.\n\nThe `encoding` option is ignored if `data` is a buffer.\n\nThe `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\n```mjs\nimport { writeFile } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst data = new Uint8Array(Buffer.from('Hello Node.js'));\nwriteFile('message.txt', data, (err) => {\n  if (err) throw err;\n  console.log('The file has been saved!');\n});\n```\n\nIf `options` is a string, then it specifies the encoding:\n\n```mjs\nimport { writeFile } from 'node:fs';\n\nwriteFile('message.txt', 'Hello Node.js', 'utf8', callback);\n```\n\nIt is unsafe to use `fs.writeFile()` multiple times on the same file without\nwaiting for the callback. For this scenario, [`fs.createWriteStream()`](#fscreatewritestreampath-options) is\nrecommended.\n\nSimilarly to `fs.readFile` - `fs.writeFile` is a convenience method that\nperforms multiple `write` calls internally to write the buffer passed to it.\nFor performance sensitive code consider using [`fs.createWriteStream()`](#fscreatewritestreampath-options).\n\nIt is possible to use an {AbortSignal} to cancel an `fs.writeFile()`.\nCancelation is \"best effort\", and some amount of data is likely still\nto be written.\n\n```mjs\nimport { writeFile } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst controller = new AbortController();\nconst { signal } = controller;\nconst data = new Uint8Array(Buffer.from('Hello Node.js'));\nwriteFile('message.txt', data, { signal }, (err) => {\n  // When a request is aborted - the callback is called with an AbortError\n});\n// When the request should be aborted\ncontroller.abort();\n```\n\nAborting an ongoing request does not abort individual operating\nsystem requests but rather the internal buffering `fs.writeFile` performs.","summary":"When `file` is a filename, asynchronously writes data to the file, replacing the file if it already exists. `data` can be a string or a buffer.","examples":[{"language":"mjs","displayName":null,"code":"import { writeFile } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst data = new Uint8Array(Buffer.from('Hello Node.js'));\nwriteFile('message.txt', data, (err) => {\n  if (err) throw err;\n  console.log('The file has been saved!');\n});"},{"language":"mjs","displayName":null,"code":"import { writeFile } from 'node:fs';\n\nwriteFile('message.txt', 'Hello Node.js', 'utf8', callback);"},{"language":"mjs","displayName":null,"code":"import { writeFile } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst controller = new AbortController();\nconst { signal } = controller;\nconst data = new Uint8Array(Buffer.from('Hello Node.js'));\nwriteFile('message.txt', data, { signal }, (err) => {\n  // When a request is aborted - the callback is called with an AbortError\n});\n// When the request should be aborted\ncontroller.abort();"}],"children":[{"kind":"section","id":"using-fswritefile-with-file-descriptors","name":"Using fs.writeFile() with file descriptors","title":"Using `fs.writeFile()` with file descriptors","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When `file` is a file descriptor, the behavior is almost identical to directly\ncalling `fs.write()` like:\n\n```mjs\nimport { write } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nwrite(fd, Buffer.from(data, options.encoding), callback);\n```\n\nThe difference from directly calling `fs.write()` is that under some unusual\nconditions, `fs.write()` might write only part of the buffer and need to be\nretried to write the remaining data, whereas `fs.writeFile()` retries until\nthe data is entirely written (or an error occurs).\n\nThe implications of this are a common source of confusion. In\nthe file descriptor case, the file is not replaced! The data is not necessarily\nwritten to the beginning of the file, and the file's original data may remain\nbefore and/or after the newly written data.\n\nFor example, if `fs.writeFile()` is called twice in a row, first to write the\nstring `'Hello'`, then to write the string `', World'`, the file would contain\n`'Hello, World'`, and might contain some of the file's original data (depending\non the size of the original file, and the position of the file descriptor). If\na file name had been used instead of a descriptor, the file would be guaranteed\nto contain only `', World'`.","summary":"When `file` is a file descriptor, the behavior is almost identical to directly calling `fs.write()` like:","examples":[{"language":"mjs","displayName":null,"code":"import { write } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nwrite(fd, Buffer.from(data, options.encoding), callback);"}],"children":[]}]},{"kind":"method","id":"fswritevfd-buffers-position-callback","name":"writev","title":"`fs.writev(fd, buffers[, position], callback)`","scope":"module","overloadOf":null,"stability":null,"added":["v12.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"bytesWritten","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Write an array of `ArrayBufferView`s to the file specified by `fd` using\n`writev()`.\n\n`position` is the offset from the beginning of the file where this data\nshould be written. If `typeof position !== 'number'`, the data will be written\nat the current position.\n\nThe callback will be given three arguments: `err`, `bytesWritten`, and\n`buffers`. `bytesWritten` is how many bytes were written from `buffers`.\n\nIf this method is [`util.promisify()`](util.html#utilpromisifyoriginal)ed, it returns a promise for an\n`Object` with `bytesWritten` and `buffers` properties.\n\nIt is unsafe to use `fs.writev()` multiple times on the same file without\nwaiting for the callback. For this scenario, use [`fs.createWriteStream()`](#fscreatewritestreampath-options).\n\nOn Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.","summary":"Write an array of `ArrayBufferView`s to the file specified by `fd` using `writev()`.","examples":[],"children":[]}]},{"kind":"section","id":"synchronous-api","name":"Synchronous API","title":"Synchronous API","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The synchronous APIs perform all operations synchronously, blocking the\nevent loop until the operation completes or fails.","summary":"The synchronous APIs perform all operations synchronously, blocking the event loop until the operation completes or fails.","examples":[],"children":[{"kind":"method","id":"fsaccesssyncpath-mode","name":"accessSync","title":"`fs.accessSync(path[, mode])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"fs.constants.F_OK","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Synchronously tests a user's permissions for the file or directory specified\nby `path`. The `mode` argument is an optional integer that specifies the\naccessibility checks to be performed. `mode` should be either the value\n`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of\n`fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK` (e.g.\n`fs.constants.W_OK | fs.constants.R_OK`). Check [File access constants](#file-access-constants) for\npossible values of `mode`.\n\nIf any of the accessibility checks fail, an `Error` will be thrown. Otherwise,\nthe method will return `undefined`.\n\n```mjs\nimport { accessSync, constants } from 'node:fs';\n\ntry {\n  accessSync('etc/passwd', constants.R_OK | constants.W_OK);\n  console.log('can read/write');\n} catch (err) {\n  console.error('no access!');\n}\n```","summary":"Synchronously tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK` (e.g. `fs.constants.W_OK | fs.constants.R_OK`). Check File access constants for possible values of `mode`.","examples":[{"language":"mjs","displayName":null,"code":"import { accessSync, constants } from 'node:fs';\n\ntry {\n  accessSync('etc/passwd', constants.R_OK | constants.W_OK);\n  console.log('can read/write');\n} catch (err) {\n  console.error('no access!');\n}"}],"children":[]},{"kind":"method","id":"fsappendfilesyncpath-data-options","name":"appendFileSync","title":"`fs.appendFileSync(path, data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.6.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.1.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50095","commit":null,"description":"The `flush` option is now supported."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7831","commit":null,"description":"The passed `options` object will never be modified."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `file` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":30}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'a'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, the underlying file descriptor is flushed\nprior to closing it.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Synchronously append data to a file, creating the file if it does not yet\nexist. `data` can be a string or a {Buffer}.\n\nThe `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\n```mjs\nimport { appendFileSync } from 'node:fs';\n\ntry {\n  appendFileSync('message.txt', 'data to append');\n  console.log('The \"data to append\" was appended to file!');\n} catch (err) {\n  /* Handle the error */\n}\n```\n\nIf `options` is a string, then it specifies the encoding:\n\n```mjs\nimport { appendFileSync } from 'node:fs';\n\nappendFileSync('message.txt', 'data to append', 'utf8');\n```\n\nThe `path` may be specified as a numeric file descriptor that has been opened\nfor appending (using `fs.open()` or `fs.openSync()`). The file descriptor will\nnot be closed automatically.\n\n```mjs\nimport { openSync, closeSync, appendFileSync } from 'node:fs';\n\nlet fd;\n\ntry {\n  fd = openSync('message.txt', 'a');\n  appendFileSync(fd, 'data to append', 'utf8');\n} catch (err) {\n  /* Handle the error */\n} finally {\n  if (fd !== undefined)\n    closeSync(fd);\n}\n```","summary":"Synchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a {Buffer}.","examples":[{"language":"mjs","displayName":null,"code":"import { appendFileSync } from 'node:fs';\n\ntry {\n  appendFileSync('message.txt', 'data to append');\n  console.log('The \"data to append\" was appended to file!');\n} catch (err) {\n  /* Handle the error */\n}"},{"language":"mjs","displayName":null,"code":"import { appendFileSync } from 'node:fs';\n\nappendFileSync('message.txt', 'data to append', 'utf8');"},{"language":"mjs","displayName":null,"code":"import { openSync, closeSync, appendFileSync } from 'node:fs';\n\nlet fd;\n\ntry {\n  fd = openSync('message.txt', 'a');\n  appendFileSync(fd, 'data to append', 'utf8');\n} catch (err) {\n  /* Handle the error */\n} finally {\n  if (fd !== undefined)\n    closeSync(fd);\n}"}],"children":[]},{"kind":"method","id":"fschmodsyncpath-mode","name":"chmodSync","title":"`fs.chmodSync(path, mode)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.6.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.chmod()`](#fschmodpath-mode-callback).\n\nSee the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.chmod()`.","examples":[],"children":[]},{"kind":"method","id":"fschownsyncpath-uid-gid","name":"chownSync","title":"`fs.chownSync(path, uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.97"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Synchronously changes owner and group of a file. Returns `undefined`.\nThis is the synchronous version of [`fs.chown()`](#fschownpath-uid-gid-callback).\n\nSee the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.","summary":"Synchronously changes owner and group of a file. Returns `undefined`. This is the synchronous version of `fs.chown()`.","examples":[],"children":[]},{"kind":"method","id":"fsclosesyncfd","name":"closeSync","title":"`fs.closeSync(fd)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Closes the file descriptor. Returns `undefined`.\n\nCalling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use\nthrough any other `fs` operation may lead to undefined behavior.\n\nSee the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.","summary":"Closes the file descriptor. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fscopyfilesyncsrc-dest-mode","name":"copyFileSync","title":"`fs.copyFileSync(src, dest[, mode])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/27044","commit":null,"description":"Changed `flags` argument to `mode` and imposed stricter type validation."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"source filename to copy","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"destination filename of the copy operation","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"modifiers for copy operation.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it\nalready exists. Returns `undefined`. Node.js makes no guarantees about the\natomicity of the copy operation. If an error occurs after the destination file\nhas been opened for writing, Node.js will attempt to remove the destination.\n\nSymbolic links are followed. If `src` is a symbolic link, the target file is\ncopied. If `dest` is a symbolic link, the target file is overwritten unless\n`mode` contains `fs.constants.COPYFILE_EXCL`.\n\n`mode` is an optional integer that specifies the behavior\nof the copy operation. It is possible to create a mask consisting of the bitwise\nOR of two or more values (e.g.\n`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).\n\n* `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already\n  exists.\n* `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a\n  copy-on-write reflink. If the platform does not support copy-on-write, then a\n  fallback copy mechanism is used.\n* `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to\n  create a copy-on-write reflink. If the platform does not support\n  copy-on-write, then the operation will fail.\n\n```mjs\nimport { copyFileSync, constants } from 'node:fs';\n\n// destination.txt will be created or overwritten by default.\ncopyFileSync('source.txt', 'destination.txt');\nconsole.log('source.txt was copied to destination.txt');\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ncopyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);\n```","summary":"Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists. Returns `undefined`. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.","examples":[{"language":"mjs","displayName":null,"code":"import { copyFileSync, constants } from 'node:fs';\n\n// destination.txt will be created or overwritten by default.\ncopyFileSync('source.txt', 'destination.txt');\nconsole.log('source.txt was copied to destination.txt');\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\ncopyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);"}],"children":[]},{"kind":"method","id":"fscpsyncsrc-dest-options","name":"cpSync","title":"`fs.cpSync(src, dest[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.3.0"],"prUrl":"https://github.com/nodejs/node/pull/53127","commit":null,"description":"This API is no longer experimental."},{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/47084","commit":null,"description":"Accept an additional `mode` option to specify the copy behavior as the `mode` argument of `fs.copyFile()`."},{"versions":["v17.6.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41819","commit":null,"description":"Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks."}],"signature":{"parameters":[{"name":"src","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"dereference","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"dereference symlinks.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"errorOnExist","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"when `force` is `false`, and the destination\nexists, throw an error.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"filter","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"Function to filter copied files/directories. Return\n`true` to copy the item, `false` to ignore it. When ignoring a directory,\nall of its contents will be skipped as well.","default":"undefined","optional":true,"rest":false,"properties":[{"name":"src","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"source path to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"destination path to copy to.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Any non-`Promise` value that is coercible\nto `boolean`.","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"overwrite existing file or directory. The copy\noperation will ignore errors if you set this to false and the destination\nexists. Use the `errorOnExist` option to change this behavior.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"modifiers for copy operation.","default":"0`. See `mode` flag of `fs.copyFileSync()","optional":true,"rest":false,"properties":[]},{"name":"preserveTimestamps","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true` timestamps from `src` will\nbe preserved.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"copy directories recursively","default":"false","optional":true,"rest":false,"properties":[]},{"name":"verbatimSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, path resolution for symlinks will\nbe skipped.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Synchronously copies the entire directory structure from `src` to `dest`,\nincluding subdirectories and files.\n\nWhen copying a directory to another directory, globs are not supported and\nbehavior is similar to `cp dir1/ dir2/`.","summary":"Synchronously copies the entire directory structure from `src` to `dest`, including subdirectories and files.","examples":[],"children":[]},{"kind":"method","id":"fsexistssyncpath","name":"existsSync","title":"`fs.existsSync(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the path exists, `false` otherwise.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.exists()`](#fsexistspath-callback).\n\n`fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`\nparameter to `fs.exists()` accepts parameters that are inconsistent with other\nNode.js callbacks. `fs.existsSync()` does not use a callback.\n\n```mjs\nimport { existsSync } from 'node:fs';\n\nif (existsSync('/etc/passwd'))\n  console.log('The path exists.');\n```","summary":"Returns `true` if the path exists, `false` otherwise.","examples":[{"language":"mjs","displayName":null,"code":"import { existsSync } from 'node:fs';\n\nif (existsSync('/etc/passwd'))\n  console.log('The path exists.');"}],"children":[]},{"kind":"method","id":"fsfchmodsyncfd-mode","name":"fchmodSync","title":"`fs.fchmodSync(fd, mode)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Sets the permissions on the file. Returns `undefined`.\n\nSee the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.","summary":"Sets the permissions on the file. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsfchownsyncfd-uid-gid","name":"fchownSync","title":"`fs.fchownSync(fd, uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new owner's user id.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new group's group id.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Sets the owner of the file. Returns `undefined`.\n\nSee the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.","summary":"Sets the owner of the file. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsfdatasyncsyncfd","name":"fdatasyncSync","title":"`fs.fdatasyncSync(fd)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.96"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Forces all currently queued I/O operations associated with the file to the\noperating system's synchronized I/O completion state. Refer to the POSIX\n[`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`.","summary":"Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX `fdatasync(2)` documentation for details. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsfstatsyncfd-options","name":"fstatSync","title":"`fs.fstatSync(fd[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.95"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":""}},"description":"Retrieves the {fs.Stats} for the file descriptor.\n\nSee the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.","summary":"Retrieves the {fs.Stats} for the file descriptor.","examples":[],"children":[]},{"kind":"method","id":"fsfsyncsyncfd","name":"fsyncSync","title":"`fs.fsyncSync(fd)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.96"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Request that all data for the open file descriptor is flushed to the storage\ndevice. The specific implementation is operating system and device specific.\nRefer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`.","summary":"Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX `fsync(2)` documentation for more detail. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsftruncatesyncfd-len","name":"ftruncateSync","title":"`fs.ftruncateSync(fd[, len])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.8.6"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Truncates the file descriptor. Returns `undefined`.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.ftruncate()`](#fsftruncatefd-len-callback).","summary":"Truncates the file descriptor. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsfutimessyncfd-atime-mtime","name":"futimesSync","title":"`fs.futimesSync(fd, atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v4.1.0"],"prUrl":"https://github.com/nodejs/node/pull/2387","commit":null,"description":"Numeric strings, `NaN`, and `Infinity` are now allowed time specifiers."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Synchronous version of [`fs.futimes()`](#fsfutimesfd-atime-mtime-callback). Returns `undefined`.","summary":"Synchronous version of `fs.futimes()`. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsglobsyncpattern-options","name":"globSync","title":"`fs.globSync(pattern[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v22.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62695","commit":null,"description":"Add support for the `followSymlinks` option."},{"versions":["v24.1.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/58182","commit":null,"description":"Add support for `URL` instances for `cwd` option."},{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."},{"versions":["v23.7.0","v22.14.0"],"prUrl":"https://github.com/nodejs/node/pull/56489","commit":null,"description":"Add support for `exclude` option to accept glob patterns."},{"versions":["v22.2.0"],"prUrl":"https://github.com/nodejs/node/pull/52837","commit":null,"description":"Add support for `withFileTypes` as an option."}],"signature":{"parameters":[{"name":"pattern","type":{"text":"string | string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"cwd","type":{"text":"string | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"URL","href":"url.html#the-whatwg-url-api","start":9,"end":12}]},"description":"current working directory.","default":"process.cwd()","optional":true,"rest":false,"properties":[]},{"name":"exclude","type":{"text":"Function | string[]","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":11,"end":17}]},"description":"Function to filter out files/directories or a\nlist of glob patterns to be excluded. If a function is provided, return\n`true` to exclude the item, `false` to include it.","default":"undefined","optional":true,"rest":false,"properties":[]},{"name":"followSymlinks","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, symbolic links to directories are\nfollowed while expanding `**` patterns.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if the glob should return paths as Dirents,\n`false` otherwise.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"paths of files that match the pattern."}},"description":"When `followSymlinks` is enabled, detected symbolic link cycles are not\ntraversed recursively.\n\n```mjs\nimport { globSync } from 'node:fs';\n\nconsole.log(globSync('**/*.js'));\n```\n\n```cjs\nconst { globSync } = require('node:fs');\n\nconsole.log(globSync('**/*.js'));\n```","summary":"When `followSymlinks` is enabled, detected symbolic link cycles are not traversed recursively.","examples":[{"language":"mjs","displayName":null,"code":"import { globSync } from 'node:fs';\n\nconsole.log(globSync('**/*.js'));"},{"language":"cjs","displayName":null,"code":"const { globSync } = require('node:fs');\n\nconsole.log(globSync('**/*.js'));"}],"children":[]},{"kind":"method","id":"fslchmodsyncpath-mode","name":"lchmodSync","title":"`fs.lchmodSync(path, mode)`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated"},"added":["v0.5.0"],"deprecated":["v0.5.0"],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Changes the permissions on a symbolic link. Returns `undefined`.\n\nThis method is only implemented on macOS.\n\nSee the POSIX [`lchmod(2)`](http://man7.org/linux/man-pages/man2/lchmod.2.html) documentation for more detail.","summary":"Changes the permissions on a symbolic link. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fslchownsyncpath-uid-gid","name":"lchownSync","title":"`fs.lchownSync(path, uid, gid)`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.6.0"],"prUrl":"https://github.com/nodejs/node/pull/21498","commit":null,"description":"This API is no longer deprecated."},{"versions":["v0.4.7"],"prUrl":null,"commit":null,"description":"Documentation-only deprecation."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"uid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new owner's user id.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"gid","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The file's new group's group id.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Set the owner for the path. Returns `undefined`.\n\nSee the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details.","summary":"Set the owner for the path. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fslutimessyncpath-atime-mtime","name":"lutimesSync","title":"`fs.lutimesSync(path, atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v14.5.0","v12.19.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Change the file system timestamps of the symbolic link referenced by `path`.\nReturns `undefined`, or throws an exception when parameters are incorrect or\nthe operation fails. This is the synchronous version of [`fs.lutimes()`](#fslutimespath-atime-mtime-callback).","summary":"Change the file system timestamps of the symbolic link referenced by `path`. Returns `undefined`, or throws an exception when parameters are incorrect or the operation fails. This is the synchronous version of `fs.lutimes()`.","examples":[],"children":[]},{"kind":"method","id":"fslinksyncexistingpath-newpath","name":"linkSync","title":"`fs.linkSync(existingPath, newPath)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `existingPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."}],"signature":{"parameters":[{"name":"existingPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX\n[`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`.","summary":"Creates a new link from the `existingPath` to the `newPath`. See the POSIX `link(2)` documentation for more detail. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fslstatsyncpath-options","name":"lstatSync","title":"`fs.lstatSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.30"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.3.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/33716","commit":null,"description":"Accepts a `throwIfNoEntry` option to specify whether an exception should be thrown if the entry does not exist."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"throwIfNoEntry","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether an exception will be thrown\nif no file system entry exists, rather than returning `undefined`.","default":"true","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":""}},"description":"Retrieves the {fs.Stats} for the symbolic link referred to by `path`.\n\nSee the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.","summary":"Retrieves the {fs.Stats} for the symbolic link referred to by `path`.","examples":[],"children":[]},{"kind":"method","id":"fsmkdirsyncpath-options","name":"mkdirSync","title":"`fs.mkdirSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v13.11.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/31530","commit":null,"description":"In `recursive` mode, the first created path is returned now."},{"versions":["v10.12.0"],"prUrl":"https://github.com/nodejs/node/pull/21875","commit":null,"description":"The second argument can now be an `options` object with `recursive` and `mode` properties."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | integer","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"Not supported on Windows.","default":"0o777","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | undefined","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":9,"end":18}]},"description":""}},"description":"Synchronously creates a directory. Returns `undefined`, or if `recursive` is\n`true`, the first directory path created.\nThis is the synchronous version of [`fs.mkdir()`](#fsmkdirpath-options-callback).\n\nSee the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.","summary":"Synchronously creates a directory. Returns `undefined`, or if `recursive` is `true`, the first directory path created. This is the synchronous version of `fs.mkdir()`.","examples":[],"children":[]},{"kind":"method","id":"fsmkdtempsyncprefix-options","name":"mkdtempSync","title":"`fs.mkdtempSync(prefix[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.6.0","v18.19.0"],"prUrl":"https://github.com/nodejs/node/pull/48828","commit":null,"description":"The `prefix` parameter now accepts buffers and URL."},{"versions":["v16.5.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/39028","commit":null,"description":"The `prefix` parameter now accepts an empty string."}],"signature":{"parameters":[{"name":"prefix","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Returns the created directory path.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.mkdtemp()`](#fsmkdtempprefix-options-callback).\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use.","summary":"Returns the created directory path.","examples":[],"children":[]},{"kind":"method","id":"fsmkdtempdisposablesyncprefix-options","name":"mkdtempDisposableSync","title":"`fs.mkdtempDisposableSync(prefix[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v24.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"prefix","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"A disposable object:"}},"description":"Returns a disposable object whose `path` property holds the created directory\npath. When the object is disposed, the directory and its contents will be\nremoved if it still exists. If the directory cannot be deleted, disposal will\nthrow an error. The object has a `remove()` method which will perform the same\ntask.\n\nSee the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using) for more information about\nexplicit resource management.\n\nFor detailed information, see the documentation of [`fs.mkdtemp()`](#fsmkdtempprefix-options-callback).\n\nThere is no callback-based version of this API because it is designed for use\nwith the [`using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using) syntax.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use.","summary":"Returns a disposable object whose `path` property holds the created directory path. When the object is disposed, the directory and its contents will be removed if it still exists. If the directory cannot be deleted, disposal will throw an error. The object has a `remove()` method which will perform the same task.","examples":[],"children":[]},{"kind":"method","id":"fsopendirsyncpath-options","name":"opendirSync","title":"`fs.opendirSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v13.1.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30114","commit":null,"description":"The `bufferSize` option was introduced."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"bufferSize","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number of directory entries that are buffered\ninternally when reading from the directory. Higher values lead to better\nperformance but higher memory usage.","default":"32","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.Dir","links":[{"name":"fs.Dir","href":"fs.html#class-fsdir","start":0,"end":6}]},"description":""}},"description":"Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).\n\nCreates an {fs.Dir}, which contains all further functions for reading from\nand cleaning up the directory.\n\nThe `encoding` option sets the encoding for the `path` while opening the\ndirectory and subsequent read operations.","summary":"Synchronously open a directory. See `opendir(3)`.","examples":[],"children":[]},{"kind":"method","id":"fsopensyncpath-flags-mode","name":"openSync","title":"`fs.openSync(path[, flags[, mode]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v11.1.0"],"prUrl":"https://github.com/nodejs/node/pull/23767","commit":null,"description":"The `flags` argument is now optional and defaults to `'r'`."},{"versions":["v9.9.0"],"prUrl":"https://github.com/nodejs/node/pull/18801","commit":null,"description":"The `as` and `as+` flags are supported now."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"flags","type":{"text":"string | number","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":15}]},"description":"","default":"'r'`. See support of file system `flags","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"string | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":9,"end":16}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Returns an integer representing the file descriptor.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.open()`](#fsopenpath-flags-mode-callback).","summary":"Returns an integer representing the file descriptor.","examples":[],"children":[]},{"kind":"method","id":"fsreaddirsyncpath-options","name":"readdirSync","title":"`fs.readdirSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.1.0","v18.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41439","commit":null,"description":"Added `recursive` option."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22020","commit":null,"description":"New option `withFileTypes` was added."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"withFileTypes","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"","default":"false","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, reads the contents of a directory\nrecursively. In recursive mode, it will list all files, sub files, and\ndirectories.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string[] | Buffer[] | fs.Dirent[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":11,"end":17},{"name":"fs.Dirent","href":"fs.html#class-fsdirent","start":22,"end":31}]},"description":""}},"description":"Reads the contents of the directory.\n\nSee the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe filenames returned. If the `encoding` is set to `'buffer'`,\nthe filenames returned will be passed as {Buffer} objects.\n\nIf `options.withFileTypes` is set to `true`, the result will contain\n{fs.Dirent} objects.","summary":"Reads the contents of the directory.","examples":[],"children":[]},{"kind":"method","id":"fsreadfilesyncpath-options","name":"readFileSync","title":"`fs.readFileSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.4.0"],"prUrl":"https://github.com/nodejs/node/pull/63634","commit":null,"description":"Added support for the `buffer` option."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `path` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":31}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'r'","optional":true,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView | Function","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30},{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":33,"end":41}]},"description":"A buffer to read into, or a\nfunction called with the file size that returns the buffer.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":""}},"description":"Returns the contents of the `path`.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.readFile()`](#fsreadfilepath-options-callback).\n\nIf the `encoding` option is specified then this function returns a\nstring. Otherwise it returns a buffer.\n\nIf `buffer` is provided and no encoding is specified, the returned {Buffer} is\na view over the supplied buffer containing only the bytes read. If the\nsupplied buffer is too small to contain the entire file, an error will be\nthrown.\n\nSimilar to [`fs.readFile()`](#fsreadfilepath-options-callback), when the path is a directory, the behavior of\n`fs.readFileSync()` is platform-specific.\n\n```mjs\nimport { readFileSync } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFileSync('<directory>');\n// => [Error: EISDIR: illegal operation on a directory, read <directory>]\n\n//  FreeBSD\nreadFileSync('<directory>'); // => <data>\n```","summary":"Returns the contents of the `path`.","examples":[{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n\n// macOS, Linux, and Windows\nreadFileSync('<directory>');\n// => [Error: EISDIR: illegal operation on a directory, read <directory>]\n\n//  FreeBSD\nreadFileSync('<directory>'); // => <data>"}],"children":[]},{"kind":"method","id":"fsreadlinksyncpath-options","name":"readlinkSync","title":"`fs.readlinkSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":""}},"description":"Returns the symbolic link's string value.\n\nSee the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe link path returned. If the `encoding` is set to `'buffer'`,\nthe link path returned will be passed as a {Buffer} object.","summary":"Returns the symbolic link's string value.","examples":[],"children":[]},{"kind":"method","id":"fsreadsyncfd-buffer-offset-length-position","name":"readSync","title":"`fs.readSync(fd, buffer, offset, length[, position])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `buffer` parameter can now be any `TypedArray` or a `DataView`."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/4518","commit":null,"description":"The `length` parameter can now be `0`."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Returns the number of `bytesRead`.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.read()`](#fsreadfd-buffer-offset-length-position-callback).","summary":"Returns the number of `bytesRead`.","examples":[],"children":[]},{"kind":"method","id":"fsreadsyncfd-buffer-options","name":"readSync","title":"`fs.readSync(fd, buffer[, options])`","scope":"module","overloadOf":"fsreadsyncfd-buffer-offset-length-position","stability":null,"added":["v13.13.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v13.13.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/32460","commit":null,"description":"Options object can be passed in to make offset, length, and position optional."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | bigint | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":10,"end":16},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":19,"end":23}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Returns the number of `bytesRead`.\n\nSimilar to the above `fs.readSync` function, this version takes an optional `options` object.\nIf no `options` object is specified, it will default with the above values.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.read()`](#fsreadfd-buffer-offset-length-position-callback).","summary":"Returns the number of `bytesRead`.","examples":[],"children":[]},{"kind":"method","id":"fsreadvsyncfd-buffers-position","name":"readvSync","title":"`fs.readvSync(fd, buffers[, position])`","scope":"module","overloadOf":null,"stability":null,"added":["v13.13.0","v12.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes read."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.readv()`](#fsreadvfd-buffers-position-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.readv()`.","examples":[],"children":[]},{"kind":"method","id":"fsrealpathsyncpath-options","name":"realpathSync","title":"`fs.realpathSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/13028","commit":null,"description":"Pipe/Socket resolve support was added."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v6.4.0"],"prUrl":"https://github.com/nodejs/node/pull/7899","commit":null,"description":"Calling `realpathSync` now works again for various edge cases on Windows."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3594","commit":null,"description":"The `cache` parameter was removed."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":""}},"description":"Returns the resolved pathname.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.realpath()`](#fsrealpathpath-options-callback).","summary":"Returns the resolved pathname.","examples":[],"children":[]},{"kind":"method","id":"fsrealpathsyncnativepath-options","name":"native","title":"`fs.realpathSync.native(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v9.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"string | Object","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":""}},"description":"Synchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).\n\nOnly paths that can be converted to UTF8 strings are supported.\n\nThe optional `options` argument can be a string specifying an encoding, or an\nobject with an `encoding` property specifying the character encoding to use for\nthe path returned. If the `encoding` is set to `'buffer'`,\nthe path returned will be passed as a {Buffer} object.\n\nOn Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on `/proc` in order for this function to work. Glibc does not have\nthis restriction.","summary":"Synchronous `realpath(3)`.","examples":[],"children":[]},{"kind":"method","id":"fsrenamesyncoldpath-newpath","name":"renameSync","title":"`fs.renameSync(oldPath, newPath)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `oldPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."}],"signature":{"parameters":[{"name":"oldPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"newPath","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Renames the file from `oldPath` to `newPath`. Returns `undefined`.\n\nSee the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details.","summary":"Renames the file from `oldPath` to `newPath`. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsrmdirsyncpath-options","name":"rmdirSync","title":"`fs.rmdirSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.0.0"],"prUrl":"https://github.com/nodejs/node/pull/58616","commit":null,"description":"Remove `recursive` option."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fs.rmdirSync(path, { recursive: true })` on a `path` that is a file is no longer permitted and results in an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37216","commit":null,"description":"Using `fs.rmdirSync(path, { recursive: true })` on a `path` that does not exist is no longer permitted and results in a `ENOENT` error."},{"versions":["v16.0.0"],"prUrl":"https://github.com/nodejs/node/pull/37302","commit":null,"description":"The `recursive` option is deprecated, using it triggers a deprecation warning."},{"versions":["v14.14.0"],"prUrl":"https://github.com/nodejs/node/pull/35579","commit":null,"description":"The `recursive` option is deprecated, use `fs.rmSync` instead."},{"versions":["v13.3.0","v12.16.0"],"prUrl":"https://github.com/nodejs/node/pull/30644","commit":null,"description":"The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."},{"versions":["v12.10.0"],"prUrl":"https://github.com/nodejs/node/pull/29168","commit":null,"description":"The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameters can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"There are currently no options exposed. There used to\nbe options for `recursive`, `maxBusyTries`, and `emfileWait` but they were\ndeprecated and removed. The `options` argument is still accepted for\nbackwards compatibility but it is not used.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`.\n\nUsing `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error\non Windows and an `ENOTDIR` error on POSIX.\n\nTo get a behavior similar to the `rm -rf` Unix command, use [`fs.rmSync()`](#fsrmsyncpath-options)\nwith options `{ recursive: true, force: true }`.","summary":"Synchronous `rmdir(2)`. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsrmsyncpath-options","name":"rmSync","title":"`fs.rmSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v14.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.3.0","v16.14.0"],"prUrl":"https://github.com/nodejs/node/pull/41132","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"force","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When `true`, exceptions will be ignored if `path` does\nnot exist.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"maxRetries","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or\n`EPERM` error is encountered, Node.js will retry the operation with a linear\nbackoff wait of `retryDelay` milliseconds longer on each try. This option\nrepresents the number of retries. This option is ignored if the `recursive`\noption is not `true`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"recursive","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, perform a recursive directory removal. In\nrecursive mode operations are retried on failure.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"retryDelay","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The amount of time in milliseconds to wait between\nretries. This option is ignored if the `recursive` option is not `true`.","default":"100","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Synchronously removes files and directories (modeled on the standard POSIX `rm`\nutility). Returns `undefined`.","summary":"Synchronously removes files and directories (modeled on the standard POSIX `rm` utility). Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsstatsyncpath-options","name":"statSync","title":"`fs.statSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.3.0","v14.17.0"],"prUrl":"https://github.com/nodejs/node/pull/33716","commit":null,"description":"Accepts a `throwIfNoEntry` option to specify whether an exception should be thrown if the entry does not exist."},{"versions":["v10.5.0"],"prUrl":"https://github.com/nodejs/node/pull/20220","commit":null,"description":"Accepts an additional `options` object to specify whether the numeric values returned should be bigint."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.Stats} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"throwIfNoEntry","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether an exception will be thrown\nif no file system entry exists, rather than returning `undefined`.","default":"true","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.Stats","links":[{"name":"fs.Stats","href":"fs.html#class-fsstats","start":0,"end":8}]},"description":""}},"description":"Retrieves the {fs.Stats} for the path.","summary":"Retrieves the {fs.Stats} for the path.","examples":[],"children":[]},{"kind":"method","id":"fsstatfssyncpath-options","name":"statfsSync","title":"`fs.statfsSync(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"bigint","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether the numeric values in the returned\n{fs.StatFs} object should be `bigint`.","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.StatFs","links":[{"name":"fs.StatFs","href":"fs.html#class-fsstatfs","start":0,"end":9}]},"description":""}},"description":"Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which\ncontains `path`.\n\nIn case of an error, the `err.code` will be one of [Common System Errors](errors.html#common-system-errors).","summary":"Synchronous `statfs(2)`. Returns information about the mounted file system which contains `path`.","examples":[],"children":[]},{"kind":"method","id":"fssymlinksynctarget-path-type","name":"symlinkSync","title":"`fs.symlinkSync(target, path[, type])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.31"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v12.0.0"],"prUrl":"https://github.com/nodejs/node/pull/23724","commit":null,"description":"If the `type` argument is left undefined, Node will autodetect `target` type and automatically select `dir` or `file`."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."}],"signature":{"parameters":[{"name":"target","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"type","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":null,"description":"`undefined`."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.symlink()`](#fssymlinktarget-path-type-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.symlink()`.","examples":[],"children":[]},{"kind":"method","id":"fstruncatesyncpath-len","name":"truncateSync","title":"`fs.truncateSync(path[, len])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.8.6"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"len","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Truncates the file. Returns `undefined`. A file descriptor can also be\npassed as the first argument. In this case, `fs.ftruncateSync()` is called.\n\nPassing a file descriptor is deprecated and may result in an error being thrown\nin the future.","summary":"Truncates the file. Returns `undefined`. A file descriptor can also be passed as the first argument. In this case, `fs.ftruncateSync()` is called.","examples":[],"children":[]},{"kind":"method","id":"fsunlinksyncpath","name":"unlinkSync","title":"`fs.unlinkSync(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`.","summary":"Synchronous `unlink(2)`. Returns `undefined`.","examples":[],"children":[]},{"kind":"method","id":"fsutimessyncpath-atime-mtime","name":"utimesSync","title":"`fs.utimesSync(path, atime, mtime)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/11919","commit":null,"description":"`NaN`, `Infinity`, and `-Infinity` are no longer valid time specifiers."},{"versions":["v7.6.0"],"prUrl":"https://github.com/nodejs/node/pull/10739","commit":null,"description":"The `path` parameter can be a WHATWG `URL` object using `file:` protocol."},{"versions":["v4.1.0"],"prUrl":"https://github.com/nodejs/node/pull/2387","commit":null,"description":"Numeric strings, `NaN`, and `Infinity` are now allowed time specifiers."}],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"atime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mtime","type":{"text":"number | string | Date","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15},{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":18,"end":22}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":null,"description":"`undefined`."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.utimes()`](#fsutimespath-atime-mtime-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.utimes()`.","examples":[],"children":[]},{"kind":"method","id":"fswritefilesyncfile-data-options","name":"writeFileSync","title":"`fs.writeFileSync(file, data[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.29"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v21.0.0","v20.10.0"],"prUrl":"https://github.com/nodejs/node/pull/50009","commit":null,"description":"The `flush` option is now supported."},{"versions":["v19.0.0"],"prUrl":"https://github.com/nodejs/node/pull/42796","commit":null,"description":"Passing to the `data` parameter an object with an own `toString` function is no longer supported."},{"versions":["v17.8.0"],"prUrl":"https://github.com/nodejs/node/pull/42149","commit":null,"description":"Passing to the `data` parameter an object with an own `toString` function is deprecated."},{"versions":["v14.12.0"],"prUrl":"https://github.com/nodejs/node/pull/34993","commit":null,"description":"The `data` parameter will stringify an object with an explicit `toString` function."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `data` parameter won't coerce unsupported input to strings anymore."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `data` parameter can now be any `TypedArray` or a `DataView`."},{"versions":["v7.4.0"],"prUrl":"https://github.com/nodejs/node/pull/10382","commit":null,"description":"The `data` parameter can now be a `Uint8Array`."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/3163","commit":null,"description":"The `file` parameter can be a file descriptor now."}],"signature":{"parameters":[{"name":"file","type":{"text":"string | Buffer | URL | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":24,"end":31}]},"description":"filename or file descriptor","default":null,"optional":false,"rest":false,"properties":[]},{"name":"data","type":{"text":"string | Buffer | TypedArray | DataView","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object | string","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"encoding","type":{"text":"string | null","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":9,"end":13}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"mode","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0o666","optional":true,"rest":false,"properties":[]},{"name":"flag","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"See [support of file system `flags`](#file-system-flags).","default":"'w'","optional":true,"rest":false,"properties":[]},{"name":"flush","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If all data is successfully written to the file, and\n`flush` is `true`, `fs.fsyncSync()` is used to flush the data.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":null,"description":"`undefined`."}},"description":"The `mode` option only affects the newly created file. See [`fs.open()`](#fsopenpath-flags-mode-callback)\nfor more details.\n\nFor detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.writeFile()`](#fswritefilefile-data-options-callback).","summary":"The `mode` option only affects the newly created file. See `fs.open()` for more details.","examples":[],"children":[]},{"kind":"method","id":"fswritesyncfd-buffer-offset-length-position","name":"writeSync","title":"`fs.writeSync(fd, buffer, offset[, length[, position]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `buffer` parameter won't coerce unsupported input to strings anymore."},{"versions":["v10.10.0"],"prUrl":"https://github.com/nodejs/node/pull/22150","commit":null,"description":"The `buffer` parameter can now be any `TypedArray` or a `DataView`."},{"versions":["v7.4.0"],"prUrl":"https://github.com/nodejs/node/pull/10382","commit":null,"description":"The `buffer` parameter can now be a `Uint8Array`."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/7856","commit":null,"description":"The `offset` and `length` parameters are optional now."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes written."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.write(fd, buffer...)`](#fswritefd-buffer-offset-length-position-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.write(fd, buffer...)`.","examples":[],"children":[]},{"kind":"method","id":"fswritesyncfd-buffer-options","name":"writeSync","title":"`fs.writeSync(fd, buffer[, options])`","scope":"module","overloadOf":"fswritesyncfd-buffer-offset-length-position","stability":null,"added":["v18.3.0","v16.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffer","type":{"text":"Buffer | TypedArray | DataView","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":9,"end":19},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":22,"end":30}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":"buffer.byteLength - offset","optional":true,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes written."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.write(fd, buffer...)`](#fswritefd-buffer-offset-length-position-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.write(fd, buffer...)`.","examples":[],"children":[]},{"kind":"method","id":"fswritesyncfd-string-position-encoding","name":"writeSync","title":"`fs.writeSync(fd, string[, position[, encoding]])`","scope":"module","overloadOf":"fswritesyncfd-buffer-offset-length-position","stability":null,"added":["v0.11.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/31030","commit":null,"description":"The `string` parameter won't coerce unsupported input to strings anymore."},{"versions":["v7.2.0"],"prUrl":"https://github.com/nodejs/node/pull/7856","commit":null,"description":"The `position` parameter is optional now."}],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes written."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.write(fd, string...)`](#fswritefd-string-position-encoding-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.write(fd, string...)`.","examples":[],"children":[]},{"kind":"method","id":"fswritevsyncfd-buffers-position","name":"writevSync","title":"`fs.writevSync(fd, buffers[, position])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buffers","type":{"text":"ArrayBufferView[]","links":[{"name":"ArrayBufferView","href":"https://developer.mozilla.org/docs/Web/API/ArrayBufferView","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"position","type":{"text":"integer | null","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":10,"end":14}]},"description":"","default":"null","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of bytes written."}},"description":"For detailed information, see the documentation of the asynchronous version of\nthis API: [`fs.writev()`](#fswritevfd-buffers-position-callback).","summary":"For detailed information, see the documentation of the asynchronous version of this API: `fs.writev()`.","examples":[],"children":[]}]},{"kind":"section","id":"common-objects","name":"Common Objects","title":"Common Objects","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The common objects are shared by all of the file system API variants\n(promise, callback, and synchronous).","summary":"The common objects are shared by all of the file system API variants (promise, callback, and synchronous).","examples":[],"children":[{"kind":"class","id":"class-fsdir","name":"Dir","title":"Class: `fs.Dir`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"A class representing a directory stream.\n\nCreated by [`fs.opendir()`](#fsopendirpath-options-callback), [`fs.opendirSync()`](#fsopendirsyncpath-options), or\n[`fsPromises.opendir()`](#fspromisesopendirpath-options).\n\n```mjs\nimport { opendir } from 'node:fs/promises';\n\ntry {\n  const dir = await opendir('./');\n  for await (const dirent of dir)\n    console.log(dirent.name);\n} catch (err) {\n  console.error(err);\n}\n```\n\nWhen using the async iterator, the {fs.Dir} object will be automatically\nclosed after the iterator exits.","summary":"A class representing a directory stream.","examples":[{"language":"mjs","displayName":null,"code":"import { opendir } from 'node:fs/promises';\n\ntry {\n  const dir = await opendir('./');\n  for await (const dirent of dir)\n    console.log(dirent.name);\n} catch (err) {\n  console.error(err);\n}"}],"children":[{"kind":"method","id":"dirclose","name":"close","title":"`dir.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Asynchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.\n\nA promise is returned that will be fulfilled after the resource has been\nclosed.","summary":"Asynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.","examples":[],"children":[]},{"kind":"method","id":"dirclosecallback","name":"close","title":"`dir.close(callback)`","scope":"module","overloadOf":"dirclose","stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0"],"prUrl":"https://github.com/nodejs/node/pull/41678","commit":null,"description":"Passing an invalid callback to the `callback` argument now throws `ERR_INVALID_ARG_TYPE` instead of `ERR_INVALID_CALLBACK`."}],"signature":{"parameters":[{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.\n\nThe `callback` will be called after the resource handle has been closed.","summary":"Asynchronously close the directory's underlying resource handle. Subsequent reads will result in errors.","examples":[],"children":[]},{"kind":"method","id":"dirclosesync","name":"closeSync","title":"`dir.closeSync()`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Synchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.","summary":"Synchronously close the directory's underlying resource handle. Subsequent reads will result in errors.","examples":[],"children":[]},{"kind":"property","id":"dirpath","name":"path","title":"`dir.path`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The read-only path of this directory as was provided to [`fs.opendir()`](#fsopendirpath-options-callback),\n[`fs.opendirSync()`](#fsopendirsyncpath-options), or [`fsPromises.opendir()`](#fspromisesopendirpath-options).","summary":"The read-only path of this directory as was provided to `fs.opendir()`, `fs.opendirSync()`, or `fsPromises.opendir()`.","examples":[],"children":[]},{"kind":"method","id":"dirread","name":"read","title":"`dir.read()`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfills with a {fs.Dirent | null}"}},"description":"Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an {fs.Dirent}.\n\nA promise is returned that will be fulfilled with an {fs.Dirent}, or `null`\nif there are no more directory entries to read.\n\nDirectory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory might not be\nincluded in the iteration results.","summary":"Asynchronously read the next directory entry via `readdir(3)` as an {fs.Dirent}.","examples":[],"children":[]},{"kind":"method","id":"dirreadcallback","name":"read","title":"`dir.read(callback)`","scope":"module","overloadOf":"dirread","stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dirent","type":{"text":"fs.Dirent | null","links":[{"name":"fs.Dirent","href":"fs.html#class-fsdirent","start":0,"end":9},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":12,"end":16}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an {fs.Dirent}.\n\nAfter the read is completed, the `callback` will be called with an\n{fs.Dirent}, or `null` if there are no more directory entries to read.\n\nDirectory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory might not be\nincluded in the iteration results.","summary":"Asynchronously read the next directory entry via `readdir(3)` as an {fs.Dirent}.","examples":[],"children":[]},{"kind":"method","id":"dirreadsync","name":"readSync","title":"`dir.readSync()`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"fs.Dirent | null","links":[{"name":"fs.Dirent","href":"fs.html#class-fsdirent","start":0,"end":9},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":12,"end":16}]},"description":""}},"description":"Synchronously read the next directory entry as an {fs.Dirent}. See the\nPOSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.\n\nIf there are no more directory entries to read, `null` will be returned.\n\nDirectory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory might not be\nincluded in the iteration results.","summary":"Synchronously read the next directory entry as an {fs.Dirent}. See the POSIX `readdir(3)` documentation for more detail.","examples":[],"children":[]},{"kind":"method","id":"dirsymbolasynciterator","name":"[Symbol.asyncIterator]","title":"`dir[Symbol.asyncIterator]()`","scope":"module","overloadOf":null,"stability":null,"added":["v12.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"AsyncIterator","links":[{"name":"AsyncIterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator","start":0,"end":13}]},"description":"An AsyncIterator of {fs.Dirent}"}},"description":"Asynchronously iterates over the directory until all entries have\nbeen read. Refer to the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.\n\nEntries returned by the async iterator are always an {fs.Dirent}.\nThe `null` case from `dir.read()` is handled internally.\n\nSee {fs.Dir} for an example.\n\nDirectory entries returned by this iterator are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory might not be\nincluded in the iteration results.","summary":"Asynchronously iterates over the directory until all entries have been read. Refer to the POSIX `readdir(3)` documentation for more detail.","examples":[],"children":[]},{"kind":"method","id":"dirsymbolasyncdispose","name":"[Symbol.asyncDispose]","title":"`dir[Symbol.asyncDispose]()`","scope":"module","overloadOf":null,"stability":null,"added":["v24.1.0","v22.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.2.0"],"prUrl":"https://github.com/nodejs/node/pull/58467","commit":null,"description":"No longer experimental."}],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Calls `dir.close()` if the directory handle is open, and returns a promise that\nfulfills when disposal is complete.\n\nThis method enables the directory to be used with [`await using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/await_using), which\nwill automatically close the directory when the scope exits. For more\ninformation, see the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using).","summary":"Calls `dir.close()` if the directory handle is open, and returns a promise that fulfills when disposal is complete.","examples":[],"children":[]},{"kind":"method","id":"dirsymboldispose","name":"[Symbol.dispose]","title":"`dir[Symbol.dispose]()`","scope":"module","overloadOf":null,"stability":null,"added":["v24.1.0","v22.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.2.0"],"prUrl":"https://github.com/nodejs/node/pull/58467","commit":null,"description":"No longer experimental."}],"signature":{"parameters":[],"returns":null},"description":"Calls `dir.closeSync()` if the directory handle is open, and returns\n`undefined`.\n\nThis method enables the directory to be used with [`using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using), which\nwill automatically close the directory when the scope exits. For more\ninformation, see the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using).","summary":"Calls `dir.closeSync()` if the directory handle is open, and returns `undefined`.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsdirent","name":"Dirent","title":"Class: `fs.Dirent`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"A representation of a directory entry, which can be a file or a subdirectory\nwithin the directory, as returned by reading from an {fs.Dir}. The\ndirectory entry is a combination of the file name and file type pairs.\n\nAdditionally, when [`fs.readdir()`](#fsreaddirpath-options-callback) or [`fs.readdirSync()`](#fsreaddirsyncpath-options) is called with\nthe `withFileTypes` option set to `true`, the resulting array is filled with\n{fs.Dirent} objects, rather than strings or {Buffer}s.\n\nWhen a directory is read, such as with [`fs.readdir()`](#fsreaddirpath-options-callback) or\n[`fs.opendir()`](#fsopendirpath-options-callback), the file type of each entry is the type reported by the\noperating system and may depend on the file system; for example, some file\nsystems may report a type that differs from what [`fs.lstat()`](#fslstatpath-options-callback) returns.\nNode.js calls [`fs.lstat()`](#fslstatpath-options-callback) on such an entry only when the reported type\nis unknown. Use [`fs.lstat()`](#fslstatpath-options-callback) when an accurate file type is required.","summary":"A representation of a directory entry, which can be a file or a subdirectory within the directory, as returned by reading from an {fs.Dir}. The directory entry is a combination of the file name and file type pairs.","examples":[],"children":[{"kind":"method","id":"direntisblockdevice","name":"isBlockDevice","title":"`dirent.isBlockDevice()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a block device.","summary":"Returns `true` if the {fs.Dirent} object describes a block device.","examples":[],"children":[]},{"kind":"method","id":"direntischaracterdevice","name":"isCharacterDevice","title":"`dirent.isCharacterDevice()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a character device.","summary":"Returns `true` if the {fs.Dirent} object describes a character device.","examples":[],"children":[]},{"kind":"method","id":"direntisdirectory","name":"isDirectory","title":"`dirent.isDirectory()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a file system\ndirectory.","summary":"Returns `true` if the {fs.Dirent} object describes a file system directory.","examples":[],"children":[]},{"kind":"method","id":"direntisfifo","name":"isFIFO","title":"`dirent.isFIFO()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a first-in-first-out\n(FIFO) pipe.","summary":"Returns `true` if the {fs.Dirent} object describes a first-in-first-out (FIFO) pipe.","examples":[],"children":[]},{"kind":"method","id":"direntisfile","name":"isFile","title":"`dirent.isFile()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a regular file.","summary":"Returns `true` if the {fs.Dirent} object describes a regular file.","examples":[],"children":[]},{"kind":"method","id":"direntissocket","name":"isSocket","title":"`dirent.isSocket()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a socket.","summary":"Returns `true` if the {fs.Dirent} object describes a socket.","examples":[],"children":[]},{"kind":"method","id":"direntissymboliclink","name":"isSymbolicLink","title":"`dirent.isSymbolicLink()`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Dirent} object describes a symbolic link.","summary":"Returns `true` if the {fs.Dirent} object describes a symbolic link.","examples":[],"children":[]},{"kind":"property","id":"direntname","name":"name","title":"`dirent.name`","scope":"module","overloadOf":null,"stability":null,"added":["v10.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"default":null,"description":"The file name that this {fs.Dirent} object refers to. The type of this\nvalue is determined by the `options.encoding` passed to [`fs.readdir()`](#fsreaddirpath-options-callback) or\n[`fs.readdirSync()`](#fsreaddirsyncpath-options).","summary":"The file name that this {fs.Dirent} object refers to. The type of this value is determined by the `options.encoding` passed to `fs.readdir()` or `fs.readdirSync()`.","examples":[],"children":[]},{"kind":"property","id":"direntparentpath","name":"parentPath","title":"`dirent.parentPath`","scope":"module","overloadOf":null,"stability":null,"added":["v21.4.0","v20.12.0","v18.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."}],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The path to the parent directory of the file this {fs.Dirent} object refers to.","summary":"The path to the parent directory of the file this {fs.Dirent} object refers to.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsfswatcher","name":"FSWatcher","title":"Class: `fs.FSWatcher`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"EventEmitter","links":[{"name":"EventEmitter","href":"events.html#class-eventemitter","start":0,"end":12}]},"description":"A successful call to [`fs.watch()`](#fswatchfilename-options-listener) method will return a new {fs.FSWatcher}\nobject.\n\nAll {fs.FSWatcher} objects emit a `'change'` event whenever a specific watched\nfile is modified.","summary":"A successful call to `fs.watch()` method will return a new {fs.FSWatcher} object.","examples":[],"children":[{"kind":"event","id":"event-change","name":"change","title":"Event: `'change'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[{"name":"eventType","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The type of change event that has occurred","default":null,"optional":false,"rest":false,"properties":[]},{"name":"filename","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"The filename that changed (if relevant/available)","default":null,"optional":false,"rest":false,"properties":[]}],"description":"Emitted when something changes in a watched directory or file.\nSee more details in [`fs.watch()`](#fswatchfilename-options-listener).\n\nThe `filename` argument may not be provided depending on operating system\nsupport. If `filename` is provided, it will be provided as a {Buffer} if\n`fs.watch()` is called with its `encoding` option set to `'buffer'`, otherwise\n`filename` will be a UTF-8 string.\n\n```mjs\nimport { watch } from 'node:fs';\n// Example when handled through fs.watch() listener\nwatch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {\n  if (filename) {\n    console.log(filename);\n    // Prints: <Buffer ...>\n  }\n});\n```","summary":"Emitted when something changes in a watched directory or file. See more details in `fs.watch()`.","examples":[{"language":"mjs","displayName":null,"code":"import { watch } from 'node:fs';\n// Example when handled through fs.watch() listener\nwatch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {\n  if (filename) {\n    console.log(filename);\n    // Prints: <Buffer ...>\n  }\n});"}],"children":[]},{"kind":"event","id":"event-close-1","name":"close","title":"Event: `'close'`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"Emitted when the watcher stops watching for changes. The closed\n{fs.FSWatcher} object is no longer usable in the event handler.","summary":"Emitted when the watcher stops watching for changes. The closed {fs.FSWatcher} object is no longer usable in the event handler.","examples":[],"children":[]},{"kind":"event","id":"event-error","name":"error","title":"Event: `'error'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[{"name":"error","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"description":"Emitted when an error occurs while watching the file. The errored\n{fs.FSWatcher} object is no longer usable in the event handler.","summary":"Emitted when an error occurs while watching the file. The errored {fs.FSWatcher} object is no longer usable in the event handler.","examples":[],"children":[]},{"kind":"method","id":"watcherclose","name":"close","title":"`watcher.close()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.8"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Stop watching for changes on the given {fs.FSWatcher}. Once stopped, the\n{fs.FSWatcher} object is no longer usable.","summary":"Stop watching for changes on the given {fs.FSWatcher}. Once stopped, the {fs.FSWatcher} object is no longer usable.","examples":[],"children":[]},{"kind":"method","id":"watcherref","name":"ref","title":"`watcher.ref()`","scope":"module","overloadOf":null,"stability":null,"added":["v14.3.0","v12.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"fs.FSWatcher","links":[{"name":"fs.FSWatcher","href":"fs.html#fsfswatcher","start":0,"end":12}]},"description":""}},"description":"When called, requests that the Node.js event loop *not* exit so long as the\n{fs.FSWatcher} is active. Calling `watcher.ref()` multiple times will have\nno effect.\n\nBy default, all {fs.FSWatcher} objects are \"ref'ed\", making it normally\nunnecessary to call `watcher.ref()` unless `watcher.unref()` had been\ncalled previously.","summary":"When called, requests that the Node.js event loop _not_ exit so long as the {fs.FSWatcher} is active. Calling `watcher.ref()` multiple times will have no effect.","examples":[],"children":[]},{"kind":"method","id":"watcherunref","name":"unref","title":"`watcher.unref()`","scope":"module","overloadOf":null,"stability":null,"added":["v14.3.0","v12.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"fs.FSWatcher","links":[{"name":"fs.FSWatcher","href":"fs.html#fsfswatcher","start":0,"end":12}]},"description":""}},"description":"When called, the active {fs.FSWatcher} object will not require the Node.js\nevent loop to remain active. If there is no other activity keeping the\nevent loop running, the process may exit before the {fs.FSWatcher} object's\ncallback is invoked. Calling `watcher.unref()` multiple times will have\nno effect.","summary":"When called, the active {fs.FSWatcher} object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the {fs.FSWatcher} object's callback is invoked. Calling `watcher.unref()` multiple times will have no effect.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsstatwatcher","name":"StatWatcher","title":"Class: `fs.StatWatcher`","scope":"module","overloadOf":null,"stability":null,"added":["v14.3.0","v12.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"EventEmitter","links":[{"name":"EventEmitter","href":"events.html#class-eventemitter","start":0,"end":12}]},"description":"A successful call to `fs.watchFile()` method will return a new {fs.StatWatcher}\nobject.","summary":"A successful call to `fs.watchFile()` method will return a new {fs.StatWatcher} object.","examples":[],"children":[{"kind":"method","id":"watcherref-1","name":"ref","title":"`watcher.ref()`","scope":"module","overloadOf":null,"stability":null,"added":["v14.3.0","v12.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"fs.StatWatcher","links":[{"name":"fs.StatWatcher","href":"fs.html#class-fsstatwatcher","start":0,"end":14}]},"description":""}},"description":"When called, requests that the Node.js event loop *not* exit so long as the\n{fs.StatWatcher} is active. Calling `watcher.ref()` multiple times will have\nno effect.\n\nBy default, all {fs.StatWatcher} objects are \"ref'ed\", making it normally\nunnecessary to call `watcher.ref()` unless `watcher.unref()` had been\ncalled previously.","summary":"When called, requests that the Node.js event loop _not_ exit so long as the {fs.StatWatcher} is active. Calling `watcher.ref()` multiple times will have no effect.","examples":[],"children":[]},{"kind":"method","id":"watcherunref-1","name":"unref","title":"`watcher.unref()`","scope":"module","overloadOf":null,"stability":null,"added":["v14.3.0","v12.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"fs.StatWatcher","links":[{"name":"fs.StatWatcher","href":"fs.html#class-fsstatwatcher","start":0,"end":14}]},"description":""}},"description":"When called, the active {fs.StatWatcher} object will not require the Node.js\nevent loop to remain active. If there is no other activity keeping the\nevent loop running, the process may exit before the {fs.StatWatcher} object's\ncallback is invoked. Calling `watcher.unref()` multiple times will have\nno effect.","summary":"When called, the active {fs.StatWatcher} object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the {fs.StatWatcher} object's callback is invoked. Calling `watcher.unref()` multiple times will have no effect.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsreadstream","name":"ReadStream","title":"Class: `fs.ReadStream`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Readable","links":[{"name":"stream.Readable","href":"stream.html#class-streamreadable","start":0,"end":15}]},"description":"Instances of {fs.ReadStream} cannot be constructed directly. They are created and\nreturned using the [`fs.createReadStream()`](#fscreatereadstreampath-options) function.","summary":"Instances of {fs.ReadStream} cannot be constructed directly. They are created and returned using the `fs.createReadStream()` function.","examples":[],"children":[{"kind":"event","id":"event-close-2","name":"close","title":"Event: `'close'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"Emitted when the {fs.ReadStream}'s underlying file descriptor has been closed.","summary":"Emitted when the {fs.ReadStream}'s underlying file descriptor has been closed.","examples":[],"children":[]},{"kind":"event","id":"event-open","name":"open","title":"Event: `'open'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Integer file descriptor used by the {fs.ReadStream}.","default":null,"optional":false,"rest":false,"properties":[]}],"description":"Emitted when the {fs.ReadStream}'s file descriptor has been opened.","summary":"Emitted when the {fs.ReadStream}'s file descriptor has been opened.","examples":[],"children":[]},{"kind":"event","id":"event-ready","name":"ready","title":"Event: `'ready'`","scope":"module","overloadOf":null,"stability":null,"added":["v9.11.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"Emitted when the {fs.ReadStream} is ready to be used.\n\nFires immediately after `'open'`.","summary":"Emitted when the {fs.ReadStream} is ready to be used.","examples":[],"children":[]},{"kind":"property","id":"readstreambytesread","name":"bytesRead","title":"`readStream.bytesRead`","scope":"module","overloadOf":null,"stability":null,"added":["v6.4.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The number of bytes that have been read so far.","summary":"The number of bytes that have been read so far.","examples":[],"children":[]},{"kind":"property","id":"readstreampath","name":"path","title":"`readStream.path`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"default":null,"description":"The path to the file the stream is reading from as specified in the first\nargument to `fs.createReadStream()`. If `path` is passed as a string, then\n`readStream.path` will be a string. If `path` is passed as a {Buffer}, then\n`readStream.path` will be a {Buffer}. If `fd` is specified, then\n`readStream.path` will be `undefined`.","summary":"The path to the file the stream is reading from as specified in the first argument to `fs.createReadStream()`. If `path` is passed as a string, then `readStream.path` will be a string. If `path` is passed as a {Buffer}, then `readStream.path` will be a {Buffer}. If `fd` is specified, then `readStream.path` will be `undefined`.","examples":[],"children":[]},{"kind":"property","id":"readstreampending","name":"pending","title":"`readStream.pending`","scope":"module","overloadOf":null,"stability":null,"added":["v11.2.0","v10.16.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.","summary":"This property is `true` if the underlying file has not been opened yet, i.e. before the `'ready'` event is emitted.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsstats","name":"Stats","title":"Class: `fs.Stats`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.21"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.2.0"],"prUrl":"https://github.com/nodejs/node/pull/60789","commit":null,"description":"Added `Temporal.Instant` support."},{"versions":["v22.0.0","v20.13.0"],"prUrl":"https://github.com/nodejs/node/pull/51879","commit":null,"description":"Public constructor is deprecated."},{"versions":["v8.1.0"],"prUrl":"https://github.com/nodejs/node/pull/13173","commit":null,"description":"Added times as numbers."}],"extends":null,"description":"A {fs.Stats} object provides information about a file.\n\nObjects returned from [`fs.stat()`](#fsstatpath-options-callback), [`fs.lstat()`](#fslstatpath-options-callback), [`fs.fstat()`](#fsfstatfd-options-callback), and\ntheir synchronous counterparts are of this type.\nIf `bigint` in the `options` passed to those methods is true, the numeric values\nwill be `bigint` instead of `number`, and the object will contain additional\nnanosecond-precision properties suffixed with `Ns`.\n`Stat` objects are not to be created directly using the `new` keyword.\n\n```console\nStats {\n  dev: 2114,\n  ino: 48064969,\n  mode: 33188,\n  nlink: 1,\n  uid: 85,\n  gid: 100,\n  rdev: 0,\n  size: 527,\n  blksize: 4096,\n  blocks: 8,\n  atimeMs: 1318289051000.1,\n  mtimeMs: 1318289051000.1,\n  ctimeMs: 1318289051000.1,\n  birthtimeMs: 1318289051000.1,\n\n  // Instances of Date\n  atime: Mon, 10 Oct 2011 23:24:11 GMT,\n  mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n  ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n  birthtime: Mon, 10 Oct 2011 23:24:11 GMT,\n\n  // Instances of Temporal.Instant\n  atimeInstant: 2011-10-10T23:24:11.0001Z,\n  mtimeInstant: 2011-10-10T23:24:11.0001Z,\n  ctimeInstant: 2011-10-10T23:24:11.0001Z,\n  birthtimeInstant: 2011-10-10T23:24:11.0001Z\n}\n```\n\n`bigint` version:\n\n```console\nBigIntStats {\n  dev: 2114n,\n  ino: 48064969n,\n  mode: 33188n,\n  nlink: 1n,\n  uid: 85n,\n  gid: 100n,\n  rdev: 0n,\n  size: 527n,\n  blksize: 4096n,\n  blocks: 8n,\n  atimeMs: 1318289051000n,\n  mtimeMs: 1318289051000n,\n  ctimeMs: 1318289051000n,\n  birthtimeMs: 1318289051000n,\n  atimeNs: 1318289051000000000n,\n  mtimeNs: 1318289051000000000n,\n  ctimeNs: 1318289051000000000n,\n  birthtimeNs: 1318289051000000000n,\n\n  // Instances of Date\n  atime: Mon, 10 Oct 2011 23:24:11 GMT,\n  mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n  ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n  birthtime: Mon, 10 Oct 2011 23:24:11 GMT,\n\n  // Instances of Temporal.Instant\n  atimeInstant: 2011-10-10T23:24:11Z,\n  mtimeInstant: 2011-10-10T23:24:11Z,\n  ctimeInstant: 2011-10-10T23:24:11Z,\n  birthtimeInstant: 2011-10-10T23:24:11Z\n}\n```","summary":"A {fs.Stats} object provides information about a file.","examples":[{"language":"console","displayName":null,"code":"Stats {\n  dev: 2114,\n  ino: 48064969,\n  mode: 33188,\n  nlink: 1,\n  uid: 85,\n  gid: 100,\n  rdev: 0,\n  size: 527,\n  blksize: 4096,\n  blocks: 8,\n  atimeMs: 1318289051000.1,\n  mtimeMs: 1318289051000.1,\n  ctimeMs: 1318289051000.1,\n  birthtimeMs: 1318289051000.1,\n\n  // Instances of Date\n  atime: Mon, 10 Oct 2011 23:24:11 GMT,\n  mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n  ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n  birthtime: Mon, 10 Oct 2011 23:24:11 GMT,\n\n  // Instances of Temporal.Instant\n  atimeInstant: 2011-10-10T23:24:11.0001Z,\n  mtimeInstant: 2011-10-10T23:24:11.0001Z,\n  ctimeInstant: 2011-10-10T23:24:11.0001Z,\n  birthtimeInstant: 2011-10-10T23:24:11.0001Z\n}"},{"language":"console","displayName":null,"code":"BigIntStats {\n  dev: 2114n,\n  ino: 48064969n,\n  mode: 33188n,\n  nlink: 1n,\n  uid: 85n,\n  gid: 100n,\n  rdev: 0n,\n  size: 527n,\n  blksize: 4096n,\n  blocks: 8n,\n  atimeMs: 1318289051000n,\n  mtimeMs: 1318289051000n,\n  ctimeMs: 1318289051000n,\n  birthtimeMs: 1318289051000n,\n  atimeNs: 1318289051000000000n,\n  mtimeNs: 1318289051000000000n,\n  ctimeNs: 1318289051000000000n,\n  birthtimeNs: 1318289051000000000n,\n\n  // Instances of Date\n  atime: Mon, 10 Oct 2011 23:24:11 GMT,\n  mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n  ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n  birthtime: Mon, 10 Oct 2011 23:24:11 GMT,\n\n  // Instances of Temporal.Instant\n  atimeInstant: 2011-10-10T23:24:11Z,\n  mtimeInstant: 2011-10-10T23:24:11Z,\n  ctimeInstant: 2011-10-10T23:24:11Z,\n  birthtimeInstant: 2011-10-10T23:24:11Z\n}"}],"children":[{"kind":"method","id":"statsisblockdevice","name":"isBlockDevice","title":"`stats.isBlockDevice()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a block device.","summary":"Returns `true` if the {fs.Stats} object describes a block device.","examples":[],"children":[]},{"kind":"method","id":"statsischaracterdevice","name":"isCharacterDevice","title":"`stats.isCharacterDevice()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a character device.","summary":"Returns `true` if the {fs.Stats} object describes a character device.","examples":[],"children":[]},{"kind":"method","id":"statsisdirectory","name":"isDirectory","title":"`stats.isDirectory()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a file system directory.\n\nIf the {fs.Stats} object was obtained from calling [`fs.lstat()`](#fslstatpath-options-callback) on a\nsymbolic link which resolves to a directory, this method will return `false`.\nThis is because [`fs.lstat()`](#fslstatpath-options-callback) returns information\nabout a symbolic link itself and not the path it resolves to.","summary":"Returns `true` if the {fs.Stats} object describes a file system directory.","examples":[],"children":[]},{"kind":"method","id":"statsisfifo","name":"isFIFO","title":"`stats.isFIFO()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a first-in-first-out (FIFO)\npipe.","summary":"Returns `true` if the {fs.Stats} object describes a first-in-first-out (FIFO) pipe.","examples":[],"children":[]},{"kind":"method","id":"statsisfile","name":"isFile","title":"`stats.isFile()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a regular file.","summary":"Returns `true` if the {fs.Stats} object describes a regular file.","examples":[],"children":[]},{"kind":"method","id":"statsissocket","name":"isSocket","title":"`stats.isSocket()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a socket.","summary":"Returns `true` if the {fs.Stats} object describes a socket.","examples":[],"children":[]},{"kind":"method","id":"statsissymboliclink","name":"isSymbolicLink","title":"`stats.isSymbolicLink()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.10"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if the {fs.Stats} object describes a symbolic link.\n\nThis method is only valid when using [`fs.lstat()`](#fslstatpath-options-callback).","summary":"Returns `true` if the {fs.Stats} object describes a symbolic link.","examples":[],"children":[]},{"kind":"property","id":"statsdev","name":"dev","title":"`stats.dev`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The numeric identifier of the device containing the file.","summary":"The numeric identifier of the device containing the file.","examples":[],"children":[]},{"kind":"property","id":"statsino","name":"ino","title":"`stats.ino`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The file system specific \"Inode\" number for the file.","summary":"The file system specific \"Inode\" number for the file.","examples":[],"children":[]},{"kind":"property","id":"statsmode","name":"mode","title":"`stats.mode`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"A bit-field describing the file type and mode.","summary":"A bit-field describing the file type and mode.","examples":[],"children":[]},{"kind":"property","id":"statsnlink","name":"nlink","title":"`stats.nlink`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The number of hard-links that exist for the file.","summary":"The number of hard-links that exist for the file.","examples":[],"children":[]},{"kind":"property","id":"statsuid","name":"uid","title":"`stats.uid`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The numeric user identifier of the user that owns the file (POSIX).","summary":"The numeric user identifier of the user that owns the file (POSIX).","examples":[],"children":[]},{"kind":"property","id":"statsgid","name":"gid","title":"`stats.gid`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The numeric group identifier of the group that owns the file (POSIX).","summary":"The numeric group identifier of the group that owns the file (POSIX).","examples":[],"children":[]},{"kind":"property","id":"statsrdev","name":"rdev","title":"`stats.rdev`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"A numeric device identifier if the file represents a device.","summary":"A numeric device identifier if the file represents a device.","examples":[],"children":[]},{"kind":"property","id":"statssize","name":"size","title":"`stats.size`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The size of the file in bytes.\n\nIf the underlying file system does not support getting the size of the file,\nthis will be `0`.","summary":"The size of the file in bytes.","examples":[],"children":[]},{"kind":"property","id":"statsblksize","name":"blksize","title":"`stats.blksize`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The file system block size for i/o operations.","summary":"The file system block size for i/o operations.","examples":[],"children":[]},{"kind":"property","id":"statsblocks","name":"blocks","title":"`stats.blocks`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The number of blocks allocated for this file.","summary":"The number of blocks allocated for this file.","examples":[],"children":[]},{"kind":"property","id":"statsatimems","name":"atimeMs","title":"`stats.atimeMs`","scope":"module","overloadOf":null,"stability":null,"added":["v8.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The timestamp indicating the last time this file was accessed expressed in\nmilliseconds since the POSIX Epoch.","summary":"The timestamp indicating the last time this file was accessed expressed in milliseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsmtimems","name":"mtimeMs","title":"`stats.mtimeMs`","scope":"module","overloadOf":null,"stability":null,"added":["v8.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The timestamp indicating the last time this file was modified expressed in\nmilliseconds since the POSIX Epoch.","summary":"The timestamp indicating the last time this file was modified expressed in milliseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsctimems","name":"ctimeMs","title":"`stats.ctimeMs`","scope":"module","overloadOf":null,"stability":null,"added":["v8.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The timestamp indicating the last time the file status was changed expressed\nin milliseconds since the POSIX Epoch.","summary":"The timestamp indicating the last time the file status was changed expressed in milliseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsbirthtimems","name":"birthtimeMs","title":"`stats.birthtimeMs`","scope":"module","overloadOf":null,"stability":null,"added":["v8.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"The timestamp indicating the creation time of this file expressed in\nmilliseconds since the POSIX Epoch.","summary":"The timestamp indicating the creation time of this file expressed in milliseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsatimens","name":"atimeNs","title":"`stats.atimeNs`","scope":"module","overloadOf":null,"stability":null,"added":["v12.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"default":null,"description":"Only present when `bigint: true` is passed into the method that generates\nthe object.\nThe timestamp indicating the last time this file was accessed expressed in\nnanoseconds since the POSIX Epoch.","summary":"Only present when `bigint: true` is passed into the method that generates the object. The timestamp indicating the last time this file was accessed expressed in nanoseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsmtimens","name":"mtimeNs","title":"`stats.mtimeNs`","scope":"module","overloadOf":null,"stability":null,"added":["v12.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"default":null,"description":"Only present when `bigint: true` is passed into the method that generates\nthe object.\nThe timestamp indicating the last time this file was modified expressed in\nnanoseconds since the POSIX Epoch.","summary":"Only present when `bigint: true` is passed into the method that generates the object. The timestamp indicating the last time this file was modified expressed in nanoseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsctimens","name":"ctimeNs","title":"`stats.ctimeNs`","scope":"module","overloadOf":null,"stability":null,"added":["v12.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"default":null,"description":"Only present when `bigint: true` is passed into the method that generates\nthe object.\nThe timestamp indicating the last time the file status was changed expressed\nin nanoseconds since the POSIX Epoch.","summary":"Only present when `bigint: true` is passed into the method that generates the object. The timestamp indicating the last time the file status was changed expressed in nanoseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsbirthtimens","name":"birthtimeNs","title":"`stats.birthtimeNs`","scope":"module","overloadOf":null,"stability":null,"added":["v12.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"default":null,"description":"Only present when `bigint: true` is passed into the method that generates\nthe object.\nThe timestamp indicating the creation time of this file expressed in\nnanoseconds since the POSIX Epoch.","summary":"Only present when `bigint: true` is passed into the method that generates the object. The timestamp indicating the creation time of this file expressed in nanoseconds since the POSIX Epoch.","examples":[],"children":[]},{"kind":"property","id":"statsatime","name":"atime","title":"`stats.atime`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The timestamp indicating the last time this file was accessed.","summary":"The timestamp indicating the last time this file was accessed.","examples":[],"children":[]},{"kind":"property","id":"statsmtime","name":"mtime","title":"`stats.mtime`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The timestamp indicating the last time this file was modified.","summary":"The timestamp indicating the last time this file was modified.","examples":[],"children":[]},{"kind":"property","id":"statsctime","name":"ctime","title":"`stats.ctime`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The timestamp indicating the last time the file status was changed.","summary":"The timestamp indicating the last time the file status was changed.","examples":[],"children":[]},{"kind":"property","id":"statsbirthtime","name":"birthtime","title":"`stats.birthtime`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Date","links":[{"name":"Date","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date","start":0,"end":4}]},"default":null,"description":"The timestamp indicating the creation time of this file.","summary":"The timestamp indicating the creation time of this file.","examples":[],"children":[]},{"kind":"section","id":"stat-time-values","name":"Stat time values","title":"Stat time values","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `atimeMs`, `mtimeMs`, `ctimeMs`, `birthtimeMs` properties are\nnumeric values that hold the corresponding times in milliseconds. Their\nprecision is platform specific. When `bigint: true` is passed into the\nmethod that generates the object, the properties will be [bigints](https://tc39.github.io/proposal-bigint),\notherwise they will be [numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#number_type).\n\nThe `atimeNs`, `mtimeNs`, `ctimeNs`, `birthtimeNs` properties are\n[bigints](https://tc39.github.io/proposal-bigint) that hold the corresponding times in nanoseconds. They are\nonly present when `bigint: true` is passed into the method that generates\nthe object. Their precision is platform specific.\n\n`atime`, `mtime`, `ctime`, and `birthtime` are\n[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object alternate representations of the various times. The\n`Date` and number values are not connected. Assigning a new number value, or\nmutating the `Date` value, will not be reflected in the corresponding alternate\nrepresentation.\n\nThe times in the stat object have the following semantics:\n\n* `atime` \"Access Time\": Time when file data last accessed. Changed\n  by the [`mknod(2)`](http://man7.org/linux/man-pages/man2/mknod.2.html), [`utimes(2)`](http://man7.org/linux/man-pages/man2/utimes.2.html), and [`read(2)`](http://man7.org/linux/man-pages/man2/read.2.html) system calls.\n* `mtime` \"Modified Time\": Time when file data last modified.\n  Changed by the [`mknod(2)`](http://man7.org/linux/man-pages/man2/mknod.2.html), [`utimes(2)`](http://man7.org/linux/man-pages/man2/utimes.2.html), and [`write(2)`](http://man7.org/linux/man-pages/man2/write.2.html) system calls.\n* `ctime` \"Change Time\": Time when file status was last changed\n  (inode data modification). Changed by the [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html), [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html),\n  [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html), [`mknod(2)`](http://man7.org/linux/man-pages/man2/mknod.2.html), [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html), [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html), [`utimes(2)`](http://man7.org/linux/man-pages/man2/utimes.2.html),\n  [`read(2)`](http://man7.org/linux/man-pages/man2/read.2.html), and [`write(2)`](http://man7.org/linux/man-pages/man2/write.2.html) system calls.\n* `birthtime` \"Birth Time\": Time of file creation. Set once when the\n  file is created. On file systems where birthtime is not available,\n  this field may instead hold either the `ctime` or\n  `1970-01-01T00:00Z` (ie, Unix epoch timestamp `0`). This value may be greater\n  than `atime` or `mtime` in this case. On Darwin and other FreeBSD variants,\n  also set if the `atime` is explicitly set to an earlier value than the current\n  `birthtime` using the [`utimes(2)`](http://man7.org/linux/man-pages/man2/utimes.2.html) system call.\n\nPrior to Node.js 0.12, the `ctime` held the `birthtime` on Windows systems. As\nof 0.12, `ctime` is not \"creation time\", and on Unix systems, it never was.","summary":"The `atimeMs`, `mtimeMs`, `ctimeMs`, `birthtimeMs` properties are numeric values that hold the corresponding times in milliseconds. Their precision is platform specific. When `bigint: true` is passed into the method that generates the object, the properties will be bigints, otherwise they will be numbers.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsstatfs","name":"StatFs","title":"Class: `fs.StatFs`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"Provides information about a mounted file system.\n\nObjects returned from [`fs.statfs()`](#fsstatfspath-options-callback) and its synchronous counterpart are of\nthis type. If `bigint` in the `options` passed to those methods is `true`, the\nnumeric values will be `bigint` instead of `number`.\n\n```console\nStatFs {\n  type: 1397114950,\n  bsize: 4096,\n  frsize: 4096,\n  blocks: 121938943,\n  bfree: 61058895,\n  bavail: 61058895,\n  files: 999,\n  ffree: 1000000\n}\n```\n\n`bigint` version:\n\n```console\nStatFs {\n  type: 1397114950n,\n  bsize: 4096n,\n  frsize: 4096n,\n  blocks: 121938943n,\n  bfree: 61058895n,\n  bavail: 61058895n,\n  files: 999n,\n  ffree: 1000000n\n}\n```","summary":"Provides information about a mounted file system.","examples":[{"language":"console","displayName":null,"code":"StatFs {\n  type: 1397114950,\n  bsize: 4096,\n  frsize: 4096,\n  blocks: 121938943,\n  bfree: 61058895,\n  bavail: 61058895,\n  files: 999,\n  ffree: 1000000\n}"},{"language":"console","displayName":null,"code":"StatFs {\n  type: 1397114950n,\n  bsize: 4096n,\n  frsize: 4096n,\n  blocks: 121938943n,\n  bfree: 61058895n,\n  bavail: 61058895n,\n  files: 999n,\n  ffree: 1000000n\n}"}],"children":[{"kind":"property","id":"statfsbavail","name":"bavail","title":"`statfs.bavail`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Free blocks available to unprivileged users. Multiply by [`statfs.bsize`](#statfsbsize)\nto get the number of available bytes.\n\n```mjs\nimport { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst availableBytes = stats.bsize * stats.bavail;\nconsole.log(`Available space: ${availableBytes} bytes`);\n```\n\n```cjs\nconst { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const availableBytes = stats.bsize * stats.bavail;\n  console.log(`Available space: ${availableBytes} bytes`);\n})();\n```","summary":"Free blocks available to unprivileged users. Multiply by `statfs.bsize` to get the number of available bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst availableBytes = stats.bsize * stats.bavail;\nconsole.log(`Available space: ${availableBytes} bytes`);"},{"language":"cjs","displayName":null,"code":"const { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const availableBytes = stats.bsize * stats.bavail;\n  console.log(`Available space: ${availableBytes} bytes`);\n})();"}],"children":[]},{"kind":"property","id":"statfsbfree","name":"bfree","title":"`statfs.bfree`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Free blocks in file system. Multiply by [`statfs.bsize`](#statfsbsize) to get the number\nof free bytes.\n\n```mjs\nimport { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst freeBytes = stats.bsize * stats.bfree;\nconsole.log(`Free space: ${freeBytes} bytes`);\n```\n\n```cjs\nconst { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const freeBytes = stats.bsize * stats.bfree;\n  console.log(`Free space: ${freeBytes} bytes`);\n})();\n```","summary":"Free blocks in file system. Multiply by `statfs.bsize` to get the number of free bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst freeBytes = stats.bsize * stats.bfree;\nconsole.log(`Free space: ${freeBytes} bytes`);"},{"language":"cjs","displayName":null,"code":"const { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const freeBytes = stats.bsize * stats.bfree;\n  console.log(`Free space: ${freeBytes} bytes`);\n})();"}],"children":[]},{"kind":"property","id":"statfsblocks","name":"blocks","title":"`statfs.blocks`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Total data blocks in file system. Multiply by [`statfs.bsize`](#statfsbsize) to get the\ntotal size in bytes.\n\n```mjs\nimport { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst totalBytes = stats.bsize * stats.blocks;\nconsole.log(`Total space: ${totalBytes} bytes`);\n```\n\n```cjs\nconst { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const totalBytes = stats.bsize * stats.blocks;\n  console.log(`Total space: ${totalBytes} bytes`);\n})();\n```","summary":"Total data blocks in file system. Multiply by `statfs.bsize` to get the total size in bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { statfs } from 'node:fs/promises';\n\nconst stats = await statfs('/');\nconst totalBytes = stats.bsize * stats.blocks;\nconsole.log(`Total space: ${totalBytes} bytes`);"},{"language":"cjs","displayName":null,"code":"const { statfs } = require('node:fs/promises');\n\n(async () => {\n  const stats = await statfs('/');\n  const totalBytes = stats.bsize * stats.blocks;\n  console.log(`Total space: ${totalBytes} bytes`);\n})();"}],"children":[]},{"kind":"property","id":"statfsbsize","name":"bsize","title":"`statfs.bsize`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Optimal transfer block size in bytes.","summary":"Optimal transfer block size in bytes.","examples":[],"children":[]},{"kind":"property","id":"statfsfrsize","name":"frsize","title":"`statfs.frsize`","scope":"module","overloadOf":null,"stability":null,"added":["v26.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Fundamental file system block size.","summary":"Fundamental file system block size.","examples":[],"children":[]},{"kind":"property","id":"statfsffree","name":"ffree","title":"`statfs.ffree`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Free file nodes in file system.","summary":"Free file nodes in file system.","examples":[],"children":[]},{"kind":"property","id":"statfsfiles","name":"files","title":"`statfs.files`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Total file nodes in file system.","summary":"Total file nodes in file system.","examples":[],"children":[]},{"kind":"property","id":"statfstype","name":"type","title":"`statfs.type`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | bigint","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":9,"end":15}]},"default":null,"description":"Type of file system. A platform-specific numeric identifier for the type of\nfile system. This value corresponds to the `f_type` field returned by\n`statfs(2)` on POSIX systems (for example, `0xEF53` for ext4 on Linux). Its\nmeaning is OS-dependent and is not guaranteed to be consistent across\nplatforms.","summary":"Type of file system. A platform-specific numeric identifier for the type of file system. This value corresponds to the `f_type` field returned by `statfs(2)` on POSIX systems (for example, `0xEF53` for ext4 on Linux). Its meaning is OS-dependent and is not guaranteed to be consistent across platforms.","examples":[],"children":[]}]},{"kind":"class","id":"class-fsutf8stream","name":"Utf8Stream","title":"Class: `fs.Utf8Stream`","scope":"module","overloadOf":null,"stability":{"index":"1","description":"Experimental"},"added":["v24.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"An optimized UTF-8 stream writer that allows for flushing all the internal\nbuffering on demand. It handles `EAGAIN` errors correctly, allowing for\ncustomization, for example, by dropping content if the disk is busy.","summary":"An optimized UTF-8 stream writer that allows for flushing all the internal buffering on demand. It handles `EAGAIN` errors correctly, allowing for customization, for example, by dropping content if the disk is busy.","examples":[],"children":[{"kind":"event","id":"event-close-3","name":"close","title":"Event: `'close'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'close'` event is emitted when the stream is fully closed.","summary":"The `'close'` event is emitted when the stream is fully closed.","examples":[],"children":[]},{"kind":"event","id":"event-drain","name":"drain","title":"Event: `'drain'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'drain'` event is emitted when the internal buffer has drained sufficiently\nto allow continued writing.","summary":"The `'drain'` event is emitted when the internal buffer has drained sufficiently to allow continued writing.","examples":[],"children":[]},{"kind":"event","id":"event-drop","name":"drop","title":"Event: `'drop'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'drop'` event is emitted when the maximal length is reached and that data\nwill not be written. The data that was dropped is passed as the first argument\nto the event handler.","summary":"The `'drop'` event is emitted when the maximal length is reached and that data will not be written. The data that was dropped is passed as the first argument to the event handler.","examples":[],"children":[]},{"kind":"event","id":"event-error-1","name":"error","title":"Event: `'error'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'error'` event is emitted when an error occurs.","summary":"The `'error'` event is emitted when an error occurs.","examples":[],"children":[]},{"kind":"event","id":"event-finish","name":"finish","title":"Event: `'finish'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'finish'` event is emitted when the stream has been ended and all data has\nbeen flushed to the underlying file.","summary":"The `'finish'` event is emitted when the stream has been ended and all data has been flushed to the underlying file.","examples":[],"children":[]},{"kind":"event","id":"event-ready-1","name":"ready","title":"Event: `'ready'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'ready'` event is emitted when the stream is ready to accept writes.","summary":"The `'ready'` event is emitted when the stream is ready to accept writes.","examples":[],"children":[]},{"kind":"event","id":"event-write","name":"write","title":"Event: `'write'`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"The `'write'` event is emitted when a write operation has completed. The number\nof bytes written is passed as the first argument to the event handler.","summary":"The `'write'` event is emitted when a write operation has completed. The number of bytes written is passed as the first argument to the event handler.","examples":[],"children":[]},{"kind":"constructor","id":"new-fsutf8streamoptions","name":"Utf8Stream","title":"`new fs.Utf8Stream([options])`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"append","type":null,"description":"{boolean} Appends writes to dest file instead of truncating it.\n**Default**: `true`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"contentMode","type":null,"description":"{string} Which type of data you can send to the write\nfunction, supported values are `'utf8'` or `'buffer'`. **Default**:\n`'utf8'`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"dest","type":null,"description":"{string} A path to a file to be written to (mode controlled by the\nappend option).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fd","type":null,"description":"{number} A file descriptor, something that is returned by `fs.open()`\nor `fs.openSync()`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fs","type":null,"description":"{Object} An object that has the same API as the `fs` module, useful\nfor mocking, testing, or customizing the behavior of the stream.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fsync","type":null,"description":"{boolean} Perform a `fs.fsyncSync()` every time a write is\ncompleted.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"maxLength","type":null,"description":"{number} The maximum length of the internal buffer. If a write\noperation would cause the buffer to exceed `maxLength`, the data written is\ndropped and a drop event is emitted with the dropped data","default":null,"optional":false,"rest":false,"properties":[]},{"name":"maxWrite","type":null,"description":"{number} The maximum number of bytes that can be written;\n**Default**: `16384`","default":null,"optional":false,"rest":false,"properties":[]},{"name":"minLength","type":null,"description":"{number} The minimum length of the internal buffer that is\nrequired to be full before flushing.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mkdir","type":null,"description":"{boolean} Ensure directory for `dest` file exists when true.\n**Default**: `false`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"mode","type":null,"description":"{number | string} Specify the creating file mode (see `fs.open()`).","default":null,"optional":false,"rest":false,"properties":[]},{"name":"periodicFlush","type":null,"description":"{number} Calls flush every `periodicFlush` milliseconds.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"retryEAGAIN","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"A function that will be called when `write()`,\n`writeSync()`, or `flushSync()` encounters an `EAGAIN` or `EBUSY` error.\nIf the return value is `true` the operation will be retried, otherwise it\nwill bubble the error. The `err` is the error that caused this function to\nbe called, `writeBufferLen` is the length of the buffer that was written,\nand `remainingBufferLen` is the length of the remaining buffer that the\nstream did not try to write.","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"An error or `null`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"writeBufferLen","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"remainingBufferLen","type":null,"description":"{number}","default":null,"optional":false,"rest":false,"properties":[]}]},{"name":"sync","type":null,"description":"{boolean} Perform writes synchronously.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"fs.Utf8Stream","links":[{"name":"fs.Utf8Stream","href":"fs.html#class-fsutf8stream","start":0,"end":13}]},"description":""}},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streamappend","name":"append","title":"`utf8Stream.append`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether the stream is appending to the file or truncating it.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streamcontentmode","name":"contentMode","title":"`utf8Stream.contentMode`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The type of data that can be written to the stream. Supported\nvalues are `'utf8'` or `'buffer'`. **Default**: `'utf8'`.","summary":"","examples":[],"children":[]},{"kind":"method","id":"utf8streamdestroy","name":"destroy","title":"`utf8Stream.destroy()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Close the stream immediately, without flushing the internal buffer.","summary":"Close the stream immediately, without flushing the internal buffer.","examples":[],"children":[]},{"kind":"method","id":"utf8streamend","name":"end","title":"`utf8Stream.end()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Close the stream gracefully, flushing the internal buffer before closing.","summary":"Close the stream gracefully, flushing the internal buffer before closing.","examples":[],"children":[]},{"kind":"property","id":"utf8streamfd","name":"fd","title":"`utf8Stream.fd`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The file descriptor that is being written to.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streamfile","name":"file","title":"`utf8Stream.file`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The file that is being written to.","summary":"","examples":[],"children":[]},{"kind":"method","id":"utf8streamflushcallback","name":"flush","title":"`utf8Stream.flush(callback)`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"err","type":{"text":"Error | null","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5},{"name":"null","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#null_type","start":8,"end":12}]},"description":"An error if the flush failed, otherwise `null`.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Writes the current buffer to the file if a write was not in progress. Do\nnothing if `minLength` is zero or if it is already writing.","summary":"Writes the current buffer to the file if a write was not in progress. Do nothing if `minLength` is zero or if it is already writing.","examples":[],"children":[]},{"kind":"method","id":"utf8streamflushsync","name":"flushSync","title":"`utf8Stream.flushSync()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Flushes the buffered data synchronously. This is a costly operation.","summary":"Flushes the buffered data synchronously. This is a costly operation.","examples":[],"children":[]},{"kind":"property","id":"utf8streamfsync","name":"fsync","title":"`utf8Stream.fsync`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether the stream is performing a `fs.fsyncSync()` after every\nwrite operation.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streammaxlength","name":"maxLength","title":"`utf8Stream.maxLength`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The maximum length of the internal buffer. If a write\noperation would cause the buffer to exceed `maxLength`, the data written is\ndropped and a drop event is emitted with the dropped data.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streamminlength","name":"minLength","title":"`utf8Stream.minLength`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The minimum length of the internal buffer that is required to be\nfull before flushing.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streammkdir","name":"mkdir","title":"`utf8Stream.mkdir`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether the stream should ensure that the directory for the\n`dest` file exists. If `true`, it will create the directory if it does not\nexist. **Default**: `false`.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streammode","name":"mode","title":"`utf8Stream.mode`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number | string","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":9,"end":15}]},"default":null,"description":"The mode of the file that is being written to.","summary":"","examples":[],"children":[]},{"kind":"property","id":"utf8streamperiodicflush","name":"periodicFlush","title":"`utf8Stream.periodicFlush`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The number of milliseconds between flushes. If set to `0`, no\nperiodic flushes will be performed.","summary":"","examples":[],"children":[]},{"kind":"method","id":"utf8streamreopenfile","name":"reopen","title":"`utf8Stream.reopen(file)`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"file","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"* `file`: {string | Buffer | URL} A path to a file to be written to (mode\n  controlled by the append option).\n\nReopen the file in place, useful for log rotation.","summary":"Reopen the file in place, useful for log rotation.","examples":[],"children":[]},{"kind":"property","id":"utf8streamsync","name":"sync","title":"`utf8Stream.sync`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether the stream is writing synchronously or asynchronously.","summary":"","examples":[],"children":[]},{"kind":"method","id":"utf8streamwritedata","name":"write","title":"`utf8Stream.write(data)`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"string | Buffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15}]},"description":"The data to write.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"When the `options.contentMode` is set to `'utf8'` when the stream is created,\nthe `data` argument must be a string. If the `contentMode` is set to `'buffer'`,\nthe `data` argument must be a {Buffer}.","summary":"When the `options.contentMode` is set to `'utf8'` when the stream is created, the `data` argument must be a string. If the `contentMode` is set to `'buffer'`, the `data` argument must be a {Buffer}.","examples":[],"children":[]},{"kind":"property","id":"utf8streamwriting","name":"writing","title":"`utf8Stream.writing`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"Whether the stream is currently writing data to the file.","summary":"","examples":[],"children":[]},{"kind":"method","id":"utf8streamsymboldispose","name":"[Symbol.dispose]","title":"`utf8Stream[Symbol.dispose]()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Calls `utf8Stream.destroy()`.\n\nThis method enables the stream to be used with [`using`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using), which\nwill automatically destroy the stream when the scope exits. For more\ninformation, see the [MDN documentation on `using` statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using).","summary":"Calls `utf8Stream.destroy()`.","examples":[],"children":[]}]},{"kind":"class","id":"class-fswritestream","name":"WriteStream","title":"Class: `fs.WriteStream`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":{"text":"stream.Writable","links":[{"name":"stream.Writable","href":"stream.html#class-streamwritable","start":0,"end":15}]},"description":"Instances of {fs.WriteStream} cannot be constructed directly. They are created and\nreturned using the [`fs.createWriteStream()`](#fscreatewritestreampath-options) function.","summary":"Instances of {fs.WriteStream} cannot be constructed directly. They are created and returned using the `fs.createWriteStream()` function.","examples":[],"children":[{"kind":"event","id":"event-close-4","name":"close","title":"Event: `'close'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"Emitted when the {fs.WriteStream}'s underlying file descriptor has been closed.","summary":"Emitted when the {fs.WriteStream}'s underlying file descriptor has been closed.","examples":[],"children":[]},{"kind":"event","id":"event-open-1","name":"open","title":"Event: `'open'`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[{"name":"fd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Integer file descriptor used by the {fs.WriteStream}.","default":null,"optional":false,"rest":false,"properties":[]}],"description":"Emitted when the {fs.WriteStream}'s file is opened.","summary":"Emitted when the {fs.WriteStream}'s file is opened.","examples":[],"children":[]},{"kind":"event","id":"event-ready-2","name":"ready","title":"Event: `'ready'`","scope":"module","overloadOf":null,"stability":null,"added":["v9.11.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"parameters":[],"description":"Emitted when the {fs.WriteStream} is ready to be used.\n\nFires immediately after `'open'`.","summary":"Emitted when the {fs.WriteStream} is ready to be used.","examples":[],"children":[]},{"kind":"property","id":"writestreambyteswritten","name":"bytesWritten","title":"`writeStream.bytesWritten`","scope":"module","overloadOf":null,"stability":null,"added":["v0.4.7"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"The number of bytes written so far. Does not include data that is still queued\nfor writing.","summary":"The number of bytes written so far. Does not include data that is still queued for writing.","examples":[],"children":[]},{"kind":"method","id":"writestreamclosecallback","name":"close","title":"`writeStream.close([callback])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.4"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"callback","type":{"text":"Function","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"err","type":{"text":"Error","links":[{"name":"Error","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error","start":0,"end":5}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Closes `writeStream`. Optionally accepts a\ncallback that will be executed once the `writeStream`\nis closed.","summary":"Closes `writeStream`. Optionally accepts a callback that will be executed once the `writeStream` is closed.","examples":[],"children":[]},{"kind":"property","id":"writestreampath","name":"path","title":"`writeStream.path`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.93"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"The path to the file the stream is writing to as specified in the first\nargument to [`fs.createWriteStream()`](#fscreatewritestreampath-options). If `path` is passed as a string, then\n`writeStream.path` will be a string. If `path` is passed as a {Buffer}, then\n`writeStream.path` will be a {Buffer}.","summary":"The path to the file the stream is writing to as specified in the first argument to `fs.createWriteStream()`. If `path` is passed as a string, then `writeStream.path` will be a string. If `path` is passed as a {Buffer}, then `writeStream.path` will be a {Buffer}.","examples":[],"children":[]},{"kind":"property","id":"writestreampending","name":"pending","title":"`writeStream.pending`","scope":"module","overloadOf":null,"stability":null,"added":["v11.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"default":null,"description":"This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.","summary":"This property is `true` if the underlying file has not been opened yet, i.e. before the `'ready'` event is emitted.","examples":[],"children":[]}]},{"kind":"property","id":"fsconstants","name":"constants","title":"`fs.constants`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"Returns an object containing commonly used constants for file system\noperations.","summary":"Returns an object containing commonly used constants for file system operations.","examples":[],"children":[{"kind":"section","id":"fs-constants","name":"FS constants","title":"FS constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are exported by `fs.constants` and `fsPromises.constants`.\n\nNot every constant will be available on every operating system;\nthis is especially important for Windows, where many of the POSIX specific\ndefinitions are not available.\nFor portable applications it is recommended to check for their presence\nbefore use.\n\nTo use more than one constant, use the bitwise OR `|` operator.\n\nExample:\n\n```mjs\nimport { open, constants } from 'node:fs';\n\nconst {\n  O_RDWR,\n  O_CREAT,\n  O_EXCL,\n} = constants;\n\nopen('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {\n  // ...\n});\n```","summary":"The following constants are exported by `fs.constants` and `fsPromises.constants`.","examples":[{"language":"mjs","displayName":null,"code":"import { open, constants } from 'node:fs';\n\nconst {\n  O_RDWR,\n  O_CREAT,\n  O_EXCL,\n} = constants;\n\nopen('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {\n  // ...\n});"}],"children":[{"kind":"section","id":"file-access-constants","name":"File access constants","title":"File access constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are meant for use as the `mode` parameter passed to\n[`fsPromises.access()`](#fspromisesaccesspath-mode), [`fs.access()`](#fsaccesspath-mode-callback), and [`fs.accessSync()`](#fsaccesssyncpath-mode).\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>F_OK</code></td>\n    <td>Flag indicating that the file is visible to the calling process.\n     This is useful for determining if a file exists, but says nothing\n     about <code>rwx</code> permissions. Default if no mode is specified.</td>\n  </tr>\n  <tr>\n    <td><code>R_OK</code></td>\n    <td>Flag indicating that the file can be read by the calling process.</td>\n  </tr>\n  <tr>\n    <td><code>W_OK</code></td>\n    <td>Flag indicating that the file can be written by the calling\n    process.</td>\n  </tr>\n  <tr>\n    <td><code>X_OK</code></td>\n    <td>Flag indicating that the file can be executed by the calling\n    process. This has no effect on Windows\n    (will behave like <code>fs.constants.F_OK</code>).</td>\n  </tr>\n</table>\n\nThe definitions are also available on Windows.","summary":"The following constants are meant for use as the `mode` parameter passed to `fsPromises.access()`, `fs.access()`, and `fs.accessSync()`.","examples":[],"children":[]},{"kind":"section","id":"file-copy-constants","name":"File copy constants","title":"File copy constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are meant for use with [`fs.copyFile()`](#fscopyfilesrc-dest-mode-callback).\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>COPYFILE_EXCL</code></td>\n    <td>If present, the copy operation will fail with an error if the\n    destination path already exists.</td>\n  </tr>\n  <tr>\n    <td><code>COPYFILE_FICLONE</code></td>\n    <td>If present, the copy operation will attempt to create a\n    copy-on-write reflink. If the underlying platform does not support\n    copy-on-write, then a fallback copy mechanism is used.</td>\n  </tr>\n  <tr>\n    <td><code>COPYFILE_FICLONE_FORCE</code></td>\n    <td>If present, the copy operation will attempt to create a\n    copy-on-write reflink. If the underlying platform does not support\n    copy-on-write, then the operation will fail with an error.</td>\n  </tr>\n</table>\n\nThe definitions are also available on Windows.","summary":"The following constants are meant for use with `fs.copyFile()`.","examples":[],"children":[]},{"kind":"section","id":"file-open-constants","name":"File open constants","title":"File open constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are meant for use with `fs.open()`.\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>O_RDONLY</code></td>\n    <td>Flag indicating to open a file for read-only access.</td>\n  </tr>\n  <tr>\n    <td><code>O_WRONLY</code></td>\n    <td>Flag indicating to open a file for write-only access.</td>\n  </tr>\n  <tr>\n    <td><code>O_RDWR</code></td>\n    <td>Flag indicating to open a file for read-write access.</td>\n  </tr>\n  <tr>\n    <td><code>O_CREAT</code></td>\n    <td>Flag indicating to create the file if it does not already exist.</td>\n  </tr>\n  <tr>\n    <td><code>O_EXCL</code></td>\n    <td>Flag indicating that opening a file should fail if the\n    <code>O_CREAT</code> flag is set and the file already exists.</td>\n  </tr>\n  <tr>\n    <td><code>O_NOCTTY</code></td>\n    <td>Flag indicating that if path identifies a terminal device, opening the\n    path shall not cause that terminal to become the controlling terminal for\n    the process (if the process does not already have one).</td>\n  </tr>\n  <tr>\n    <td><code>O_TRUNC</code></td>\n    <td>Flag indicating that if the file exists and is a regular file, and the\n    file is opened successfully for write access, its length shall be truncated\n    to zero.</td>\n  </tr>\n  <tr>\n    <td><code>O_APPEND</code></td>\n    <td>Flag indicating that data will be appended to the end of the file.</td>\n  </tr>\n  <tr>\n    <td><code>O_DIRECTORY</code></td>\n    <td>Flag indicating that the open should fail if the path is not a\n    directory.</td>\n  </tr>\n  <tr>\n  <td><code>O_NOATIME</code></td>\n    <td>Flag indicating reading accesses to the file system will no longer\n    result in an update to the <code>atime</code> information associated with\n    the file. This flag is available on Linux operating systems only.</td>\n  </tr>\n  <tr>\n    <td><code>O_NOFOLLOW</code></td>\n    <td>Flag indicating that the open should fail if the path is a symbolic\n    link.</td>\n  </tr>\n  <tr>\n    <td><code>O_SYNC</code></td>\n    <td>Flag indicating that the file is opened for synchronized I/O with write\n    operations waiting for file integrity. On Windows, this maps to\n    <code>FILE_FLAG_WRITE_THROUGH</code>.</td>\n  </tr>\n  <tr>\n    <td><code>O_DSYNC</code></td>\n    <td>Flag indicating that the file is opened for synchronized I/O with write\n    operations waiting for data integrity. On Windows, this maps to\n    <code>FILE_FLAG_WRITE_THROUGH</code>.</td>\n  </tr>\n  <tr>\n    <td><code>O_SYMLINK</code></td>\n    <td>Flag indicating to open the symbolic link itself rather than the\n    resource it is pointing to.</td>\n  </tr>\n  <tr>\n    <td><code>O_DIRECT</code></td>\n    <td>When set, an attempt will be made to minimize caching effects of file\n    I/O. On Windows, this maps to <code>FILE_FLAG_NO_BUFFERING</code>.</td>\n  </tr>\n  <tr>\n    <td><code>O_NONBLOCK</code></td>\n    <td>Flag indicating to open the file in nonblocking mode when possible.</td>\n  </tr>\n  <tr>\n    <td><code>UV_FS_O_FILEMAP</code></td>\n    <td>When set, a memory file mapping is used to access the file. This flag\n    is available on Windows operating systems only. On other operating systems,\n    this flag is ignored.</td>\n  </tr>\n  <tr>\n    <td><code>UV_FS_O_TEMPORARY</code></td>\n    <td>When set, the file is deleted automatically when the last handle to it\n    is closed. This flag is available on Windows operating systems only. On\n    other operating systems, this flag is ignored.</td>\n  </tr>\n  <tr>\n    <td><code>UV_FS_O_SHORT_LIVED</code></td>\n    <td>Hint that the file is short-lived, so the system avoids flushing it to\n    disk when possible. This flag is available on Windows operating systems\n    only. On other operating systems, this flag is ignored.</td>\n  </tr>\n  <tr>\n    <td><code>UV_FS_O_SEQUENTIAL</code></td>\n    <td>Hint that the file is accessed sequentially from beginning to end, to\n    optimize caching. This flag is available on Windows operating systems only.\n    On other operating systems, this flag is ignored.</td>\n  </tr>\n  <tr>\n    <td><code>UV_FS_O_RANDOM</code></td>\n    <td>Hint that the file is accessed randomly, to optimize caching. This flag\n    is available on Windows operating systems only. On other operating systems,\n    this flag is ignored.</td>\n  </tr>\n</table>\n\nOn Windows, only `O_APPEND`, `O_CREAT`, `O_EXCL`, `O_RDONLY`, `O_RDWR`,\n`O_TRUNC`, `O_WRONLY`, `UV_FS_O_FILEMAP`, `UV_FS_O_TEMPORARY`,\n`UV_FS_O_SHORT_LIVED`, `UV_FS_O_SEQUENTIAL`, and `UV_FS_O_RANDOM` are\navailable.","summary":"The following constants are meant for use with `fs.open()`.","examples":[],"children":[]},{"kind":"section","id":"file-type-constants","name":"File type constants","title":"File type constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are meant for use with the {fs.Stats} object's\n`mode` property for determining a file's type.\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>S_IFMT</code></td>\n    <td>Bit mask used to extract the file type code.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFREG</code></td>\n    <td>File type constant for a regular file.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFDIR</code></td>\n    <td>File type constant for a directory.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFCHR</code></td>\n    <td>File type constant for a character-oriented device file.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFBLK</code></td>\n    <td>File type constant for a block-oriented device file.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFIFO</code></td>\n    <td>File type constant for a FIFO/pipe.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFLNK</code></td>\n    <td>File type constant for a symbolic link.</td>\n  </tr>\n  <tr>\n    <td><code>S_IFSOCK</code></td>\n    <td>File type constant for a socket.</td>\n  </tr>\n</table>\n\nOn Windows, only `S_IFCHR`, `S_IFDIR`, `S_IFLNK`, `S_IFMT`, and `S_IFREG`,\nare available.","summary":"The following constants are meant for use with the {fs.Stats} object's `mode` property for determining a file's type.","examples":[],"children":[]},{"kind":"section","id":"file-mode-constants","name":"File mode constants","title":"File mode constants","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following constants are meant for use with the {fs.Stats} object's\n`mode` property for determining the access permissions for a file.\n\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>S_IRWXU</code></td>\n    <td>File mode indicating readable, writable, and executable by owner.</td>\n  </tr>\n  <tr>\n    <td><code>S_IRUSR</code></td>\n    <td>File mode indicating readable by owner.</td>\n  </tr>\n  <tr>\n    <td><code>S_IWUSR</code></td>\n    <td>File mode indicating writable by owner.</td>\n  </tr>\n  <tr>\n    <td><code>S_IXUSR</code></td>\n    <td>File mode indicating executable by owner.</td>\n  </tr>\n  <tr>\n    <td><code>S_IRWXG</code></td>\n    <td>File mode indicating readable, writable, and executable by group.</td>\n  </tr>\n  <tr>\n    <td><code>S_IRGRP</code></td>\n    <td>File mode indicating readable by group.</td>\n  </tr>\n  <tr>\n    <td><code>S_IWGRP</code></td>\n    <td>File mode indicating writable by group.</td>\n  </tr>\n  <tr>\n    <td><code>S_IXGRP</code></td>\n    <td>File mode indicating executable by group.</td>\n  </tr>\n  <tr>\n    <td><code>S_IRWXO</code></td>\n    <td>File mode indicating readable, writable, and executable by others.</td>\n  </tr>\n  <tr>\n    <td><code>S_IROTH</code></td>\n    <td>File mode indicating readable by others.</td>\n  </tr>\n  <tr>\n    <td><code>S_IWOTH</code></td>\n    <td>File mode indicating writable by others.</td>\n  </tr>\n  <tr>\n    <td><code>S_IXOTH</code></td>\n    <td>File mode indicating executable by others.</td>\n  </tr>\n</table>\n\nOn Windows, only `S_IRUSR` and `S_IWUSR` are available.","summary":"The following constants are meant for use with the {fs.Stats} object's `mode` property for determining the access permissions for a file.","examples":[],"children":[]}]}]}]},{"kind":"section","id":"notes","name":"Notes","title":"Notes","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"section","id":"ordering-of-callback-and-promise-based-operations","name":"Ordering of callback and promise-based operations","title":"Ordering of callback and promise-based operations","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Because they are executed asynchronously by the underlying thread pool,\nthere is no guaranteed ordering when using either the callback or\npromise-based methods.\n\nFor example, the following is prone to error because the `fs.stat()`\noperation might complete before the `fs.rename()` operation:\n\n```js\nconst fs = require('node:fs');\n\nfs.rename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  console.log('renamed complete');\n});\nfs.stat('/tmp/world', (err, stats) => {\n  if (err) throw err;\n  console.log(`stats: ${JSON.stringify(stats)}`);\n});\n```\n\nIt is important to correctly order the operations by awaiting the results\nof one before invoking the other:\n\n```mjs\nimport { rename, stat } from 'node:fs/promises';\n\nconst oldPath = '/tmp/hello';\nconst newPath = '/tmp/world';\n\ntry {\n  await rename(oldPath, newPath);\n  const stats = await stat(newPath);\n  console.log(`stats: ${JSON.stringify(stats)}`);\n} catch (error) {\n  console.error('there was an error:', error.message);\n}\n```\n\n```cjs\nconst { rename, stat } = require('node:fs/promises');\n\n(async function(oldPath, newPath) {\n  try {\n    await rename(oldPath, newPath);\n    const stats = await stat(newPath);\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  } catch (error) {\n    console.error('there was an error:', error.message);\n  }\n})('/tmp/hello', '/tmp/world');\n```\n\nOr, when using the callback APIs, move the `fs.stat()` call into the callback\nof the `fs.rename()` operation:\n\n```mjs\nimport { rename, stat } from 'node:fs';\n\nrename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  stat('/tmp/world', (err, stats) => {\n    if (err) throw err;\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  });\n});\n```\n\n```cjs\nconst { rename, stat } = require('node:fs');\n\nrename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  stat('/tmp/world', (err, stats) => {\n    if (err) throw err;\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  });\n});\n```","summary":"Because they are executed asynchronously by the underlying thread pool, there is no guaranteed ordering when using either the callback or promise-based methods.","examples":[{"language":"js","displayName":null,"code":"const fs = require('node:fs');\n\nfs.rename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  console.log('renamed complete');\n});\nfs.stat('/tmp/world', (err, stats) => {\n  if (err) throw err;\n  console.log(`stats: ${JSON.stringify(stats)}`);\n});"},{"language":"mjs","displayName":null,"code":"import { rename, stat } from 'node:fs/promises';\n\nconst oldPath = '/tmp/hello';\nconst newPath = '/tmp/world';\n\ntry {\n  await rename(oldPath, newPath);\n  const stats = await stat(newPath);\n  console.log(`stats: ${JSON.stringify(stats)}`);\n} catch (error) {\n  console.error('there was an error:', error.message);\n}"},{"language":"cjs","displayName":null,"code":"const { rename, stat } = require('node:fs/promises');\n\n(async function(oldPath, newPath) {\n  try {\n    await rename(oldPath, newPath);\n    const stats = await stat(newPath);\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  } catch (error) {\n    console.error('there was an error:', error.message);\n  }\n})('/tmp/hello', '/tmp/world');"},{"language":"mjs","displayName":null,"code":"import { rename, stat } from 'node:fs';\n\nrename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  stat('/tmp/world', (err, stats) => {\n    if (err) throw err;\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  });\n});"},{"language":"cjs","displayName":null,"code":"const { rename, stat } = require('node:fs');\n\nrename('/tmp/hello', '/tmp/world', (err) => {\n  if (err) throw err;\n  stat('/tmp/world', (err, stats) => {\n    if (err) throw err;\n    console.log(`stats: ${JSON.stringify(stats)}`);\n  });\n});"}],"children":[]},{"kind":"section","id":"file-paths","name":"File paths","title":"File paths","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Most `fs` operations accept file paths that may be specified in the form of\na string, a {Buffer}, or a {URL} object using the `file:` protocol.","summary":"Most `fs` operations accept file paths that may be specified in the form of a string, a {Buffer}, or a {URL} object using the `file:` protocol.","examples":[],"children":[{"kind":"section","id":"string-paths","name":"String paths","title":"String paths","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"String paths are interpreted as UTF-8 character sequences identifying\nthe absolute or relative filename. Relative paths will be resolved relative\nto the current working directory as determined by calling `process.cwd()`.\n\nExample using an absolute path on POSIX:\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n  fd = await open('/open/some/file.txt', 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}\n```\n\nExample using a relative path on POSIX (relative to `process.cwd()`):\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n  fd = await open('file.txt', 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}\n```","summary":"String paths are interpreted as UTF-8 character sequences identifying the absolute or relative filename. Relative paths will be resolved relative to the current working directory as determined by calling `process.cwd()`.","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n  fd = await open('/open/some/file.txt', 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}"},{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nlet fd;\ntry {\n  fd = await open('file.txt', 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}"}],"children":[]},{"kind":"section","id":"file-url-paths","name":"File URL paths","title":"File URL paths","scope":"module","overloadOf":null,"stability":null,"added":["v7.6.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"For most `node:fs` module functions, the `path` or `filename` argument may be\npassed as a {URL} object using the `file:` protocol.\n\n```mjs\nimport { readFileSync } from 'node:fs';\n\nreadFileSync(new URL('file:///tmp/hello'));\n```\n\n`file:` URLs are always absolute paths.","summary":"For most `node:fs` module functions, the `path` or `filename` argument may be passed as a {URL} object using the `file:` protocol.","examples":[{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n\nreadFileSync(new URL('file:///tmp/hello'));"}],"children":[{"kind":"section","id":"platform-specific-considerations","name":"Platform-specific considerations","title":"Platform-specific considerations","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"On Windows, `file:` {URL}s with a host name convert to UNC paths, while `file:`\n{URL}s with drive letters convert to local absolute paths. `file:` {URL}s\nwith no host name and no drive letter will result in an error:\n\n```mjs\nimport { readFileSync } from 'node:fs';\n// On Windows :\n\n// - WHATWG file URLs with hostname convert to UNC path\n// file://hostname/p/a/t/h/file => \\\\hostname\\p\\a\\t\\h\\file\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n\n// - WHATWG file URLs with drive letters convert to absolute path\n// file:///C:/tmp/hello => C:\\tmp\\hello\nreadFileSync(new URL('file:///C:/tmp/hello'));\n\n// - WHATWG file URLs without hostname must have a drive letters\nreadFileSync(new URL('file:///notdriveletter/p/a/t/h/file'));\nreadFileSync(new URL('file:///c/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute\n```\n\n`file:` {URL}s with drive letters must use `:` as a separator just after\nthe drive letter. Using another separator will result in an error.\n\nOn all other platforms, `file:` {URL}s with a host name are unsupported and\nwill result in an error:\n\n```mjs\nimport { readFileSync } from 'node:fs';\n// On other platforms:\n\n// - WHATWG file URLs with hostname are unsupported\n// file://hostname/p/a/t/h/file => throw!\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: must be absolute\n\n// - WHATWG file URLs convert to absolute path\n// file:///tmp/hello => /tmp/hello\nreadFileSync(new URL('file:///tmp/hello'));\n```\n\nA `file:` {URL} having encoded slash characters will result in an error on all\nplatforms:\n\n```mjs\nimport { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/p/a/t/h/%2F'));\nreadFileSync(new URL('file:///C:/p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n\n// On POSIX\nreadFileSync(new URL('file:///p/a/t/h/%2F'));\nreadFileSync(new URL('file:///p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n/ characters */\n```\n\nOn Windows, `file:` {URL}s having encoded backslash will result in an error:\n\n```mjs\nimport { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/path/%5C'));\nreadFileSync(new URL('file:///C:/path/%5c'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n```","summary":"On Windows, `file:` {URL}s with a host name convert to UNC paths, while `file:` {URL}s with drive letters convert to local absolute paths. `file:` {URL}s with no host name and no drive letter will result in an error:","examples":[{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n// On Windows :\n\n// - WHATWG file URLs with hostname convert to UNC path\n// file://hostname/p/a/t/h/file => \\\\hostname\\p\\a\\t\\h\\file\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n\n// - WHATWG file URLs with drive letters convert to absolute path\n// file:///C:/tmp/hello => C:\\tmp\\hello\nreadFileSync(new URL('file:///C:/tmp/hello'));\n\n// - WHATWG file URLs without hostname must have a drive letters\nreadFileSync(new URL('file:///notdriveletter/p/a/t/h/file'));\nreadFileSync(new URL('file:///c/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute"},{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n// On other platforms:\n\n// - WHATWG file URLs with hostname are unsupported\n// file://hostname/p/a/t/h/file => throw!\nreadFileSync(new URL('file://hostname/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: must be absolute\n\n// - WHATWG file URLs convert to absolute path\n// file:///tmp/hello => /tmp/hello\nreadFileSync(new URL('file:///tmp/hello'));"},{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/p/a/t/h/%2F'));\nreadFileSync(new URL('file:///C:/p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n\n// On POSIX\nreadFileSync(new URL('file:///p/a/t/h/%2F'));\nreadFileSync(new URL('file:///p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n/ characters */"},{"language":"mjs","displayName":null,"code":"import { readFileSync } from 'node:fs';\n\n// On Windows\nreadFileSync(new URL('file:///C:/path/%5C'));\nreadFileSync(new URL('file:///C:/path/%5c'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */"}],"children":[]}]},{"kind":"section","id":"buffer-paths","name":"Buffer paths","title":"Buffer paths","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Paths specified using a {Buffer} are useful primarily on certain POSIX\noperating systems that treat file paths as opaque byte sequences. On such\nsystems, it is possible for a single file path to contain sub-sequences that\nuse multiple character encodings. As with string paths, {Buffer} paths may\nbe relative or absolute:\n\nExample using an absolute path on POSIX:\n\n```mjs\nimport { open } from 'node:fs/promises';\nimport { Buffer } from 'node:buffer';\n\nlet fd;\ntry {\n  fd = await open(Buffer.from('/open/some/file.txt'), 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}\n```","summary":"Paths specified using a {Buffer} are useful primarily on certain POSIX operating systems that treat file paths as opaque byte sequences. On such systems, it is possible for a single file path to contain sub-sequences that use multiple character encodings. As with string paths, {Buffer} paths may be relative or absolute:","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\nimport { Buffer } from 'node:buffer';\n\nlet fd;\ntry {\n  fd = await open(Buffer.from('/open/some/file.txt'), 'r');\n  // Do something with the file\n} finally {\n  await fd?.close();\n}"}],"children":[]},{"kind":"section","id":"per-drive-working-directories-on-windows","name":"Per-drive working directories on Windows","title":"Per-drive working directories on Windows","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"On Windows, Node.js follows the concept of per-drive working directory. This\nbehavior can be observed when using a drive path without a backslash. For\nexample `fs.readdirSync('C:\\\\')` can potentially return a different result than\n`fs.readdirSync('C:')`. For more information, see\n[this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths).","summary":"On Windows, Node.js follows the concept of per-drive working directory. This behavior can be observed when using a drive path without a backslash. For example `fs.readdirSync('C:\\\\')` can potentially return a different result than `fs.readdirSync('C:')`. For more information, see this MSDN page.","examples":[],"children":[]}]},{"kind":"section","id":"file-descriptors-1","name":"File descriptors","title":"File descriptors","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"On POSIX systems, for every process, the kernel maintains a table of currently\nopen files and resources. Each open file is assigned a simple numeric\nidentifier called a *file descriptor*. At the system-level, all file system\noperations use these file descriptors to identify and track each specific\nfile. Windows systems use a different but conceptually similar mechanism for\ntracking resources. To simplify things for users, Node.js abstracts away the\ndifferences between operating systems and assigns all open files a numeric file\ndescriptor.\n\nThe callback-based `fs.open()`, and synchronous `fs.openSync()` methods open a\nfile and allocate a new file descriptor. Once allocated, the file descriptor may\nbe used to read data from, write data to, or request information about the file.\n\nOperating systems limit the number of file descriptors that may be open\nat any given time so it is critical to close the descriptor when operations\nare completed. Failure to do so will result in a memory leak that will\neventually cause an application to crash.\n\n```mjs\nimport { open, close, fstat } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('/open/some/file.txt', 'r', (err, fd) => {\n  if (err) throw err;\n  try {\n    fstat(fd, (err, stat) => {\n      if (err) {\n        closeFd(fd);\n        throw err;\n      }\n\n      // use stat\n\n      closeFd(fd);\n    });\n  } catch (err) {\n    closeFd(fd);\n    throw err;\n  }\n});\n```\n\nThe promise-based APIs use a {FileHandle} object in place of the numeric\nfile descriptor. These objects are better managed by the system to ensure\nthat resources are not leaked. However, it is still required that they are\nclosed when operations are completed:\n\n```mjs\nimport { open } from 'node:fs/promises';\n\nlet file;\ntry {\n  file = await open('/open/some/file.txt', 'r');\n  const stat = await file.stat();\n  // use stat\n} finally {\n  await file.close();\n}\n```","summary":"On POSIX systems, for every process, the kernel maintains a table of currently open files and resources. Each open file is assigned a simple numeric identifier called a _file descriptor_. At the system-level, all file system operations use these file descriptors to identify and track each specific file. Windows systems use a different but conceptually similar mechanism for tracking resources. To simplify things for users, Node.js abstracts away the differences between operating systems and assigns all open files a numeric file descriptor.","examples":[{"language":"mjs","displayName":null,"code":"import { open, close, fstat } from 'node:fs';\n\nfunction closeFd(fd) {\n  close(fd, (err) => {\n    if (err) throw err;\n  });\n}\n\nopen('/open/some/file.txt', 'r', (err, fd) => {\n  if (err) throw err;\n  try {\n    fstat(fd, (err, stat) => {\n      if (err) {\n        closeFd(fd);\n        throw err;\n      }\n\n      // use stat\n\n      closeFd(fd);\n    });\n  } catch (err) {\n    closeFd(fd);\n    throw err;\n  }\n});"},{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\n\nlet file;\ntry {\n  file = await open('/open/some/file.txt', 'r');\n  const stat = await file.stat();\n  // use stat\n} finally {\n  await file.close();\n}"}],"children":[]},{"kind":"section","id":"threadpool-usage","name":"Threadpool usage","title":"Threadpool usage","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"All callback and promise-based file system APIs (with the exception of\n`fs.FSWatcher()`) use libuv's threadpool. This can have surprising and negative\nperformance implications for some applications. See the\n[`UV_THREADPOOL_SIZE`](cli.html#uv_threadpool_sizesize) documentation for more information.","summary":"All callback and promise-based file system APIs (with the exception of `fs.FSWatcher()`) use libuv's threadpool. This can have surprising and negative performance implications for some applications. See the `UV_THREADPOOL_SIZE` documentation for more information.","examples":[],"children":[]},{"kind":"section","id":"file-system-flags","name":"File system flags","title":"File system flags","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following flags are available wherever the `flag` option takes a\nstring.\n\n* `'a'`: Open file for appending.\n  The file is created if it does not exist.\n\n* `'ax'`: Like `'a'` but fails if the path exists.\n\n* `'a+'`: Open file for reading and appending.\n  The file is created if it does not exist.\n\n* `'ax+'`: Like `'a+'` but fails if the path exists.\n\n* `'as'`: Open file for appending in synchronous mode.\n  The file is created if it does not exist.\n\n* `'as+'`: Open file for reading and appending in synchronous mode.\n  The file is created if it does not exist.\n\n* `'r'`: Open file for reading.\n  An exception occurs if the file does not exist.\n\n* `'rs'`: Open file for reading in synchronous mode.\n  An exception occurs if the file does not exist.\n\n* `'r+'`: Open file for reading and writing.\n  An exception occurs if the file does not exist.\n\n* `'rs+'`: Open file for reading and writing in synchronous mode. Instructs\n  the operating system to bypass the local file system cache.\n\n  This is primarily useful for opening files on NFS mounts as it allows\n  skipping the potentially stale local cache. It has a very real impact on\n  I/O performance so using this flag is not recommended unless it is needed.\n\n  This doesn't turn `fs.open()` or `fsPromises.open()` into a synchronous\n  blocking call. If synchronous operation is desired, something like\n  `fs.openSync()` should be used.\n\n* `'w'`: Open file for writing.\n  The file is created (if it does not exist) or truncated (if it exists).\n\n* `'wx'`: Like `'w'` but fails if the path exists.\n\n* `'w+'`: Open file for reading and writing.\n  The file is created (if it does not exist) or truncated (if it exists).\n\n* `'wx+'`: Like `'w+'` but fails if the path exists.\n\n`flag` can also be a number as documented by [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html); commonly used constants\nare available from `fs.constants`. On Windows, flags are translated to\ntheir equivalent ones where applicable, e.g. `O_WRONLY` to `FILE_GENERIC_WRITE`,\nor `O_EXCL|O_CREAT` to `CREATE_NEW`, as accepted by `CreateFileW`.\n\nThe exclusive flag `'x'` (`O_EXCL` flag in [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html)) causes the operation to\nreturn an error if the path already exists. On POSIX, if the path is a symbolic\nlink, using `O_EXCL` returns an error even if the link is to a path that does\nnot exist. The exclusive flag might not work with network file systems.\n\nOn Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.\n\nModifying a file rather than replacing it may require the `flag` option to be\nset to `'r+'` rather than the default `'w'`.\n\nThe behavior of some flags are platform-specific. As such, opening a directory\non macOS and Linux with the `'a+'` flag, as in the example below, will return an\nerror. In contrast, on Windows and FreeBSD, a file descriptor or a `FileHandle`\nwill be returned.\n\n```js\n// macOS and Linux\nfs.open('<directory>', 'a+', (err, fd) => {\n  // => [Error: EISDIR: illegal operation on a directory, open <directory>]\n});\n\n// Windows and FreeBSD\nfs.open('<directory>', 'a+', (err, fd) => {\n  // => null, <fd>\n});\n```\n\nOn Windows, opening an existing hidden file using the `'w'` flag (either\nthrough `fs.open()`, `fs.writeFile()`, or `fsPromises.open()`) will fail with\n`EPERM`. Existing hidden files can be opened for writing with the `'r+'` flag.\n\nA call to `fs.ftruncate()` or `filehandle.truncate()` can be used to reset\nthe file contents.","summary":"The following flags are available wherever the `flag` option takes a string.","examples":[{"language":"js","displayName":null,"code":"// macOS and Linux\nfs.open('<directory>', 'a+', (err, fd) => {\n  // => [Error: EISDIR: illegal operation on a directory, open <directory>]\n});\n\n// Windows and FreeBSD\nfs.open('<directory>', 'a+', (err, fd) => {\n  // => null, <fd>\n});"}],"children":[]}]}]}