mirror of https://github.com/nodejs/node.git
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
parent
624938d052
commit
d66d840e3b
|
@ -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…
Reference in New Issue