util: isObject should always return boolean

Fix small bug where isObject would return the original object instead of
true.
pull/28770/head
Trevor Norris 2013-08-20 11:05:36 -07:00
parent edd2fcccf0
commit 50cee6ecab
2 changed files with 4 additions and 1 deletions

View File

@ -486,7 +486,7 @@ function isRegExp(re) {
exports.isRegExp = isRegExp; exports.isRegExp = isRegExp;
function isObject(arg) { function isObject(arg) {
return typeof arg === 'object' && arg; return typeof arg === 'object' && arg !== null;
} }
exports.isObject = isObject; exports.isObject = isObject;

View File

@ -70,6 +70,9 @@ assert.equal(false, util.isError({ name: 'Error', message: '' }));
assert.equal(false, util.isError([])); assert.equal(false, util.isError([]));
assert.equal(false, util.isError(Object.create(Error.prototype))); assert.equal(false, util.isError(Object.create(Error.prototype)));
// isObject
assert.ok(util.isObject({}) === true);
// _extend // _extend
assert.deepEqual(util._extend({a:1}), {a:1}); assert.deepEqual(util._extend({a:1}), {a:1});
assert.deepEqual(util._extend({a:1}, []), {a:1}); assert.deepEqual(util._extend({a:1}, []), {a:1});