diff options
author | wbt <wbt@users.noreply.github.com> | 2022-02-19 20:22:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-19 20:22:46 +0300 |
commit | 246227f4bca1afe06af5a766fc41e251b7d3700a (patch) | |
tree | d2e475f18c0bf3426dba0781e602b36d15d59caf /doc/api/fs.md | |
parent | 5d4da62514cdf24c582fd4a8e5f86ef37860e8af (diff) |
fs: fix default `length` parameter for `fs.read`
Currently, specifying an `offset` without a `length`
throws an `ERR_OUT_OF_RANGE` error.
This commit provides a more sensible default.
This change should only affect cases
where no length is specified and a nonzero offset is,
which are currently throwing errors.
PR-URL: https://github.com/nodejs/node/pull/40349
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'doc/api/fs.md')
-rw-r--r-- | doc/api/fs.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md index 22f276cfe76..0db140ca411 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 @@ -3245,7 +3245,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} |