From 4240f737d11ee2f59492e8b81ff67964358c3af6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 3 Mar 2016 20:04:37 -0800 Subject: [PATCH] Add symbol support to `baseCastPath`, `isKey`, and `toNumber`. --- lodash.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index 5dbf287cf..218bf348a 100644 --- a/lodash.js +++ b/lodash.js @@ -2328,7 +2328,10 @@ * @returns {Array} Returns the cast property path array. */ function baseCastPath(value) { - return isArray(value) ? value : stringToPath(value); + if (isArray(value)) { + return value; + } + return isSymbol(value) ? [value] : stringToPath(value); } /** @@ -5262,11 +5265,12 @@ * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { - if (typeof value == 'number') { + var type = typeof value; + if (type == 'number' || type == 'symbol') { return true; } return !isArray(value) && - (reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object))); } @@ -10967,7 +10971,9 @@ value = isObject(other) ? (other + '') : other; } if (typeof value != 'string') { - return value === 0 ? value : +value; + return value === 0 + ? value + : (typeof value == 'symbol' ? NAN : +value); } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value);