From 50cee6ecab869bd406a4a8806906c87a51b0b1b2 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 20 Aug 2013 11:05:36 -0700 Subject: [PATCH] util: isObject should always return boolean Fix small bug where isObject would return the original object instead of true. --- lib/util.js | 2 +- test/simple/test-util.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 5addac5c3aa..78c16a51204 100644 --- a/lib/util.js +++ b/lib/util.js @@ -486,7 +486,7 @@ function isRegExp(re) { exports.isRegExp = isRegExp; function isObject(arg) { - return typeof arg === 'object' && arg; + return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; diff --git a/test/simple/test-util.js b/test/simple/test-util.js index 7c30f5e83e5..2acdbdb0cac 100644 --- a/test/simple/test-util.js +++ b/test/simple/test-util.js @@ -70,6 +70,9 @@ assert.equal(false, util.isError({ name: 'Error', message: '' })); assert.equal(false, util.isError([])); assert.equal(false, util.isError(Object.create(Error.prototype))); +// isObject +assert.ok(util.isObject({}) === true); + // _extend assert.deepEqual(util._extend({a:1}), {a:1}); assert.deepEqual(util._extend({a:1}, []), {a:1});