util: isObject should always return boolean
authorTrevor Norris <trev.norris@gmail.com>
Tue, 20 Aug 2013 18:05:36 +0000 (11:05 -0700)
committerTrevor Norris <trev.norris@gmail.com>
Tue, 20 Aug 2013 18:05:36 +0000 (11:05 -0700)
Fix small bug where isObject would return the original object instead of
true.

lib/util.js
test/simple/test-util.js

index 5addac5..78c16a5 100644 (file)
@@ -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;
 
index 7c30f5e..2acdbdb 100644 (file)
@@ -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});