Add symbol support to baseCastPath, isKey, and toNumber.

This commit is contained in:
John-David Dalton
2016-03-03 20:04:37 -08:00
parent 25121a86bb
commit 4240f737d1

View File

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