Skip to content

Commit 69b7f91

Browse files
deokjinkimtargos
authored andcommitted
fs: remove redundant code in readableWebStream()
Remove redundant code by moving it to outside of `if/else`. Plus, make `options` optional in doc. PR-URL: #49298 Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent ddebd29 commit 69b7f91

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

‎doc/api/fs.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ Reads data from the file and stores that in the given buffer.
444444
If the file is not modified concurrently, the end-of-file is reached when the
445445
number of bytes read is zero.
446446
447-
#### `filehandle.readableWebStream(options)`
447+
#### `filehandle.readableWebStream([options])`
448448
449449
<!-- YAML
450450
added: v17.0.0

‎lib/internal/fs/promises.js‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,8 @@ class FileHandle extends EventEmitterMixin(JSTransferable){
276276
this[kHandle],
277277
undefined,
278278
{ondone: ()=>this[kUnref]()});
279-
280-
const{
281-
readableStreamCancel,
282-
}=require('internal/webstreams/readablestream');
283-
this[kRef]();
284-
this.once('close',()=>{
285-
readableStreamCancel(readable);
286-
});
287279
}else{
288280
const{
289-
readableStreamCancel,
290281
ReadableStream,
291282
}=require('internal/webstreams/readablestream');
292283

@@ -313,14 +304,16 @@ class FileHandle extends EventEmitterMixin(JSTransferable){
313304
ondone();
314305
},
315306
});
316-
317-
this[kRef]();
318-
319-
this.once('close',()=>{
320-
readableStreamCancel(readable);
321-
});
322307
}
323308

309+
const{
310+
readableStreamCancel,
311+
}=require('internal/webstreams/readablestream');
312+
this[kRef]();
313+
this.once('close',()=>{
314+
readableStreamCancel(readable);
315+
});
316+
324317
returnreadable;
325318
}
326319

0 commit comments

Comments
(0)