Skip to content

Commit

Permalink
fs: use arrow function for lexical this
Browse files Browse the repository at this point in the history
Extra scrutiny required for this change

Refs nodejs#7414
  • Loading branch information
originalfoo committed Jun 25, 2016
1 parent 78d0c5f commit b23a93a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,16 @@ ReadStream.prototype.destroy = function() {


ReadStream.prototype.close = function(cb) {
var self = this;
const close = (fd) => {
fs.close(fd || this.fd, (er) => {
if (er)
this.emit('error', er);
else
this.emit('close');
});
this.fd = null;
};

if (cb)
this.once('close', cb);
if (this.closed || typeof this.fd !== 'number') {
Expand All @@ -1798,16 +1807,6 @@ ReadStream.prototype.close = function(cb) {
}
this.closed = true;
close();

function close(fd) {
fs.close(fd || self.fd, function(er) {
if (er)
self.emit('error', er);
else
self.emit('close');
});
self.fd = null;
}
};


Expand Down

0 comments on commit b23a93a

Please sign in to comment.