util: fix isPrimitive check

Previous check failed for the edge case Object.create(null). This uses
the current v8 code for the check.
pull/5010/head
Trevor Norris 2013-08-12 13:41:51 -07:00
parent 624938d052
commit d66d840e3b
1 changed files with 6 additions and 1 deletions

View File

@ -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;