Skip to content

Commit 39caa6d

Browse files
JacksonTianaddaleax
authored andcommitted
fs: use _final() for fs.WriteStream
use _final() method instead of once 'finish' event. PR-URL: #20562 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ccf69dd commit 39caa6d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎lib/fs.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,17 +2212,17 @@ function WriteStream(path, options) {
22122212

22132213
if(typeofthis.fd!=='number')
22142214
this.open();
2215-
2216-
// dispose on finish.
2217-
this.once('finish',function(){
2218-
if(this.autoClose){
2219-
this.destroy();
2220-
}
2221-
});
22222215
}
22232216

22242217
fs.FileWriteStream=fs.WriteStream;// support the legacy name
22252218

2219+
WriteStream.prototype._final=function(callback){
2220+
if(this.autoClose){
2221+
this.destroy();
2222+
}
2223+
2224+
callback();
2225+
};
22262226

22272227
WriteStream.prototype.open=function(){
22282228
fs.open(this.path,this.flags,this.mode,(er,fd)=>{

0 commit comments

Comments
 (0)