Browse Source

util: fix isPrimitive check

Previous check failed for the edge case Object.create(null). This uses
the current v8 code for the check.
v0.11.6-release
Trevor Norris 12 years ago
parent
commit
d66d840e3b
  1. 7
      lib/util.js

7
lib/util.js

@ -506,7 +506,12 @@ function isFunction(arg) {
exports.isFunction = isFunction;
function isPrimitive(arg) {
return !(arg instanceof Object);
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;

Loading…
Cancel
Save