diff --git a/doc/api/fs.md b/doc/api/fs.md index 17d15c51c5454d..07b52b17ed203c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -392,7 +392,7 @@ added: * `offset` {integer} The location in the buffer at which to start filling. **Default:** `0` * `length` {integer} The number of bytes to read. **Default:** - `buffer.byteLength` + `buffer.byteLength - offset` * `position` {integer} The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an integer, the current @@ -3060,7 +3060,7 @@ changes: * `options` {Object} * `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)` * `offset` {integer} **Default:** `0` - * `length` {integer} **Default:** `buffer.byteLength` + * `length` {integer} **Default:** `buffer.byteLength - offset` * `position` {integer|bigint} **Default:** `null` * `callback` {Function} * `err` {Error} diff --git a/lib/fs.js b/lib/fs.js index 75349f5b1f6f0e..9fb7473d0fea7a 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -621,7 +621,7 @@ function read(fd, buffer, offset, length, position, callback) { ({ buffer = Buffer.alloc(16384), offset = 0, - length = buffer.byteLength, + length = buffer.byteLength - offset, position } = options); }