From d66d840e3b4750f64ae5a957a63159de49cc38ce Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 12 Aug 2013 13:41:51 -0700 Subject: [PATCH] util: fix isPrimitive check Previous check failed for the edge case Object.create(null). This uses the current v8 code for the check. --- lib/util.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 1b168bfd945..5addac5c3aa 100644 --- a/lib/util.js +++ b/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;