mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Support symbols in property paths of set. [closes #3189]
This commit is contained in:
@@ -13,10 +13,13 @@ const reIsUint = /^(?:0|[1-9]\d*)$/
|
|||||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||||
*/
|
*/
|
||||||
function isIndex(value, length) {
|
function isIndex(value, length) {
|
||||||
|
const type = typeof value
|
||||||
length = length == null ? MAX_SAFE_INTEGER : length
|
length = length == null ? MAX_SAFE_INTEGER : length
|
||||||
|
|
||||||
return !!length &&
|
return !!length &&
|
||||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
(type == 'number' ||
|
||||||
(value > -1 && value % 1 == 0 && value < length)
|
(type != 'symbol' && reIsUint.test(value))) &&
|
||||||
|
(value > -1 && value % 1 == 0 && value < length)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isIndex
|
export default isIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user