Skip to content

Commit 770daa8

Browse files
committed
fixup! fixup! fs: add FileHandle.prototype.readableStream()
1 parent 84012da commit 770daa8

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

doc/api/fs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Reads data from the file and stores that in the given buffer.
302302
If the file is not modified concurrently, the end-of-file is reached when the
303303
number of bytes read is zero.
304304
305-
#### `filehandle.readableStream()`
305+
#### `filehandle.readableWebStream()`
306306
<!-- YAML
307307
added: REPLACEME
308308
-->
@@ -323,7 +323,7 @@ import {
323323

324324
const file = await open('./some/file/to/read');
325325

326-
for await (const chunk of file.readableStream())
326+
for await (const chunk of file.readableWebStream())
327327
console.log(chunk);
328328
```
329329
@@ -335,7 +335,7 @@ const {
335335
(async () => {
336336
const file = await open('./some/file/to/read');
337337

338-
for await (const chunk of file.readableStream())
338+
for await (const chunk of file.readableWebStream())
339339
console.log(chunk);
340340
})();
341341
```

lib/internal/fs/promises.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,12 @@ class FileHandle extends EventEmitterMixin(JSTransferable) {
215215
return this[kClosePromise];
216216
}
217217

218-
readableStream() {
218+
/**
219+
* @typedef {import('../webstreams/readablestream').ReadableStream
220+
* } ReadableStream
221+
* @returns {ReadableStream}
222+
*/
223+
readableWebStream() {
219224
if (this[kFd] === -1)
220225
throw new ERR_INVALID_STATE('The FileHandle is closed');
221226
if (this[kClosePromise])

test/parallel/test-filehandle-readablestream.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
1717
const dec = new TextDecoder();
1818
const file = await open(__filename);
1919
let data = '';
20-
for await (const chunk of file.readableStream())
20+
for await (const chunk of file.readableWebStream())
2121
data += dec.decode(chunk);
2222

2323
assert.strictEqual(check, data);
2424

25-
assert.throws(() => file.readableStream(), {
25+
assert.throws(() => file.readableWebStream(), {
2626
code: 'ERR_INVALID_STATE',
2727
});
2828

@@ -33,7 +33,7 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
3333
const file = await open(__filename);
3434
await file.close();
3535

36-
assert.throws(() => file.readableStream(), {
36+
assert.throws(() => file.readableWebStream(), {
3737
code: 'ERR_INVALID_STATE',
3838
});
3939
})().then(common.mustCall());
@@ -42,7 +42,7 @@ const check = readFileSync(__filename, { encoding: 'utf8' });
4242
const file = await open(__filename);
4343
file.close();
4444

45-
assert.throws(() => file.readableStream(), {
45+
assert.throws(() => file.readableWebStream(), {
4646
code: 'ERR_INVALID_STATE',
4747
});
4848
})().then(common.mustCall());

0 commit comments

Comments
 (0)