Skip to content

Commit

Permalink
fs: use arrow function for lexical this
Browse files Browse the repository at this point in the history
This commit merits extra scrutiny.

Refs nodejs#7414
  • Loading branch information
originalfoo committed Jun 25, 2016
1 parent c9d82ec commit 78d0c5f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1755,28 +1755,25 @@ ReadStream.prototype._read = function(n) {
return this.push(null);

// the actual read.
var self = this;
fs.read(this.fd, pool, pool.used, toRead, this.pos, onread);

// move the pool positions, and internal position for reading.
if (this.pos !== undefined)
this.pos += toRead;
pool.used += toRead;

function onread(er, bytesRead) {
fs.read(this.fd, pool, pool.used, toRead, this.pos, (er, bytesRead) => {
if (er) {
if (self.autoClose) {
self.destroy();
if (this.autoClose) {
this.destroy();
}
self.emit('error', er);
this.emit('error', er);
} else {
var b = null;
if (bytesRead > 0)
b = thisPool.slice(start, start + bytesRead);

self.push(b);
this.push(b);
}
}
});

// move the pool positions, and internal position for reading.
if (this.pos !== undefined)
this.pos += toRead;
pool.used += toRead;
};


Expand Down

0 comments on commit 78d0c5f

Please sign in to comment.