Skip to content

Commit

Permalink
fs: invoke callbacks with undefined context
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
Trott committed Aug 9, 2017
1 parent b3166e3 commit 9d6365a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/fs.js
Expand Up @@ -132,7 +132,7 @@ function makeCallback(cb) {
}

return function() {
return cb.apply(null, arguments);
return cb.apply(undefined, arguments);
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-mkdtemp.js
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-stat.js
Expand Up @@ -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
Expand Down

0 comments on commit 9d6365a

Please sign in to comment.