Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8a90f55

Browse filesBrowse files
Linkgorontargos
authored andcommitted
fs: allow no-params fsPromises fileHandle read
allow no-params read for fsPromises fileHandle read PR-URL: #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>
1 parent bc6e719 commit 8a90f55
Copy full SHA for 8a90f55

File tree

Expand file treeCollapse file tree

3 files changed

+12
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Reads data from the file and stores that in the given buffer.
285285
If the file is not modified concurrently, the end-of-file is reached when the
286286
number of bytes read is zero.
287287
288-
#### `filehandle.read(options)`
288+
#### `filehandle.read([options])`
289289
<!-- YAML
290290
added:
291291
- v13.11.0
Collapse file

‎lib/internal/fs/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ async function open(path, flags, mode) {
400400
async function read(handle, bufferOrOptions, offset, length, position) {
401401
let buffer = bufferOrOptions;
402402
if (!isArrayBufferView(buffer)) {
403+
if (bufferOrOptions === undefined) {
404+
bufferOrOptions = {};
405+
}
403406
if (bufferOrOptions.buffer) {
404407
buffer = bufferOrOptions.buffer;
405408
validateBuffer(buffer);
Collapse file

‎test/parallel/test-fs-promises-file-handle-read.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-read.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ async function validateLargeRead(options) {
6161
assert.strictEqual(readHandle.bytesRead, 0);
6262
}
6363

64+
async function validateReadNoParams() {
65+
const filePath = fixtures.path('x.txt');
66+
const fileHandle = await open(filePath, 'r');
67+
// Should not throw
68+
await fileHandle.read();
69+
}
70+
6471

6572
(async function() {
6673
tmpdir.refresh();
@@ -70,4 +77,5 @@ async function validateLargeRead(options) {
7077
await validateRead('', 'read-empty-file-conf', { useConf: true });
7178
await validateLargeRead({ useConf: false });
7279
await validateLargeRead({ useConf: true });
80+
await validateReadNoParams();
7381
})().then(common.mustCall());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.