es-toolkit 1.13.1-dev.329 → 1.13.1-dev.333
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunk/index-CwRt_M.js +47 -0
- package/dist/_chunk/index-CwRt_M.js.map +1 -0
- package/dist/_chunk/isPlainObject-bK22pA.js +24 -0
- package/dist/_chunk/isPlainObject-bK22pA.js.map +1 -0
- package/dist/_chunk/randomInt-CF7bZK.js +20 -0
- package/dist/_chunk/randomInt-CF7bZK.js.map +1 -0
- package/dist/_chunk/union-CdQeDK.js +13 -0
- package/dist/_chunk/union-CdQeDK.js.map +1 -0
- package/dist/array/chunk.mjs +16 -8
- package/dist/array/chunk.mjs.map +1 -1
- package/dist/array/compact.mjs +12 -8
- package/dist/array/compact.mjs.map +1 -1
- package/dist/array/countBy.mjs +11 -8
- package/dist/array/countBy.mjs.map +1 -1
- package/dist/array/difference.mjs +7 -8
- package/dist/array/difference.mjs.map +1 -1
- package/dist/array/differenceBy.mjs +9 -8
- package/dist/array/differenceBy.mjs.map +1 -1
- package/dist/array/differenceWith.mjs +10 -8
- package/dist/array/differenceWith.mjs.map +1 -1
- package/dist/array/drop.mjs +7 -8
- package/dist/array/drop.mjs.map +1 -1
- package/dist/array/dropRight.mjs +10 -8
- package/dist/array/dropRight.mjs.map +1 -1
- package/dist/array/dropRightWhile.mjs +11 -8
- package/dist/array/dropRightWhile.mjs.map +1 -1
- package/dist/array/dropWhile.mjs +10 -8
- package/dist/array/dropWhile.mjs.map +1 -1
- package/dist/array/fill.mjs +12 -8
- package/dist/array/fill.mjs.map +1 -1
- package/dist/array/flatMap.mjs +8 -9
- package/dist/array/flatMap.mjs.map +1 -1
- package/dist/array/flatten.mjs +19 -8
- package/dist/array/flatten.mjs.map +1 -1
- package/dist/array/flattenDeep.mjs +8 -9
- package/dist/array/flattenDeep.mjs.map +1 -1
- package/dist/array/forEachRight.mjs +9 -8
- package/dist/array/forEachRight.mjs.map +1 -1
- package/dist/array/groupBy.mjs +14 -8
- package/dist/array/groupBy.mjs.map +1 -1
- package/dist/array/head.mjs +6 -8
- package/dist/array/head.mjs.map +1 -1
- package/dist/array/index.js +353 -498
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +52 -211
- package/dist/array/index.mjs.map +1 -1
- package/dist/array/initial.mjs +9 -8
- package/dist/array/initial.mjs.map +1 -1
- package/dist/array/intersection.mjs +9 -8
- package/dist/array/intersection.mjs.map +1 -1
- package/dist/array/intersectionBy.mjs +7 -8
- package/dist/array/intersectionBy.mjs.map +1 -1
- package/dist/array/intersectionWith.mjs +10 -8
- package/dist/array/intersectionWith.mjs.map +1 -1
- package/dist/array/keyBy.mjs +11 -8
- package/dist/array/keyBy.mjs.map +1 -1
- package/dist/array/last.mjs +6 -8
- package/dist/array/last.mjs.map +1 -1
- package/dist/array/maxBy.mjs +15 -8
- package/dist/array/maxBy.mjs.map +1 -1
- package/dist/array/minBy.mjs +15 -8
- package/dist/array/minBy.mjs.map +1 -1
- package/dist/array/orderBy.mjs +26 -8
- package/dist/array/orderBy.mjs.map +1 -1
- package/dist/array/partition.mjs +16 -8
- package/dist/array/partition.mjs.map +1 -1
- package/dist/array/sample.mjs +7 -8
- package/dist/array/sample.mjs.map +1 -1
- package/dist/array/sampleSize.mjs +21 -10
- package/dist/array/sampleSize.mjs.map +1 -1
- package/dist/array/shuffle.mjs +11 -8
- package/dist/array/shuffle.mjs.map +1 -1
- package/dist/array/tail.mjs +14 -8
- package/dist/array/tail.mjs.map +1 -1
- package/dist/array/take.mjs +6 -8
- package/dist/array/take.mjs.map +1 -1
- package/dist/array/takeRight.mjs +9 -8
- package/dist/array/takeRight.mjs.map +1 -1
- package/dist/array/takeRightWhile.mjs +11 -8
- package/dist/array/takeRightWhile.mjs.map +1 -1
- package/dist/array/takeWhile.mjs +13 -8
- package/dist/array/takeWhile.mjs.map +1 -1
- package/dist/array/toFilled.mjs +13 -8
- package/dist/array/toFilled.mjs.map +1 -1
- package/dist/array/union.mjs +8 -9
- package/dist/array/union.mjs.map +1 -1
- package/dist/array/unionBy.mjs +13 -8
- package/dist/array/unionBy.mjs.map +1 -1
- package/dist/array/unionWith.mjs +8 -9
- package/dist/array/unionWith.mjs.map +1 -1
- package/dist/array/uniq.mjs +6 -8
- package/dist/array/uniq.mjs.map +1 -1
- package/dist/array/uniqBy.mjs +13 -8
- package/dist/array/uniqBy.mjs.map +1 -1
- package/dist/array/uniqWith.mjs +13 -8
- package/dist/array/uniqWith.mjs.map +1 -1
- package/dist/array/unzip.mjs +19 -8
- package/dist/array/unzip.mjs.map +1 -1
- package/dist/array/unzipWith.mjs +15 -8
- package/dist/array/unzipWith.mjs.map +1 -1
- package/dist/array/without.mjs +7 -8
- package/dist/array/without.mjs.map +1 -1
- package/dist/array/xor.mjs +10 -12
- package/dist/array/xor.mjs.map +1 -1
- package/dist/array/xorBy.mjs +12 -11
- package/dist/array/xorBy.mjs.map +1 -1
- package/dist/array/xorWith.mjs +12 -12
- package/dist/array/xorWith.mjs.map +1 -1
- package/dist/array/zip.mjs +15 -8
- package/dist/array/zip.mjs.map +1 -1
- package/dist/array/zipObject.mjs +10 -8
- package/dist/array/zipObject.mjs.map +1 -1
- package/dist/array/zipWith.mjs +14 -8
- package/dist/array/zipWith.mjs.map +1 -1
- package/dist/compat/_internal/isDeepKey.mjs +16 -0
- package/dist/compat/_internal/isDeepKey.mjs.map +1 -0
- package/dist/compat/_internal/isIndex.mjs +17 -0
- package/dist/compat/_internal/isIndex.mjs.map +1 -0
- package/dist/compat/_internal/toPath.mjs +41 -0
- package/dist/compat/_internal/toPath.mjs.map +1 -0
- package/dist/compat/array/chunk.d.mts +26 -0
- package/dist/compat/array/chunk.d.ts +26 -0
- package/dist/compat/array/chunk.mjs +12 -0
- package/dist/compat/array/chunk.mjs.map +1 -0
- package/dist/compat/array/concat.d.mts +30 -0
- package/dist/compat/array/concat.d.ts +30 -0
- package/dist/compat/array/concat.mjs +8 -0
- package/dist/compat/array/concat.mjs.map +1 -0
- package/dist/compat/array/difference.d.mts +3 -0
- package/dist/compat/array/difference.d.ts +3 -0
- package/dist/compat/array/difference.mjs +11 -0
- package/dist/compat/array/difference.mjs.map +1 -0
- package/dist/compat/array/fill.d.mts +33 -0
- package/dist/compat/array/fill.d.ts +33 -0
- package/dist/compat/array/fill.mjs +16 -0
- package/dist/compat/array/fill.mjs.map +1 -0
- package/dist/compat/array/zipObjectDeep.d.mts +37 -0
- package/dist/compat/array/zipObjectDeep.d.ts +37 -0
- package/dist/compat/array/zipObjectDeep.mjs +17 -0
- package/dist/compat/array/zipObjectDeep.mjs.map +1 -0
- package/dist/compat/index.d.mts +14 -546
- package/dist/compat/index.d.ts +14 -546
- package/dist/compat/index.js +287 -1498
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +106 -415
- package/dist/compat/index.mjs.map +1 -1
- package/dist/compat/math/max.d.mts +19 -0
- package/dist/compat/math/max.d.ts +19 -0
- package/dist/compat/math/max.mjs +14 -0
- package/dist/compat/math/max.mjs.map +1 -0
- package/dist/compat/math/min.d.mts +19 -0
- package/dist/compat/math/min.d.ts +19 -0
- package/dist/compat/math/min.mjs +14 -0
- package/dist/compat/math/min.mjs.map +1 -0
- package/dist/compat/object/get.d.mts +247 -0
- package/dist/compat/object/get.d.ts +247 -0
- package/dist/compat/object/get.mjs +34 -0
- package/dist/compat/object/get.mjs.map +1 -0
- package/dist/compat/object/get.types.d.mts +9 -0
- package/dist/compat/object/get.types.d.ts +9 -0
- package/dist/compat/object/set.d.mts +30 -0
- package/dist/compat/object/set.d.ts +30 -0
- package/dist/compat/object/set.mjs +25 -0
- package/dist/compat/object/set.mjs.map +1 -0
- package/dist/compat/predicate/isArray.d.mts +24 -0
- package/dist/compat/predicate/isArray.d.ts +24 -0
- package/dist/compat/predicate/isArray.mjs +6 -0
- package/dist/compat/predicate/isArray.mjs.map +1 -0
- package/dist/compat/predicate/isPlainObject.d.mts +25 -0
- package/dist/compat/predicate/isPlainObject.d.ts +25 -0
- package/dist/compat/predicate/isPlainObject.mjs +30 -0
- package/dist/compat/predicate/isPlainObject.mjs.map +1 -0
- package/dist/compat/predicate/isTypedArray.d.mts +19 -0
- package/dist/compat/predicate/isTypedArray.d.ts +19 -0
- package/dist/compat/predicate/isTypedArray.mjs +8 -0
- package/dist/compat/predicate/isTypedArray.mjs.map +1 -0
- package/dist/compat/string/endsWith.d.mts +20 -0
- package/dist/compat/string/endsWith.d.ts +20 -0
- package/dist/compat/string/endsWith.mjs +6 -0
- package/dist/compat/string/endsWith.mjs.map +1 -0
- package/dist/compat/string/startsWith.d.mts +20 -0
- package/dist/compat/string/startsWith.d.ts +20 -0
- package/dist/compat/string/startsWith.mjs +6 -0
- package/dist/compat/string/startsWith.mjs.map +1 -0
- package/dist/error/AbortError.mjs +9 -8
- package/dist/error/AbortError.mjs.map +1 -1
- package/dist/error/TimeoutError.mjs +9 -8
- package/dist/error/TimeoutError.mjs.map +1 -1
- package/dist/function/after.mjs +14 -7
- package/dist/function/after.mjs.map +1 -1
- package/dist/function/debounce.mjs +29 -8
- package/dist/function/debounce.mjs.map +1 -1
- package/dist/function/index.js +66 -102
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +7 -29
- package/dist/function/index.mjs.map +1 -1
- package/dist/function/negate.mjs +6 -8
- package/dist/function/negate.mjs.map +1 -1
- package/dist/function/noop.mjs +4 -8
- package/dist/function/noop.mjs.map +1 -1
- package/dist/function/once.mjs +16 -8
- package/dist/function/once.mjs.map +1 -1
- package/dist/function/throttle.mjs +14 -8
- package/dist/function/throttle.mjs.map +1 -1
- package/dist/index.js +114 -1307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -399
- package/dist/index.mjs.map +1 -1
- package/dist/math/clamp.mjs +9 -8
- package/dist/math/clamp.mjs.map +1 -1
- package/dist/math/inRange.mjs +13 -8
- package/dist/math/inRange.mjs.map +1 -1
- package/dist/math/index.js +59 -115
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +11 -45
- package/dist/math/index.mjs.map +1 -1
- package/dist/math/mean.mjs +8 -9
- package/dist/math/mean.mjs.map +1 -1
- package/dist/math/meanBy.mjs +9 -10
- package/dist/math/meanBy.mjs.map +1 -1
- package/dist/math/random.mjs +13 -8
- package/dist/math/random.mjs.map +1 -1
- package/dist/math/randomInt.mjs +8 -9
- package/dist/math/randomInt.mjs.map +1 -1
- package/dist/math/range.mjs +21 -8
- package/dist/math/range.mjs.map +1 -1
- package/dist/math/round.mjs +10 -8
- package/dist/math/round.mjs.map +1 -1
- package/dist/math/sum.mjs +10 -8
- package/dist/math/sum.mjs.map +1 -1
- package/dist/math/sumBy.mjs +9 -9
- package/dist/math/sumBy.mjs.map +1 -1
- package/dist/object/clone.mjs +40 -8
- package/dist/object/clone.mjs.map +1 -1
- package/dist/object/cloneDeep.mjs +100 -8
- package/dist/object/cloneDeep.mjs.map +1 -1
- package/dist/object/flattenObject.mjs +29 -9
- package/dist/object/flattenObject.mjs.map +1 -1
- package/dist/object/index.js +184 -232
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +9 -38
- package/dist/object/index.mjs.map +1 -1
- package/dist/object/invert.mjs +13 -8
- package/dist/object/invert.mjs.map +1 -1
- package/dist/object/omit.mjs +10 -8
- package/dist/object/omit.mjs.map +1 -1
- package/dist/object/omitBy.mjs +13 -8
- package/dist/object/omitBy.mjs.map +1 -1
- package/dist/object/pick.mjs +10 -8
- package/dist/object/pick.mjs.map +1 -1
- package/dist/object/pickBy.mjs +13 -8
- package/dist/object/pickBy.mjs.map +1 -1
- package/dist/predicate/index.js +65 -126
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +12 -51
- package/dist/predicate/index.mjs.map +1 -1
- package/dist/predicate/isArrayLike.mjs +9 -9
- package/dist/predicate/isArrayLike.mjs.map +1 -1
- package/dist/predicate/isEqual.mjs +36 -10
- package/dist/predicate/isEqual.mjs.map +1 -1
- package/dist/predicate/isFunction.mjs +6 -8
- package/dist/predicate/isFunction.mjs.map +1 -1
- package/dist/predicate/isLength.mjs +6 -8
- package/dist/predicate/isLength.mjs.map +1 -1
- package/dist/predicate/isNil.mjs +6 -8
- package/dist/predicate/isNil.mjs.map +1 -1
- package/dist/predicate/isNotNil.mjs +6 -8
- package/dist/predicate/isNotNil.mjs.map +1 -1
- package/dist/predicate/isNull.mjs +6 -8
- package/dist/predicate/isNull.mjs.map +1 -1
- package/dist/predicate/isPlainObject.mjs +22 -8
- package/dist/predicate/isPlainObject.mjs.map +1 -1
- package/dist/predicate/isPrimitive.mjs +6 -8
- package/dist/predicate/isPrimitive.mjs.map +1 -1
- package/dist/predicate/isTypedArray.mjs +16 -8
- package/dist/predicate/isTypedArray.mjs.map +1 -1
- package/dist/predicate/isUndefined.mjs +6 -8
- package/dist/predicate/isUndefined.mjs.map +1 -1
- package/dist/promise/delay.mjs +21 -9
- package/dist/promise/delay.mjs.map +1 -1
- package/dist/promise/index.js +6 -72
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +3 -16
- package/dist/promise/index.mjs.map +1 -1
- package/dist/promise/timeout.mjs +10 -11
- package/dist/promise/timeout.mjs.map +1 -1
- package/dist/promise/withTimeout.mjs +8 -12
- package/dist/promise/withTimeout.mjs.map +1 -1
- package/dist/string/_internal/getWords.mjs +7 -0
- package/dist/string/_internal/getWords.mjs.map +1 -0
- package/dist/string/camelCase.mjs +14 -10
- package/dist/string/camelCase.mjs.map +1 -1
- package/dist/string/capitalize.mjs +5 -7
- package/dist/string/capitalize.mjs.map +1 -1
- package/dist/string/index.js +42 -77
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +7 -30
- package/dist/string/index.mjs.map +1 -1
- package/dist/string/kebabCase.mjs +8 -8
- package/dist/string/kebabCase.mjs.map +1 -1
- package/dist/string/lowerCase.mjs +8 -8
- package/dist/string/lowerCase.mjs.map +1 -1
- package/dist/string/snakeCase.mjs +8 -8
- package/dist/string/snakeCase.mjs.map +1 -1
- package/dist/string/startCase.mjs +21 -9
- package/dist/string/startCase.mjs.map +1 -1
- package/package.json +8 -2
- package/umd/browser.global.js +2 -2
- package/umd/browser.global.js.map +1 -0
- package/dist/array/chunk.js +0 -43
- package/dist/array/chunk.js.map +0 -1
- package/dist/array/compact.js +0 -39
- package/dist/array/compact.js.map +0 -1
- package/dist/array/countBy.js +0 -38
- package/dist/array/countBy.js.map +0 -1
- package/dist/array/difference.js +0 -34
- package/dist/array/difference.js.map +0 -1
- package/dist/array/differenceBy.js +0 -36
- package/dist/array/differenceBy.js.map +0 -1
- package/dist/array/differenceWith.js +0 -37
- package/dist/array/differenceWith.js.map +0 -1
- package/dist/array/drop.js +0 -34
- package/dist/array/drop.js.map +0 -1
- package/dist/array/dropRight.js +0 -37
- package/dist/array/dropRight.js.map +0 -1
- package/dist/array/dropRightWhile.js +0 -38
- package/dist/array/dropRightWhile.js.map +0 -1
- package/dist/array/dropWhile.js +0 -37
- package/dist/array/dropWhile.js.map +0 -1
- package/dist/array/fill.js +0 -39
- package/dist/array/fill.js.map +0 -1
- package/dist/array/flatMap.js +0 -52
- package/dist/array/flatMap.js.map +0 -1
- package/dist/array/flatten.js +0 -45
- package/dist/array/flatten.js.map +0 -1
- package/dist/array/flattenDeep.js +0 -52
- package/dist/array/flattenDeep.js.map +0 -1
- package/dist/array/forEachRight.js +0 -36
- package/dist/array/forEachRight.js.map +0 -1
- package/dist/array/groupBy.js +0 -41
- package/dist/array/groupBy.js.map +0 -1
- package/dist/array/head.js +0 -33
- package/dist/array/head.js.map +0 -1
- package/dist/array/initial.js +0 -36
- package/dist/array/initial.js.map +0 -1
- package/dist/array/intersection.js +0 -36
- package/dist/array/intersection.js.map +0 -1
- package/dist/array/intersectionBy.js +0 -34
- package/dist/array/intersectionBy.js.map +0 -1
- package/dist/array/intersectionWith.js +0 -37
- package/dist/array/intersectionWith.js.map +0 -1
- package/dist/array/keyBy.js +0 -38
- package/dist/array/keyBy.js.map +0 -1
- package/dist/array/last.js +0 -33
- package/dist/array/last.js.map +0 -1
- package/dist/array/maxBy.js +0 -42
- package/dist/array/maxBy.js.map +0 -1
- package/dist/array/minBy.js +0 -42
- package/dist/array/minBy.js.map +0 -1
- package/dist/array/orderBy.js +0 -53
- package/dist/array/orderBy.js.map +0 -1
- package/dist/array/partition.js +0 -42
- package/dist/array/partition.js.map +0 -1
- package/dist/array/sample.js +0 -34
- package/dist/array/sample.js.map +0 -1
- package/dist/array/sampleSize.js +0 -65
- package/dist/array/sampleSize.js.map +0 -1
- package/dist/array/shuffle.js +0 -38
- package/dist/array/shuffle.js.map +0 -1
- package/dist/array/tail.js +0 -41
- package/dist/array/tail.js.map +0 -1
- package/dist/array/take.js +0 -33
- package/dist/array/take.js.map +0 -1
- package/dist/array/takeRight.js +0 -36
- package/dist/array/takeRight.js.map +0 -1
- package/dist/array/takeRightWhile.js +0 -38
- package/dist/array/takeRightWhile.js.map +0 -1
- package/dist/array/takeWhile.js +0 -40
- package/dist/array/takeWhile.js.map +0 -1
- package/dist/array/toFilled.js +0 -40
- package/dist/array/toFilled.js.map +0 -1
- package/dist/array/union.js +0 -40
- package/dist/array/union.js.map +0 -1
- package/dist/array/unionBy.js +0 -40
- package/dist/array/unionBy.js.map +0 -1
- package/dist/array/unionWith.js +0 -47
- package/dist/array/unionWith.js.map +0 -1
- package/dist/array/uniq.js +0 -33
- package/dist/array/uniq.js.map +0 -1
- package/dist/array/uniqBy.js +0 -40
- package/dist/array/uniqBy.js.map +0 -1
- package/dist/array/uniqWith.js +0 -40
- package/dist/array/uniqWith.js.map +0 -1
- package/dist/array/unzip.js +0 -46
- package/dist/array/unzip.js.map +0 -1
- package/dist/array/unzipWith.js +0 -42
- package/dist/array/unzipWith.js.map +0 -1
- package/dist/array/without.js +0 -34
- package/dist/array/without.js.map +0 -1
- package/dist/array/xor.js +0 -59
- package/dist/array/xor.js.map +0 -1
- package/dist/array/xorBy.js +0 -63
- package/dist/array/xorBy.js.map +0 -1
- package/dist/array/xorWith.js +0 -72
- package/dist/array/xorWith.js.map +0 -1
- package/dist/array/zip.js +0 -42
- package/dist/array/zip.js.map +0 -1
- package/dist/array/zipObject.js +0 -37
- package/dist/array/zipObject.js.map +0 -1
- package/dist/array/zipWith.js +0 -41
- package/dist/array/zipWith.js.map +0 -1
- package/dist/browser.d.mts +0 -2
- package/dist/browser.d.ts +0 -2
- package/dist/browser.js +0 -1440
- package/dist/browser.js.map +0 -1
- package/dist/browser.mjs +0 -115
- package/dist/browser.mjs.map +0 -1
- package/dist/chunk-237HGSZS.mjs +0 -16
- package/dist/chunk-237HGSZS.mjs.map +0 -1
- package/dist/chunk-27QMXBLJ.mjs +0 -9
- package/dist/chunk-27QMXBLJ.mjs.map +0 -1
- package/dist/chunk-2IXFGSUA.mjs +0 -16
- package/dist/chunk-2IXFGSUA.mjs.map +0 -1
- package/dist/chunk-2KNLZB7V.mjs +0 -10
- package/dist/chunk-2KNLZB7V.mjs.map +0 -1
- package/dist/chunk-2SLTL4KL.mjs +0 -13
- package/dist/chunk-2SLTL4KL.mjs.map +0 -1
- package/dist/chunk-2ZCITDMK.mjs +0 -13
- package/dist/chunk-2ZCITDMK.mjs.map +0 -1
- package/dist/chunk-33MSBDC6.mjs +0 -21
- package/dist/chunk-33MSBDC6.mjs.map +0 -1
- package/dist/chunk-3EZAFZG3.mjs +0 -10
- package/dist/chunk-3EZAFZG3.mjs.map +0 -1
- package/dist/chunk-3SBT6WDU.mjs +0 -25
- package/dist/chunk-3SBT6WDU.mjs.map +0 -1
- package/dist/chunk-4DFAGGIM.mjs +0 -26
- package/dist/chunk-4DFAGGIM.mjs.map +0 -1
- package/dist/chunk-4OIZM4HS.mjs +0 -1
- package/dist/chunk-4OIZM4HS.mjs.map +0 -1
- package/dist/chunk-4ZES5T6V.mjs +0 -21
- package/dist/chunk-4ZES5T6V.mjs.map +0 -1
- package/dist/chunk-5ASRKEB4.mjs +0 -13
- package/dist/chunk-5ASRKEB4.mjs.map +0 -1
- package/dist/chunk-5F26PFZL.mjs +0 -32
- package/dist/chunk-5F26PFZL.mjs.map +0 -1
- package/dist/chunk-5L4VWRFX.mjs +0 -14
- package/dist/chunk-5L4VWRFX.mjs.map +0 -1
- package/dist/chunk-5PMKOZ2F.mjs +0 -13
- package/dist/chunk-5PMKOZ2F.mjs.map +0 -1
- package/dist/chunk-6CLH5YZ2.mjs +0 -16
- package/dist/chunk-6CLH5YZ2.mjs.map +0 -1
- package/dist/chunk-6NVQAHXP.mjs +0 -13
- package/dist/chunk-6NVQAHXP.mjs.map +0 -1
- package/dist/chunk-74CREQXW.mjs +0 -9
- package/dist/chunk-74CREQXW.mjs.map +0 -1
- package/dist/chunk-7B7W36UP.mjs +0 -29
- package/dist/chunk-7B7W36UP.mjs.map +0 -1
- package/dist/chunk-7GXKT3VW.mjs +0 -41
- package/dist/chunk-7GXKT3VW.mjs.map +0 -1
- package/dist/chunk-AIRSKN47.mjs +0 -9
- package/dist/chunk-AIRSKN47.mjs.map +0 -1
- package/dist/chunk-AJKZMN2V.mjs +0 -14
- package/dist/chunk-AJKZMN2V.mjs.map +0 -1
- package/dist/chunk-B4COTK4K.mjs +0 -16
- package/dist/chunk-B4COTK4K.mjs.map +0 -1
- package/dist/chunk-BCTYOXT7.mjs +0 -16
- package/dist/chunk-BCTYOXT7.mjs.map +0 -1
- package/dist/chunk-BGWHVWY4.mjs +0 -13
- package/dist/chunk-BGWHVWY4.mjs.map +0 -1
- package/dist/chunk-BH6HLGBA.mjs +0 -16
- package/dist/chunk-BH6HLGBA.mjs.map +0 -1
- package/dist/chunk-BMRTZMRE.mjs +0 -9
- package/dist/chunk-BMRTZMRE.mjs.map +0 -1
- package/dist/chunk-BOOQBJN2.mjs +0 -9
- package/dist/chunk-BOOQBJN2.mjs.map +0 -1
- package/dist/chunk-CMBC4MXG.mjs +0 -19
- package/dist/chunk-CMBC4MXG.mjs.map +0 -1
- package/dist/chunk-DDH7K4QM.mjs +0 -1
- package/dist/chunk-DDH7K4QM.mjs.map +0 -1
- package/dist/chunk-DLS7UJKJ.mjs +0 -17
- package/dist/chunk-DLS7UJKJ.mjs.map +0 -1
- package/dist/chunk-DN3NOZ3H.mjs +0 -18
- package/dist/chunk-DN3NOZ3H.mjs.map +0 -1
- package/dist/chunk-DPH2KE6O.mjs +0 -24
- package/dist/chunk-DPH2KE6O.mjs.map +0 -1
- package/dist/chunk-DTTKJ3VC.mjs +0 -9
- package/dist/chunk-DTTKJ3VC.mjs.map +0 -1
- package/dist/chunk-DVK2N4KC.mjs +0 -9
- package/dist/chunk-DVK2N4KC.mjs.map +0 -1
- package/dist/chunk-DXB7EZUQ.mjs +0 -12
- package/dist/chunk-DXB7EZUQ.mjs.map +0 -1
- package/dist/chunk-E6C5EZQA.mjs +0 -19
- package/dist/chunk-E6C5EZQA.mjs.map +0 -1
- package/dist/chunk-E6E4RZLN.mjs +0 -17
- package/dist/chunk-E6E4RZLN.mjs.map +0 -1
- package/dist/chunk-EHSKB6DF.mjs +0 -26
- package/dist/chunk-EHSKB6DF.mjs.map +0 -1
- package/dist/chunk-ET33L3MQ.mjs +0 -14
- package/dist/chunk-ET33L3MQ.mjs.map +0 -1
- package/dist/chunk-EZYYB34V.mjs +0 -17
- package/dist/chunk-EZYYB34V.mjs.map +0 -1
- package/dist/chunk-F47GLYUU.mjs +0 -1
- package/dist/chunk-F47GLYUU.mjs.map +0 -1
- package/dist/chunk-FUS75PJ7.mjs +0 -1
- package/dist/chunk-FUS75PJ7.mjs.map +0 -1
- package/dist/chunk-FVVSE2F2.mjs +0 -12
- package/dist/chunk-FVVSE2F2.mjs.map +0 -1
- package/dist/chunk-FZZNWXDM.mjs +0 -9
- package/dist/chunk-FZZNWXDM.mjs.map +0 -1
- package/dist/chunk-G7UQ5PUR.mjs +0 -14
- package/dist/chunk-G7UQ5PUR.mjs.map +0 -1
- package/dist/chunk-GIWAOOFY.mjs +0 -13
- package/dist/chunk-GIWAOOFY.mjs.map +0 -1
- package/dist/chunk-GTFDDKZ2.mjs +0 -15
- package/dist/chunk-GTFDDKZ2.mjs.map +0 -1
- package/dist/chunk-GZGXXIF7.mjs +0 -650
- package/dist/chunk-GZGXXIF7.mjs.map +0 -1
- package/dist/chunk-HPFDYUGP.mjs +0 -13
- package/dist/chunk-HPFDYUGP.mjs.map +0 -1
- package/dist/chunk-IEA53J7P.mjs +0 -12
- package/dist/chunk-IEA53J7P.mjs.map +0 -1
- package/dist/chunk-IFNXROZR.mjs +0 -18
- package/dist/chunk-IFNXROZR.mjs.map +0 -1
- package/dist/chunk-IJD7FE2Z.mjs +0 -18
- package/dist/chunk-IJD7FE2Z.mjs.map +0 -1
- package/dist/chunk-IWXZI3QT.mjs +0 -14
- package/dist/chunk-IWXZI3QT.mjs.map +0 -1
- package/dist/chunk-J5LGTIGS.mjs +0 -10
- package/dist/chunk-J5LGTIGS.mjs.map +0 -1
- package/dist/chunk-JCRY7ZYS.mjs +0 -22
- package/dist/chunk-JCRY7ZYS.mjs.map +0 -1
- package/dist/chunk-JPUKH67K.mjs +0 -10
- package/dist/chunk-JPUKH67K.mjs.map +0 -1
- package/dist/chunk-K5WL54BY.mjs +0 -93
- package/dist/chunk-K5WL54BY.mjs.map +0 -1
- package/dist/chunk-KIOYQRMQ.mjs +0 -12
- package/dist/chunk-KIOYQRMQ.mjs.map +0 -1
- package/dist/chunk-L7FQX5MN.mjs +0 -19
- package/dist/chunk-L7FQX5MN.mjs.map +0 -1
- package/dist/chunk-LJ2C6MVP.mjs +0 -13
- package/dist/chunk-LJ2C6MVP.mjs.map +0 -1
- package/dist/chunk-LKXCOLNY.mjs +0 -8
- package/dist/chunk-LKXCOLNY.mjs.map +0 -1
- package/dist/chunk-LPZZIY5Z.mjs +0 -13
- package/dist/chunk-LPZZIY5Z.mjs.map +0 -1
- package/dist/chunk-LVWX5B43.mjs +0 -12
- package/dist/chunk-LVWX5B43.mjs.map +0 -1
- package/dist/chunk-M7SBBYV2.mjs +0 -14
- package/dist/chunk-M7SBBYV2.mjs.map +0 -1
- package/dist/chunk-ME352XO7.mjs +0 -9
- package/dist/chunk-ME352XO7.mjs.map +0 -1
- package/dist/chunk-MIGAC7F4.mjs +0 -25
- package/dist/chunk-MIGAC7F4.mjs.map +0 -1
- package/dist/chunk-MJ7LNBI6.mjs +0 -17
- package/dist/chunk-MJ7LNBI6.mjs.map +0 -1
- package/dist/chunk-ML727RRJ.mjs +0 -13
- package/dist/chunk-ML727RRJ.mjs.map +0 -1
- package/dist/chunk-MLCL773E.mjs +0 -12
- package/dist/chunk-MLCL773E.mjs.map +0 -1
- package/dist/chunk-MY4G7R3I.mjs +0 -14
- package/dist/chunk-MY4G7R3I.mjs.map +0 -1
- package/dist/chunk-N3QYJX4T.mjs +0 -12
- package/dist/chunk-N3QYJX4T.mjs.map +0 -1
- package/dist/chunk-NFS7RWWE.mjs +0 -16
- package/dist/chunk-NFS7RWWE.mjs.map +0 -1
- package/dist/chunk-NKLIE2OI.mjs +0 -1
- package/dist/chunk-NKLIE2OI.mjs.map +0 -1
- package/dist/chunk-NTLX2MPV.mjs +0 -14
- package/dist/chunk-NTLX2MPV.mjs.map +0 -1
- package/dist/chunk-O6UXZR3U.mjs +0 -10
- package/dist/chunk-O6UXZR3U.mjs.map +0 -1
- package/dist/chunk-OG2RLT5U.mjs +0 -10
- package/dist/chunk-OG2RLT5U.mjs.map +0 -1
- package/dist/chunk-OGZMEWPR.mjs +0 -18
- package/dist/chunk-OGZMEWPR.mjs.map +0 -1
- package/dist/chunk-OLORW442.mjs +0 -18
- package/dist/chunk-OLORW442.mjs.map +0 -1
- package/dist/chunk-OLX53VEF.mjs +0 -16
- package/dist/chunk-OLX53VEF.mjs.map +0 -1
- package/dist/chunk-OOKNBU4V.mjs +0 -18
- package/dist/chunk-OOKNBU4V.mjs.map +0 -1
- package/dist/chunk-OXZCMC5I.mjs +0 -13
- package/dist/chunk-OXZCMC5I.mjs.map +0 -1
- package/dist/chunk-PJPGJ2O6.mjs +0 -15
- package/dist/chunk-PJPGJ2O6.mjs.map +0 -1
- package/dist/chunk-PYEYV7BY.mjs +0 -10
- package/dist/chunk-PYEYV7BY.mjs.map +0 -1
- package/dist/chunk-Q47NGNXT.mjs +0 -21
- package/dist/chunk-Q47NGNXT.mjs.map +0 -1
- package/dist/chunk-QOJGMVVR.mjs +0 -17
- package/dist/chunk-QOJGMVVR.mjs.map +0 -1
- package/dist/chunk-QRSJBBFY.mjs +0 -21
- package/dist/chunk-QRSJBBFY.mjs.map +0 -1
- package/dist/chunk-R6GLTTAB.mjs +0 -9
- package/dist/chunk-R6GLTTAB.mjs.map +0 -1
- package/dist/chunk-R6QA7PLZ.mjs +0 -13
- package/dist/chunk-R6QA7PLZ.mjs.map +0 -1
- package/dist/chunk-RTFTLCF3.mjs +0 -14
- package/dist/chunk-RTFTLCF3.mjs.map +0 -1
- package/dist/chunk-SXFMQQ6F.mjs +0 -9
- package/dist/chunk-SXFMQQ6F.mjs.map +0 -1
- package/dist/chunk-SYWMYQYJ.mjs +0 -16
- package/dist/chunk-SYWMYQYJ.mjs.map +0 -1
- package/dist/chunk-U56ZOM7L.mjs +0 -9
- package/dist/chunk-U56ZOM7L.mjs.map +0 -1
- package/dist/chunk-UY76KTPE.mjs +0 -13
- package/dist/chunk-UY76KTPE.mjs.map +0 -1
- package/dist/chunk-VH2PV426.mjs +0 -9
- package/dist/chunk-VH2PV426.mjs.map +0 -1
- package/dist/chunk-VRUTBJYS.mjs +0 -43
- package/dist/chunk-VRUTBJYS.mjs.map +0 -1
- package/dist/chunk-WMM7TZLG.mjs +0 -9
- package/dist/chunk-WMM7TZLG.mjs.map +0 -1
- package/dist/chunk-XGQWTHW6.mjs +0 -34
- package/dist/chunk-XGQWTHW6.mjs.map +0 -1
- package/dist/chunk-XHSIT5DL.mjs +0 -16
- package/dist/chunk-XHSIT5DL.mjs.map +0 -1
- package/dist/chunk-XI7KRD2C.mjs +0 -13
- package/dist/chunk-XI7KRD2C.mjs.map +0 -1
- package/dist/chunk-XPSOKBRZ.mjs +0 -12
- package/dist/chunk-XPSOKBRZ.mjs.map +0 -1
- package/dist/chunk-XT74R35S.mjs +0 -1
- package/dist/chunk-XT74R35S.mjs.map +0 -1
- package/dist/chunk-YOPFSFTD.mjs +0 -13
- package/dist/chunk-YOPFSFTD.mjs.map +0 -1
- package/dist/chunk-YXAOYIRV.mjs +0 -1
- package/dist/chunk-YXAOYIRV.mjs.map +0 -1
- package/dist/chunk-YXD3AQAK.mjs +0 -1
- package/dist/chunk-YXD3AQAK.mjs.map +0 -1
- package/dist/chunk-Z7HWEOQX.mjs +0 -14
- package/dist/chunk-Z7HWEOQX.mjs.map +0 -1
- package/dist/chunk-ZA2XI3OV.mjs +0 -1
- package/dist/chunk-ZA2XI3OV.mjs.map +0 -1
- package/dist/chunk-ZPNX2QDE.mjs +0 -13
- package/dist/chunk-ZPNX2QDE.mjs.map +0 -1
- package/dist/error/AbortError.js +0 -36
- package/dist/error/AbortError.js.map +0 -1
- package/dist/error/TimeoutError.js +0 -36
- package/dist/error/TimeoutError.js.map +0 -1
- package/dist/error/index.d.mts +0 -2
- package/dist/error/index.d.ts +0 -2
- package/dist/error/index.js +0 -48
- package/dist/error/index.js.map +0 -1
- package/dist/error/index.mjs +0 -13
- package/dist/error/index.mjs.map +0 -1
- package/dist/function/after.js +0 -42
- package/dist/function/after.js.map +0 -1
- package/dist/function/debounce.js +0 -56
- package/dist/function/debounce.js.map +0 -1
- package/dist/function/negate.js +0 -33
- package/dist/function/negate.js.map +0 -1
- package/dist/function/noop.js +0 -32
- package/dist/function/noop.js.map +0 -1
- package/dist/function/once.js +0 -43
- package/dist/function/once.js.map +0 -1
- package/dist/function/throttle.js +0 -41
- package/dist/function/throttle.js.map +0 -1
- package/dist/math/clamp.js +0 -36
- package/dist/math/clamp.js.map +0 -1
- package/dist/math/inRange.js +0 -40
- package/dist/math/inRange.js.map +0 -1
- package/dist/math/mean.js +0 -44
- package/dist/math/mean.js.map +0 -1
- package/dist/math/meanBy.js +0 -50
- package/dist/math/meanBy.js.map +0 -1
- package/dist/math/random.js +0 -40
- package/dist/math/random.js.map +0 -1
- package/dist/math/randomInt.js +0 -47
- package/dist/math/randomInt.js.map +0 -1
- package/dist/math/range.js +0 -48
- package/dist/math/range.js.map +0 -1
- package/dist/math/round.js +0 -37
- package/dist/math/round.js.map +0 -1
- package/dist/math/sum.js +0 -37
- package/dist/math/sum.js.map +0 -1
- package/dist/math/sumBy.js +0 -45
- package/dist/math/sumBy.js.map +0 -1
- package/dist/object/clone.js +0 -67
- package/dist/object/clone.js.map +0 -1
- package/dist/object/cloneDeep.js +0 -117
- package/dist/object/cloneDeep.js.map +0 -1
- package/dist/object/flattenObject.js +0 -77
- package/dist/object/flattenObject.js.map +0 -1
- package/dist/object/invert.js +0 -40
- package/dist/object/invert.js.map +0 -1
- package/dist/object/omit.js +0 -37
- package/dist/object/omit.js.map +0 -1
- package/dist/object/omitBy.js +0 -40
- package/dist/object/omitBy.js.map +0 -1
- package/dist/object/pick.js +0 -37
- package/dist/object/pick.js.map +0 -1
- package/dist/object/pickBy.js +0 -40
- package/dist/object/pickBy.js.map +0 -1
- package/dist/predicate/isArrayLike.js +0 -40
- package/dist/predicate/isArrayLike.js.map +0 -1
- package/dist/predicate/isEqual.js +0 -73
- package/dist/predicate/isEqual.js.map +0 -1
- package/dist/predicate/isFunction.js +0 -33
- package/dist/predicate/isFunction.js.map +0 -1
- package/dist/predicate/isLength.js +0 -33
- package/dist/predicate/isLength.js.map +0 -1
- package/dist/predicate/isNil.js +0 -33
- package/dist/predicate/isNil.js.map +0 -1
- package/dist/predicate/isNotNil.js +0 -33
- package/dist/predicate/isNotNil.js.map +0 -1
- package/dist/predicate/isNull.js +0 -33
- package/dist/predicate/isNull.js.map +0 -1
- package/dist/predicate/isPlainObject.js +0 -49
- package/dist/predicate/isPlainObject.js.map +0 -1
- package/dist/predicate/isPrimitive.js +0 -33
- package/dist/predicate/isPrimitive.js.map +0 -1
- package/dist/predicate/isTypedArray.js +0 -33
- package/dist/predicate/isTypedArray.js.map +0 -1
- package/dist/predicate/isUndefined.js +0 -33
- package/dist/predicate/isUndefined.js.map +0 -1
- package/dist/promise/delay.js +0 -56
- package/dist/promise/delay.js.map +0 -1
- package/dist/promise/timeout.d.mts +0 -10
- package/dist/promise/timeout.d.ts +0 -10
- package/dist/promise/timeout.js +0 -70
- package/dist/promise/timeout.js.map +0 -1
- package/dist/promise/withTimeout.js +0 -75
- package/dist/promise/withTimeout.js.map +0 -1
- package/dist/string/camelCase.js +0 -51
- package/dist/string/camelCase.js.map +0 -1
- package/dist/string/capitalize.js +0 -33
- package/dist/string/capitalize.js.map +0 -1
- package/dist/string/kebabCase.js +0 -42
- package/dist/string/kebabCase.js.map +0 -1
- package/dist/string/lowerCase.js +0 -42
- package/dist/string/lowerCase.js.map +0 -1
- package/dist/string/snakeCase.js +0 -42
- package/dist/string/snakeCase.js.map +0 -1
- package/dist/string/startCase.js +0 -53
- package/dist/string/startCase.js.map +0 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Get } from './get.types.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the object.
|
|
7
|
+
* @template K - The type of the key in the object.
|
|
8
|
+
* @template D - The type of the default value.
|
|
9
|
+
*
|
|
10
|
+
* @param {T} object - The object to query.
|
|
11
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
12
|
+
* @returns {T[K]} - Returns the resolved value.
|
|
13
|
+
*/
|
|
14
|
+
declare function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of the object.
|
|
19
|
+
* @template K - The type of the key in the object.
|
|
20
|
+
*
|
|
21
|
+
* @param {T | null | undefined} object - The object to query.
|
|
22
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
23
|
+
* @returns {T[K] | undefined} - Returns the resolved value.
|
|
24
|
+
*/
|
|
25
|
+
declare function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
28
|
+
*
|
|
29
|
+
* @template T - The type of the object.
|
|
30
|
+
* @template K - The type of the key in the object.
|
|
31
|
+
* @template D - The type of the default value.
|
|
32
|
+
*
|
|
33
|
+
* @param {T | null | undefined} object - The object to query.
|
|
34
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
35
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
36
|
+
* @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.
|
|
37
|
+
*/
|
|
38
|
+
declare function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type of the object.
|
|
43
|
+
* @template K1 - The type of the first key in the object.
|
|
44
|
+
* @template K2 - The type of the second key in the object.
|
|
45
|
+
*
|
|
46
|
+
* @param {T} object - The object to query.
|
|
47
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
48
|
+
* @returns {T[K1][K2]} - Returns the resolved value.
|
|
49
|
+
*/
|
|
50
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
53
|
+
*
|
|
54
|
+
* @template T - The type of the object.
|
|
55
|
+
* @template K1 - The type of the first key in the object.
|
|
56
|
+
* @template K2 - The type of the second key in the object.
|
|
57
|
+
*
|
|
58
|
+
* @param {T | null | undefined} object - The object to query.
|
|
59
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
60
|
+
* @returns {T[K1][K2] | undefined} - Returns the resolved value.
|
|
61
|
+
*/
|
|
62
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
65
|
+
*
|
|
66
|
+
* @template T - The type of the object.
|
|
67
|
+
* @template K1 - The type of the first key in the object.
|
|
68
|
+
* @template K2 - The type of the second key in the object.
|
|
69
|
+
* @template D - The type of the default value.
|
|
70
|
+
*
|
|
71
|
+
* @param {T | null | undefined} object - The object to query.
|
|
72
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
73
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
74
|
+
* @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.
|
|
75
|
+
*/
|
|
76
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
79
|
+
*
|
|
80
|
+
* @template T - The type of the object.
|
|
81
|
+
* @template K1 - The type of the first key in the object.
|
|
82
|
+
* @template K2 - The type of the second key in the object.
|
|
83
|
+
* @template K3 - The type of the third key in the object.
|
|
84
|
+
*
|
|
85
|
+
* @param {T} object - The object to query.
|
|
86
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
87
|
+
* @returns {T[K1][K2][K3]} - Returns the resolved value.
|
|
88
|
+
*/
|
|
89
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
92
|
+
*
|
|
93
|
+
* @template T - The type of the object.
|
|
94
|
+
* @template K1 - The type of the first key in the object.
|
|
95
|
+
* @template K2 - The type of the second key in the object.
|
|
96
|
+
* @template K3 - The type of the third key in the object.
|
|
97
|
+
*
|
|
98
|
+
* @param {T | null | undefined} object - The object to query.
|
|
99
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
100
|
+
* @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.
|
|
101
|
+
*/
|
|
102
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
105
|
+
*
|
|
106
|
+
* @template T - The type of the object.
|
|
107
|
+
* @template K1 - The type of the first key in the object.
|
|
108
|
+
* @template K2 - The type of the second key in the object.
|
|
109
|
+
* @template K3 - The type of the third key in the object.
|
|
110
|
+
* @template D - The type of the default value.
|
|
111
|
+
*
|
|
112
|
+
* @param {T | null | undefined} object - The object to query.
|
|
113
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
114
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
115
|
+
* @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.
|
|
116
|
+
*/
|
|
117
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
120
|
+
*
|
|
121
|
+
* @template T - The type of the object.
|
|
122
|
+
* @template K1 - The type of the first key in the object.
|
|
123
|
+
* @template K2 - The type of the second key in the object.
|
|
124
|
+
* @template K3 - The type of the third key in the object.
|
|
125
|
+
* @template K4 - The type of the fourth key in the object.
|
|
126
|
+
*
|
|
127
|
+
* @param {T} object - The object to query.
|
|
128
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
129
|
+
* @returns {T[K1][K2][K3][K4]} - Returns the resolved value.
|
|
130
|
+
*/
|
|
131
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];
|
|
132
|
+
/**
|
|
133
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
134
|
+
*
|
|
135
|
+
* @template T - The type of the object.
|
|
136
|
+
* @template K1 - The type of the first key in the object.
|
|
137
|
+
* @template K2 - The type of the second key in the object.
|
|
138
|
+
* @template K3 - The type of the third key in the object.
|
|
139
|
+
* @template K4 - The type of the fourth key in the object.
|
|
140
|
+
*
|
|
141
|
+
* @param {T | null | undefined} object - The object to query.
|
|
142
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
143
|
+
* @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.
|
|
144
|
+
*/
|
|
145
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
148
|
+
*
|
|
149
|
+
* @template T - The type of the object.
|
|
150
|
+
* @template K1 - The type of the first key in the object.
|
|
151
|
+
* @template K2 - The type of the second key in the object.
|
|
152
|
+
* @template K3 - The type of the third key in the object.
|
|
153
|
+
* @template K4 - The type of the fourth key in the object.
|
|
154
|
+
* @template D - The type of the default value.
|
|
155
|
+
*
|
|
156
|
+
* @param {T | null | undefined} object - The object to query.
|
|
157
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
158
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
159
|
+
* @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.
|
|
160
|
+
*/
|
|
161
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
164
|
+
*
|
|
165
|
+
* @template T - The type of the value.
|
|
166
|
+
*
|
|
167
|
+
* @param {Record<number, T>} object - The object to query.
|
|
168
|
+
* @param {number} path - The path of the property to get.
|
|
169
|
+
* @returns {T} - Returns the resolved value.
|
|
170
|
+
*/
|
|
171
|
+
declare function get<T>(object: Record<number, T>, path: number): T;
|
|
172
|
+
/**
|
|
173
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
174
|
+
*
|
|
175
|
+
* @template T - The type of the value.
|
|
176
|
+
*
|
|
177
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
178
|
+
* @param {number} path - The path of the property to get.
|
|
179
|
+
* @returns {T | undefined} - Returns the resolved value.
|
|
180
|
+
*/
|
|
181
|
+
declare function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
184
|
+
*
|
|
185
|
+
* @template T - The type of the value.
|
|
186
|
+
* @template D - The type of the default value.
|
|
187
|
+
*
|
|
188
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
189
|
+
* @param {number} path - The path of the property to get.
|
|
190
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
191
|
+
* @returns {T | D} - Returns the resolved value.
|
|
192
|
+
*/
|
|
193
|
+
declare function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves the value at a given path from a null or undefined object, returning the default value.
|
|
196
|
+
*
|
|
197
|
+
* @template D - The type of the default value.
|
|
198
|
+
*
|
|
199
|
+
* @param {null | undefined} object - The object to query.
|
|
200
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
201
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
202
|
+
* @returns {D} - Returns the default value.
|
|
203
|
+
*/
|
|
204
|
+
declare function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves the value at a given path from a null or undefined object, returning undefined.
|
|
207
|
+
*
|
|
208
|
+
* @param {null | undefined} object - The object to query.
|
|
209
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
210
|
+
* @returns {undefined} - Returns undefined.
|
|
211
|
+
*/
|
|
212
|
+
declare function get(object: null | undefined, path: PropertyKey): undefined;
|
|
213
|
+
/**
|
|
214
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
215
|
+
*
|
|
216
|
+
* @template T - The type of the object.
|
|
217
|
+
* @template P - The type of the path.
|
|
218
|
+
*
|
|
219
|
+
* @param {T} data - The object to query.
|
|
220
|
+
* @param {P} path - The path of the property to get.
|
|
221
|
+
* @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.
|
|
222
|
+
*/
|
|
223
|
+
declare function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
226
|
+
*
|
|
227
|
+
* @template T - The type of the object.
|
|
228
|
+
* @template P - The type of the path.
|
|
229
|
+
* @template D - The type of the default value.
|
|
230
|
+
*
|
|
231
|
+
* @param {T} data - The object to query.
|
|
232
|
+
* @param {P} path - The path of the property to get.
|
|
233
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
234
|
+
* @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.
|
|
235
|
+
*/
|
|
236
|
+
declare function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
239
|
+
*
|
|
240
|
+
* @param {unknown} object - The object to query.
|
|
241
|
+
* @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
|
|
242
|
+
* @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
|
|
243
|
+
* @returns {any} - Returns the resolved value.
|
|
244
|
+
*/
|
|
245
|
+
declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
|
|
246
|
+
|
|
247
|
+
export { get };
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Get } from './get.types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the object.
|
|
7
|
+
* @template K - The type of the key in the object.
|
|
8
|
+
* @template D - The type of the default value.
|
|
9
|
+
*
|
|
10
|
+
* @param {T} object - The object to query.
|
|
11
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
12
|
+
* @returns {T[K]} - Returns the resolved value.
|
|
13
|
+
*/
|
|
14
|
+
declare function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of the object.
|
|
19
|
+
* @template K - The type of the key in the object.
|
|
20
|
+
*
|
|
21
|
+
* @param {T | null | undefined} object - The object to query.
|
|
22
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
23
|
+
* @returns {T[K] | undefined} - Returns the resolved value.
|
|
24
|
+
*/
|
|
25
|
+
declare function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
28
|
+
*
|
|
29
|
+
* @template T - The type of the object.
|
|
30
|
+
* @template K - The type of the key in the object.
|
|
31
|
+
* @template D - The type of the default value.
|
|
32
|
+
*
|
|
33
|
+
* @param {T | null | undefined} object - The object to query.
|
|
34
|
+
* @param {K | [K]} path - The path of the property to get.
|
|
35
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
36
|
+
* @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.
|
|
37
|
+
*/
|
|
38
|
+
declare function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type of the object.
|
|
43
|
+
* @template K1 - The type of the first key in the object.
|
|
44
|
+
* @template K2 - The type of the second key in the object.
|
|
45
|
+
*
|
|
46
|
+
* @param {T} object - The object to query.
|
|
47
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
48
|
+
* @returns {T[K1][K2]} - Returns the resolved value.
|
|
49
|
+
*/
|
|
50
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
53
|
+
*
|
|
54
|
+
* @template T - The type of the object.
|
|
55
|
+
* @template K1 - The type of the first key in the object.
|
|
56
|
+
* @template K2 - The type of the second key in the object.
|
|
57
|
+
*
|
|
58
|
+
* @param {T | null | undefined} object - The object to query.
|
|
59
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
60
|
+
* @returns {T[K1][K2] | undefined} - Returns the resolved value.
|
|
61
|
+
*/
|
|
62
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
65
|
+
*
|
|
66
|
+
* @template T - The type of the object.
|
|
67
|
+
* @template K1 - The type of the first key in the object.
|
|
68
|
+
* @template K2 - The type of the second key in the object.
|
|
69
|
+
* @template D - The type of the default value.
|
|
70
|
+
*
|
|
71
|
+
* @param {T | null | undefined} object - The object to query.
|
|
72
|
+
* @param {[K1, K2]} path - The path of the property to get.
|
|
73
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
74
|
+
* @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.
|
|
75
|
+
*/
|
|
76
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
79
|
+
*
|
|
80
|
+
* @template T - The type of the object.
|
|
81
|
+
* @template K1 - The type of the first key in the object.
|
|
82
|
+
* @template K2 - The type of the second key in the object.
|
|
83
|
+
* @template K3 - The type of the third key in the object.
|
|
84
|
+
*
|
|
85
|
+
* @param {T} object - The object to query.
|
|
86
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
87
|
+
* @returns {T[K1][K2][K3]} - Returns the resolved value.
|
|
88
|
+
*/
|
|
89
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
92
|
+
*
|
|
93
|
+
* @template T - The type of the object.
|
|
94
|
+
* @template K1 - The type of the first key in the object.
|
|
95
|
+
* @template K2 - The type of the second key in the object.
|
|
96
|
+
* @template K3 - The type of the third key in the object.
|
|
97
|
+
*
|
|
98
|
+
* @param {T | null | undefined} object - The object to query.
|
|
99
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
100
|
+
* @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.
|
|
101
|
+
*/
|
|
102
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
105
|
+
*
|
|
106
|
+
* @template T - The type of the object.
|
|
107
|
+
* @template K1 - The type of the first key in the object.
|
|
108
|
+
* @template K2 - The type of the second key in the object.
|
|
109
|
+
* @template K3 - The type of the third key in the object.
|
|
110
|
+
* @template D - The type of the default value.
|
|
111
|
+
*
|
|
112
|
+
* @param {T | null | undefined} object - The object to query.
|
|
113
|
+
* @param {[K1, K2, K3]} path - The path of the property to get.
|
|
114
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
115
|
+
* @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.
|
|
116
|
+
*/
|
|
117
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
120
|
+
*
|
|
121
|
+
* @template T - The type of the object.
|
|
122
|
+
* @template K1 - The type of the first key in the object.
|
|
123
|
+
* @template K2 - The type of the second key in the object.
|
|
124
|
+
* @template K3 - The type of the third key in the object.
|
|
125
|
+
* @template K4 - The type of the fourth key in the object.
|
|
126
|
+
*
|
|
127
|
+
* @param {T} object - The object to query.
|
|
128
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
129
|
+
* @returns {T[K1][K2][K3][K4]} - Returns the resolved value.
|
|
130
|
+
*/
|
|
131
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];
|
|
132
|
+
/**
|
|
133
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
134
|
+
*
|
|
135
|
+
* @template T - The type of the object.
|
|
136
|
+
* @template K1 - The type of the first key in the object.
|
|
137
|
+
* @template K2 - The type of the second key in the object.
|
|
138
|
+
* @template K3 - The type of the third key in the object.
|
|
139
|
+
* @template K4 - The type of the fourth key in the object.
|
|
140
|
+
*
|
|
141
|
+
* @param {T | null | undefined} object - The object to query.
|
|
142
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
143
|
+
* @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.
|
|
144
|
+
*/
|
|
145
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
148
|
+
*
|
|
149
|
+
* @template T - The type of the object.
|
|
150
|
+
* @template K1 - The type of the first key in the object.
|
|
151
|
+
* @template K2 - The type of the second key in the object.
|
|
152
|
+
* @template K3 - The type of the third key in the object.
|
|
153
|
+
* @template K4 - The type of the fourth key in the object.
|
|
154
|
+
* @template D - The type of the default value.
|
|
155
|
+
*
|
|
156
|
+
* @param {T | null | undefined} object - The object to query.
|
|
157
|
+
* @param {[K1, K2, K3, K4]} path - The path of the property to get.
|
|
158
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
159
|
+
* @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.
|
|
160
|
+
*/
|
|
161
|
+
declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
164
|
+
*
|
|
165
|
+
* @template T - The type of the value.
|
|
166
|
+
*
|
|
167
|
+
* @param {Record<number, T>} object - The object to query.
|
|
168
|
+
* @param {number} path - The path of the property to get.
|
|
169
|
+
* @returns {T} - Returns the resolved value.
|
|
170
|
+
*/
|
|
171
|
+
declare function get<T>(object: Record<number, T>, path: number): T;
|
|
172
|
+
/**
|
|
173
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
174
|
+
*
|
|
175
|
+
* @template T - The type of the value.
|
|
176
|
+
*
|
|
177
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
178
|
+
* @param {number} path - The path of the property to get.
|
|
179
|
+
* @returns {T | undefined} - Returns the resolved value.
|
|
180
|
+
*/
|
|
181
|
+
declare function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
184
|
+
*
|
|
185
|
+
* @template T - The type of the value.
|
|
186
|
+
* @template D - The type of the default value.
|
|
187
|
+
*
|
|
188
|
+
* @param {Record<number, T> | null | undefined} object - The object to query.
|
|
189
|
+
* @param {number} path - The path of the property to get.
|
|
190
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
191
|
+
* @returns {T | D} - Returns the resolved value.
|
|
192
|
+
*/
|
|
193
|
+
declare function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves the value at a given path from a null or undefined object, returning the default value.
|
|
196
|
+
*
|
|
197
|
+
* @template D - The type of the default value.
|
|
198
|
+
*
|
|
199
|
+
* @param {null | undefined} object - The object to query.
|
|
200
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
201
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
202
|
+
* @returns {D} - Returns the default value.
|
|
203
|
+
*/
|
|
204
|
+
declare function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves the value at a given path from a null or undefined object, returning undefined.
|
|
207
|
+
*
|
|
208
|
+
* @param {null | undefined} object - The object to query.
|
|
209
|
+
* @param {PropertyKey} path - The path of the property to get.
|
|
210
|
+
* @returns {undefined} - Returns undefined.
|
|
211
|
+
*/
|
|
212
|
+
declare function get(object: null | undefined, path: PropertyKey): undefined;
|
|
213
|
+
/**
|
|
214
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
215
|
+
*
|
|
216
|
+
* @template T - The type of the object.
|
|
217
|
+
* @template P - The type of the path.
|
|
218
|
+
*
|
|
219
|
+
* @param {T} data - The object to query.
|
|
220
|
+
* @param {P} path - The path of the property to get.
|
|
221
|
+
* @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.
|
|
222
|
+
*/
|
|
223
|
+
declare function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
226
|
+
*
|
|
227
|
+
* @template T - The type of the object.
|
|
228
|
+
* @template P - The type of the path.
|
|
229
|
+
* @template D - The type of the default value.
|
|
230
|
+
*
|
|
231
|
+
* @param {T} data - The object to query.
|
|
232
|
+
* @param {P} path - The path of the property to get.
|
|
233
|
+
* @param {D} defaultValue - The value returned if the resolved value is undefined.
|
|
234
|
+
* @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.
|
|
235
|
+
*/
|
|
236
|
+
declare function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
239
|
+
*
|
|
240
|
+
* @param {unknown} object - The object to query.
|
|
241
|
+
* @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
|
|
242
|
+
* @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
|
|
243
|
+
* @returns {any} - Returns the resolved value.
|
|
244
|
+
*/
|
|
245
|
+
declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
|
|
246
|
+
|
|
247
|
+
export { get };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isDeepKey } from '../_internal/isDeepKey.mjs';
|
|
2
|
+
import { toPath } from '../_internal/toPath.mjs';
|
|
3
|
+
|
|
4
|
+
function get(object, path, defaultValue) {
|
|
5
|
+
let resolvedPath;
|
|
6
|
+
if (Array.isArray(path)) {
|
|
7
|
+
resolvedPath = path;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {
|
|
10
|
+
resolvedPath = toPath(path);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
resolvedPath = [path];
|
|
14
|
+
}
|
|
15
|
+
if (resolvedPath.length === 0) {
|
|
16
|
+
return defaultValue;
|
|
17
|
+
}
|
|
18
|
+
let current = object;
|
|
19
|
+
let index;
|
|
20
|
+
for (index = 0; index < resolvedPath.length && current != null; index++) {
|
|
21
|
+
let key = resolvedPath[index];
|
|
22
|
+
if (Object.is(key.valueOf(), -0)) {
|
|
23
|
+
key = '-0';
|
|
24
|
+
}
|
|
25
|
+
current = current[key];
|
|
26
|
+
}
|
|
27
|
+
if (current === null && index === resolvedPath.length) {
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
return current ?? defaultValue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { get };
|
|
34
|
+
//# sourceMappingURL=get.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.mjs","sources":["../../../src/compat/object/get.ts"],"sourcesContent":["import { isDeepKey } from \"../_internal/isDeepKey.ts\";\nimport { toPath } from \"../_internal/toPath.ts\";\nimport type { Get } from \"./get.types.ts\";\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K]} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * @template D - The type of the default value.\n * \n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.\n */\nexport function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T>} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T | undefined} - Returns the resolved value.\n */\nexport function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the value.\n * @template D - The type of the default value.\n * \n * @param {Record<number, T> | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {T | D} - Returns the resolved value.\n */\nexport function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n * \n * @template D - The type of the default value.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {D} - Returns the default value.\n */\nexport function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n * \n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @returns {undefined} - Returns undefined.\n */\nexport function get(object: null | undefined, path: PropertyKey): undefined;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.\n */\nexport function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @template T - The type of the object.\n * @template P - The type of the path.\n * @template D - The type of the default value.\n * \n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.\n */\nexport function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n * \n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;\nexport function get(object: any, path: PropertyKey | readonly PropertyKey[], defaultValue?: any): any {\n let resolvedPath;\n\n if (Array.isArray(path)) {\n resolvedPath = path;\n } else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {\n resolvedPath = toPath(path);\n } else {\n resolvedPath = [path];\n }\n\n if (resolvedPath.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n let index;\n\n for (index = 0; index < resolvedPath.length && current != null; index++) {\n let key = resolvedPath[index];\n\n if (Object.is(key.valueOf(), -0)) {\n key = '-0';\n }\n\n current = current[key];\n }\n\n if (current === null && index === resolvedPath.length) {\n return current;\n }\n\n return current ?? defaultValue;\n}"],"names":[],"mappings":";;;SAuPgB,GAAG,CAAC,MAAW,EAAE,IAA0C,EAAE,YAAkB,EAAA;AAC7F,IAAA,IAAI,YAAY,CAAC;AAEjB,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,YAAY,GAAG,IAAI,CAAC;KACrB;AAAM,SAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE;AAChF,QAAA,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;KAC7B;SAAM;AACL,QAAA,YAAY,GAAG,CAAC,IAAI,CAAC,CAAC;KACvB;AAED,IAAA,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,QAAA,OAAO,YAAY,CAAC;KACrB;IAED,IAAI,OAAO,GAAG,MAAM,CAAC;AACrB,IAAA,IAAI,KAAK,CAAC;AAEV,IAAA,KAAK,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,MAAM,IAAI,OAAO,IAAI,IAAI,EAAE,KAAK,EAAE,EAAE;AACvE,QAAA,IAAI,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAE9B,QAAA,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE;YAChC,GAAG,GAAG,IAAI,CAAC;SACZ;AAED,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;KACxB;IAED,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,EAAE;AACrD,QAAA,OAAO,OAAO,CAAC;KAChB;IAED,OAAO,OAAO,IAAI,YAAY,CAAC;AACjC;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the definition of `@types/lodash`.
|
|
3
|
+
*/
|
|
4
|
+
type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? 'length' extends keyof T ? number extends T['length'] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
|
|
5
|
+
type FieldWithPossiblyUndefined<T, Key> = Get<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
6
|
+
type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
7
|
+
type Get<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
|
|
8
|
+
|
|
9
|
+
export type { Get };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See the definition of `@types/lodash`.
|
|
3
|
+
*/
|
|
4
|
+
type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? 'length' extends keyof T ? number extends T['length'] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
|
|
5
|
+
type FieldWithPossiblyUndefined<T, Key> = Get<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
6
|
+
type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
|
|
7
|
+
type Get<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
|
|
8
|
+
|
|
9
|
+
export type { Get };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param {Settable} obj - The object to modify.
|
|
6
|
+
* @param {Path} path - The path of the property to set.
|
|
7
|
+
* @param {any} value - The value to set.
|
|
8
|
+
* @returns {T} - The modified object.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Set a value in a nested object
|
|
12
|
+
* const obj = { a: { b: { c: 3 } } };
|
|
13
|
+
* set(obj, 'a.b.c', 4);
|
|
14
|
+
* console.log(obj.a.b.c); // 4
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Set a value in an array
|
|
18
|
+
* const arr = [1, 2, 3];
|
|
19
|
+
* set(arr, 1, 4);
|
|
20
|
+
* console.log(arr[1]); // 4
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Create non-existent path and set value
|
|
24
|
+
* const obj = {};
|
|
25
|
+
* set(obj, 'a.b.c', 4);
|
|
26
|
+
* console.log(obj); // { a: { b: { c: 4 } } }
|
|
27
|
+
*/
|
|
28
|
+
declare function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;
|
|
29
|
+
|
|
30
|
+
export { set };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param {Settable} obj - The object to modify.
|
|
6
|
+
* @param {Path} path - The path of the property to set.
|
|
7
|
+
* @param {any} value - The value to set.
|
|
8
|
+
* @returns {T} - The modified object.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Set a value in a nested object
|
|
12
|
+
* const obj = { a: { b: { c: 3 } } };
|
|
13
|
+
* set(obj, 'a.b.c', 4);
|
|
14
|
+
* console.log(obj.a.b.c); // 4
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Set a value in an array
|
|
18
|
+
* const arr = [1, 2, 3];
|
|
19
|
+
* set(arr, 1, 4);
|
|
20
|
+
* console.log(arr[1]); // 4
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Create non-existent path and set value
|
|
24
|
+
* const obj = {};
|
|
25
|
+
* set(obj, 'a.b.c', 4);
|
|
26
|
+
* console.log(obj); // { a: { b: { c: 4 } } }
|
|
27
|
+
*/
|
|
28
|
+
declare function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;
|
|
29
|
+
|
|
30
|
+
export { set };
|