fs: allow no-params fsPromises fileHandle read

allow no-params read for fsPromises fileHandle read

PR-URL: https://github.com/nodejs/node/pull/38287
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Nitzan Uziely authored and Michaël Zasso committed 2021-09-04 09:17:50 +02:00
1 parent 63502131a3
commit ef72490cde
3 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -275,7 +275,7 @@ Reads data from the file and stores that in the given buffer.
If the file is not modified concurrently, the end-of-file is reached when the
number of bytes read is zero.
#### `filehandle.read(options)`
#### `filehandle.read([options])`
<!-- YAML
added:
- v13.11.0
+3
View File
@@ -388,6 +388,9 @@ async function open(path, flags, mode) {
async function read(handle, bufferOrOptions, offset, length, position) {
let buffer = bufferOrOptions;
if (!isArrayBufferView(buffer)) {
if (bufferOrOptions === undefined) {
bufferOrOptions = {};
}
if (bufferOrOptions.buffer) {
buffer = bufferOrOptions.buffer;
validateBuffer(buffer);
@@ -60,6 +60,13 @@ async function validateLargeRead() {
assert.strictEqual(readHandle.bytesRead, 0);
}
async function validateReadNoParams() {
const filePath = fixtures.path('x.txt');
const fileHandle = await open(filePath, 'r');
// Should not throw
await fileHandle.read();
}
let useConf = false;
(async function() {
@@ -72,4 +79,5 @@ let useConf = false;
.then(validateLargeRead)
.then(common.mustCall());
}
await validateReadNoParams();
})().then(common.mustCall());