fs: replace a bind() with a top-level function
https://github.com/nodejs/node/pull/11225 introduce an unnecessary bind() when closing a stream. This PR replaces that bind() with a top-level function. PR-URL: https://github.com/nodejs/node/pull/13474 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Evan Lucas <evanlucas@me.com>
This commit is contained in:
parent
2db2857c72
commit
07ca288929
@ -2016,7 +2016,7 @@ ReadStream.prototype.close = function(cb) {
|
|||||||
|
|
||||||
if (this.closed || typeof this.fd !== 'number') {
|
if (this.closed || typeof this.fd !== 'number') {
|
||||||
if (typeof this.fd !== 'number') {
|
if (typeof this.fd !== 'number') {
|
||||||
this.once('open', this.close.bind(this, null));
|
this.once('open', closeOnOpen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return process.nextTick(() => this.emit('close'));
|
return process.nextTick(() => this.emit('close'));
|
||||||
@ -2034,6 +2034,11 @@ ReadStream.prototype.close = function(cb) {
|
|||||||
this.fd = null;
|
this.fd = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// needed because as it will be called with arguments
|
||||||
|
// that does not match this.close() signature
|
||||||
|
function closeOnOpen(fd) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
fs.createWriteStream = function(path, options) {
|
fs.createWriteStream = function(path, options) {
|
||||||
return new WriteStream(path, options);
|
return new WriteStream(path, options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user