Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: replace a bind() with a top-level function #13474

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ ReadStream.prototype.close = function(cb) {

if (this.closed || typeof this.fd !== 'number') {
if (typeof this.fd !== 'number') {
this.once('open', this.close.bind(this, null));
this.once('open', closeOnOpen);
return;
}
return process.nextTick(() => this.emit('close'));
Expand All @@ -2034,6 +2034,11 @@ ReadStream.prototype.close = function(cb) {
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) {
return new WriteStream(path, options);
Expand Down