Permalink
Browse files

fs: invoke callbacks with undefined context

Many callbacks appear to be invoked with `this` set to `undefined`
including `fs.stat()`, `fs.lstat()`, and `fs.fstat()`.

However, some such as `fs.open()` and `fs.mkdtemp()` invoke their
callbacks with `this` set to `null`. Change to `undefined`.

PR-URL: #14645
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information...
Trott committed Aug 6, 2017
1 parent c6126b1 commit 2249234fee2b4f0ce204859728135b9767538383
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/fs.js
  2. +1 −1 test/parallel/test-fs-mkdtemp.js
  3. +1 −1 test/parallel/test-fs-stat.js
View
@@ -132,7 +132,7 @@ function makeCallback(cb) {
}
return function() {
return cb.apply(null, arguments);
return cb.apply(undefined, arguments);
};
}
@@ -20,7 +20,7 @@ assert(common.fileExists(utf8));
function handler(err, folder) {
assert.ifError(err);
assert(common.fileExists(folder));
assert.strictEqual(this, null);
assert.strictEqual(this, undefined);
}
fs.mkdtemp(path.join(common.tmpDir, 'bar.'), common.mustCall(handler));
@@ -66,7 +66,7 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
// Confirm that we are not running in the context of the internal binding
// layer.
// Ref: https://github.com/nodejs/node/commit/463d6bac8b349acc462d345a6e298a76f7d06fb1
assert.strictEqual(this, null);
assert.strictEqual(this, undefined);
}));
// fstatSync

1 comment on commit 2249234

@mikermcneil

This comment has been minimized.

Show comment
Hide comment
@mikermcneil

mikermcneil commented on 2249234 Nov 2, 2017

Awesome!

Please sign in to comment.