From 9d6365a6e1642edb7353329e438238ddc0f8bd80 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 5 Aug 2017 18:10:28 -0700 Subject: [PATCH] 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`. --- lib/fs.js | 2 +- test/parallel/test-fs-mkdtemp.js | 2 +- test/parallel/test-fs-stat.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index d733a0eaa57053..7c4e68358b33c2 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -132,7 +132,7 @@ function makeCallback(cb) { } return function() { - return cb.apply(null, arguments); + return cb.apply(undefined, arguments); }; } diff --git a/test/parallel/test-fs-mkdtemp.js b/test/parallel/test-fs-mkdtemp.js index 5ce340afa5ad0f..38a306b85c7aa8 100644 --- a/test/parallel/test-fs-mkdtemp.js +++ b/test/parallel/test-fs-mkdtemp.js @@ -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)); diff --git a/test/parallel/test-fs-stat.js b/test/parallel/test-fs-stat.js index 8a6bb1c6245431..332a26e9bff2e8 100644 --- a/test/parallel/test-fs-stat.js +++ b/test/parallel/test-fs-stat.js @@ -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