diff --git a/doc/api/fs.md b/doc/api/fs.md index 350555f2f8ad99..80d5548cc57d3a 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -696,11 +696,18 @@ close the `FileHandle` automatically. User code must still call the * `options` {Object|string} * `encoding` {string|null} **Default:** `null` * `signal` {AbortSignal} allows aborting an in-progress readFile + * `buffer` {Buffer|TypedArray|DataView} A buffer to read into. + * `getBuffer` {Function} A synchronous function called with the file size and + returning the buffer to read into. * Returns: {Promise} Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the data will be a string. @@ -709,6 +716,11 @@ Asynchronously reads the entire contents of a file. If `options` is a string, then it specifies the `encoding`. +The `buffer` and `getBuffer` options cannot be used together. If one of them is +provided and no encoding is specified, the returned {Buffer} is a view over the +supplied buffer containing only the bytes read. If the supplied buffer is too +small to contain the entire file, the operation will fail. + The {FileHandle} has to support reading. If one or more `filehandle.read()` calls are made on a file handle and then a @@ -1765,6 +1777,9 @@ try {