es-toolkit 1.50.0 → 1.51.0-dev.2069
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/CHANGELOG.md +82 -0
- package/NOTICE +39 -0
- package/README.md +2 -2
- package/bigint.d.ts +1 -0
- package/bigint.js +1 -0
- package/dist/_internal/NonPlainObject.d.mts +8 -0
- package/dist/_internal/NonPlainObject.d.ts +8 -0
- package/dist/_internal/bigIntRangeLength.js +19 -0
- package/dist/_internal/bigIntRangeLength.mjs +19 -0
- package/dist/_internal/isMergeableValue.js +17 -0
- package/dist/_internal/isMergeableValue.mjs +17 -0
- package/dist/_internal/isUnsafeProperty.js +7 -4
- package/dist/_internal/isUnsafeProperty.mjs +7 -4
- package/dist/_internal/isUnsafeToWriteProperty.js +22 -0
- package/dist/_internal/isUnsafeToWriteProperty.mjs +22 -0
- package/dist/array/at.d.mts +1 -1
- package/dist/array/at.d.ts +1 -1
- package/dist/array/filterAsync.js +1 -1
- package/dist/array/filterAsync.mjs +1 -1
- package/dist/array/flatMapAsync.js +1 -1
- package/dist/array/flatMapAsync.mjs +1 -1
- package/dist/array/forEachAsync.js +1 -1
- package/dist/array/forEachAsync.mjs +1 -1
- package/dist/array/index.js +1 -1
- package/dist/array/index.mjs +1 -1
- package/dist/array/limitAsync.d.mts +4 -28
- package/dist/array/limitAsync.d.ts +4 -28
- package/dist/array/limitAsync.js +2 -39
- package/dist/array/limitAsync.mjs +3 -39
- package/dist/array/mapAsync.js +1 -1
- package/dist/array/mapAsync.mjs +1 -1
- package/dist/array/orderBy.d.mts +1 -1
- package/dist/array/orderBy.d.ts +1 -1
- package/dist/array/pullAt.d.mts +1 -1
- package/dist/array/pullAt.d.ts +1 -1
- package/dist/array/pullAt.js +1 -1
- package/dist/array/pullAt.mjs +1 -1
- package/dist/array/sortBy.d.mts +1 -1
- package/dist/array/sortBy.d.ts +1 -1
- package/dist/array/unzip.d.mts +3 -0
- package/dist/array/unzip.d.ts +3 -0
- package/dist/array/unzip.js +3 -0
- package/dist/array/unzip.mjs +3 -0
- package/dist/bigint/clamp.d.mts +37 -0
- package/dist/bigint/clamp.d.ts +37 -0
- package/dist/bigint/clamp.js +16 -0
- package/dist/bigint/clamp.mjs +16 -0
- package/dist/bigint/inRange.d.mts +37 -0
- package/dist/bigint/inRange.d.ts +37 -0
- package/dist/bigint/inRange.js +20 -0
- package/dist/bigint/inRange.mjs +20 -0
- package/dist/bigint/index.d.mts +14 -0
- package/dist/bigint/index.d.ts +14 -0
- package/dist/bigint/index.js +27 -0
- package/dist/bigint/index.mjs +14 -0
- package/dist/bigint/max.d.mts +21 -0
- package/dist/bigint/max.d.ts +21 -0
- package/dist/bigint/max.js +26 -0
- package/dist/bigint/max.mjs +26 -0
- package/dist/bigint/maxBy.d.mts +21 -0
- package/dist/bigint/maxBy.d.ts +21 -0
- package/dist/bigint/maxBy.js +34 -0
- package/dist/bigint/maxBy.mjs +34 -0
- package/dist/bigint/median.d.mts +22 -0
- package/dist/bigint/median.d.ts +22 -0
- package/dist/bigint/median.js +28 -0
- package/dist/bigint/median.mjs +28 -0
- package/dist/bigint/medianBy.d.mts +21 -0
- package/dist/bigint/medianBy.d.ts +21 -0
- package/dist/bigint/medianBy.js +24 -0
- package/dist/bigint/medianBy.mjs +24 -0
- package/dist/bigint/min.d.mts +18 -0
- package/dist/bigint/min.d.ts +18 -0
- package/dist/bigint/min.js +23 -0
- package/dist/bigint/min.mjs +23 -0
- package/dist/bigint/minBy.d.mts +21 -0
- package/dist/bigint/minBy.d.ts +21 -0
- package/dist/bigint/minBy.js +34 -0
- package/dist/bigint/minBy.mjs +34 -0
- package/dist/bigint/percentile.d.mts +23 -0
- package/dist/bigint/percentile.d.ts +23 -0
- package/dist/bigint/percentile.js +31 -0
- package/dist/bigint/percentile.mjs +31 -0
- package/dist/bigint/range.d.mts +45 -0
- package/dist/bigint/range.d.ts +45 -0
- package/dist/bigint/range.js +24 -0
- package/dist/bigint/range.mjs +24 -0
- package/dist/bigint/rangeRight.d.mts +43 -0
- package/dist/bigint/rangeRight.d.ts +43 -0
- package/dist/bigint/rangeRight.js +25 -0
- package/dist/bigint/rangeRight.mjs +25 -0
- package/dist/bigint/sum.d.mts +18 -0
- package/dist/bigint/sum.d.ts +18 -0
- package/dist/bigint/sum.js +22 -0
- package/dist/bigint/sum.mjs +22 -0
- package/dist/bigint/sumBy.d.mts +20 -0
- package/dist/bigint/sumBy.d.ts +20 -0
- package/dist/bigint/sumBy.js +24 -0
- package/dist/bigint/sumBy.mjs +24 -0
- package/dist/browser.global.js +6 -3
- package/dist/compat/_internal/normalizeZero.js +13 -0
- package/dist/compat/_internal/normalizeZero.mjs +13 -0
- package/dist/compat/_internal/toKey.js +1 -1
- package/dist/compat/_internal/toKey.mjs +1 -1
- package/dist/compat/_internal/unicodeSize.js +45 -0
- package/dist/compat/_internal/unicodeSize.mjs +45 -0
- package/dist/compat/array/chunk.js +1 -0
- package/dist/compat/array/chunk.mjs +1 -0
- package/dist/compat/array/difference.js +2 -1
- package/dist/compat/array/difference.mjs +2 -1
- package/dist/compat/array/differenceBy.js +3 -2
- package/dist/compat/array/differenceBy.mjs +3 -2
- package/dist/compat/array/drop.d.mts +1 -1
- package/dist/compat/array/drop.d.ts +1 -1
- package/dist/compat/array/dropRight.d.mts +2 -3
- package/dist/compat/array/dropRight.d.ts +2 -3
- package/dist/compat/array/dropRight.js +4 -4
- package/dist/compat/array/dropRight.mjs +4 -4
- package/dist/compat/array/every.js +9 -9
- package/dist/compat/array/every.mjs +9 -9
- package/dist/compat/array/fill.js +8 -2
- package/dist/compat/array/fill.mjs +8 -2
- package/dist/compat/array/find.js +14 -13
- package/dist/compat/array/find.mjs +14 -13
- package/dist/compat/array/findIndex.js +3 -19
- package/dist/compat/array/findIndex.mjs +3 -19
- package/dist/compat/array/findLast.js +3 -3
- package/dist/compat/array/findLast.mjs +3 -3
- package/dist/compat/array/flatMap.js +3 -8
- package/dist/compat/array/flatMap.mjs +3 -7
- package/dist/compat/array/flatMapDepth.js +1 -1
- package/dist/compat/array/flatMapDepth.mjs +1 -1
- package/dist/compat/array/forEach.js +1 -1
- package/dist/compat/array/forEach.mjs +1 -1
- package/dist/compat/array/includes.js +13 -13
- package/dist/compat/array/includes.mjs +13 -13
- package/dist/compat/array/indexOf.js +2 -1
- package/dist/compat/array/indexOf.mjs +2 -1
- package/dist/compat/array/intersection.js +3 -2
- package/dist/compat/array/intersection.mjs +3 -2
- package/dist/compat/array/intersectionBy.js +7 -11
- package/dist/compat/array/intersectionBy.mjs +7 -11
- package/dist/compat/array/intersectionWith.js +6 -18
- package/dist/compat/array/intersectionWith.mjs +6 -18
- package/dist/compat/array/last.js +1 -1
- package/dist/compat/array/last.mjs +1 -1
- package/dist/compat/array/lastIndexOf.js +3 -1
- package/dist/compat/array/lastIndexOf.mjs +3 -1
- package/dist/compat/array/map.js +3 -3
- package/dist/compat/array/map.mjs +3 -3
- package/dist/compat/array/orderBy.js +8 -6
- package/dist/compat/array/orderBy.mjs +8 -6
- package/dist/compat/array/partition.js +6 -6
- package/dist/compat/array/partition.mjs +6 -6
- package/dist/compat/array/pull.js +1 -1
- package/dist/compat/array/pull.mjs +1 -1
- package/dist/compat/array/pullAll.js +2 -0
- package/dist/compat/array/pullAll.mjs +2 -0
- package/dist/compat/array/remove.js +8 -4
- package/dist/compat/array/remove.mjs +8 -4
- package/dist/compat/array/reverse.js +1 -1
- package/dist/compat/array/reverse.mjs +1 -1
- package/dist/compat/array/sampleSize.js +2 -1
- package/dist/compat/array/sampleSize.mjs +2 -1
- package/dist/compat/array/size.js +2 -1
- package/dist/compat/array/size.mjs +2 -1
- package/dist/compat/array/some.js +2 -1
- package/dist/compat/array/some.mjs +2 -1
- package/dist/compat/array/takeRightWhile.js +2 -2
- package/dist/compat/array/takeRightWhile.mjs +2 -2
- package/dist/compat/array/takeWhile.js +2 -2
- package/dist/compat/array/takeWhile.mjs +2 -2
- package/dist/compat/array/unionBy.js +2 -1
- package/dist/compat/array/unionBy.mjs +2 -1
- package/dist/compat/array/uniqBy.js +4 -3
- package/dist/compat/array/uniqBy.mjs +4 -3
- package/dist/compat/array/unzip.d.mts +3 -0
- package/dist/compat/array/unzip.d.ts +3 -0
- package/dist/compat/array/unzip.js +3 -0
- package/dist/compat/array/unzip.mjs +3 -0
- package/dist/compat/array/unzipWith.js +1 -1
- package/dist/compat/array/unzipWith.mjs +1 -1
- package/dist/compat/array/zipObject.js +2 -0
- package/dist/compat/array/zipObject.mjs +2 -0
- package/dist/compat/compat.d.mts +3 -3
- package/dist/compat/compat.d.ts +3 -3
- package/dist/compat/compat.js +8 -4
- package/dist/compat/compat.mjs +8 -4
- package/dist/compat/function/curry.d.mts +1 -1
- package/dist/compat/function/curry.d.ts +1 -1
- package/dist/compat/function/debounce.js +1 -1
- package/dist/compat/function/debounce.mjs +1 -1
- package/dist/compat/function/flowRight.d.mts +1 -1
- package/dist/compat/function/flowRight.d.ts +1 -1
- package/dist/compat/function/partial.d.mts +1 -1
- package/dist/compat/function/partial.d.ts +1 -1
- package/dist/compat/function/rest.d.mts +1 -1
- package/dist/compat/function/rest.d.ts +1 -1
- package/dist/compat/function/rest.js +1 -1
- package/dist/compat/function/rest.mjs +1 -1
- package/dist/compat/index.d.mts +3 -3
- package/dist/compat/index.d.ts +3 -3
- package/dist/compat/index.js +6 -4
- package/dist/compat/index.mjs +5 -5
- package/dist/compat/math/maxBy.js +1 -1
- package/dist/compat/math/maxBy.mjs +1 -1
- package/dist/compat/math/meanBy.d.mts +4 -0
- package/dist/compat/math/meanBy.d.ts +4 -0
- package/dist/compat/math/meanBy.js +8 -3
- package/dist/compat/math/meanBy.mjs +8 -3
- package/dist/compat/math/minBy.js +1 -1
- package/dist/compat/math/minBy.mjs +1 -1
- package/dist/compat/object/cloneDeep.d.mts +5 -5
- package/dist/compat/object/cloneDeep.d.ts +5 -5
- package/dist/compat/object/cloneDeep.js +5 -5
- package/dist/compat/object/cloneDeep.mjs +5 -5
- package/dist/compat/object/cloneDeepWith.js +3 -1
- package/dist/compat/object/cloneDeepWith.mjs +3 -1
- package/dist/compat/object/cloneWith.d.mts +1 -1
- package/dist/compat/object/cloneWith.d.ts +1 -1
- package/dist/compat/object/cloneWith.js +1 -1
- package/dist/compat/object/cloneWith.mjs +1 -1
- package/dist/compat/object/entries.d.mts +1 -0
- package/dist/compat/object/entries.d.ts +1 -0
- package/dist/compat/object/entries.js +1 -0
- package/dist/compat/object/entries.mjs +1 -0
- package/dist/compat/object/entriesIn.d.mts +1 -0
- package/dist/compat/object/entriesIn.d.ts +1 -0
- package/dist/compat/object/entriesIn.js +1 -0
- package/dist/compat/object/entriesIn.mjs +1 -0
- package/dist/compat/object/omit.js +5 -5
- package/dist/compat/object/omit.mjs +5 -5
- package/dist/compat/object/transform.js +1 -1
- package/dist/compat/object/transform.mjs +1 -1
- package/dist/compat/object/updateWith.js +2 -2
- package/dist/compat/object/updateWith.mjs +2 -2
- package/dist/compat/predicate/isMatchWith.js +14 -5
- package/dist/compat/predicate/isMatchWith.mjs +14 -5
- package/dist/compat/string/template.js +2 -1
- package/dist/compat/string/template.mjs +2 -1
- package/dist/compat/string/words.js +17 -13
- package/dist/compat/string/words.mjs +17 -13
- package/dist/compat/util/iteratee.js +1 -3
- package/dist/compat/util/iteratee.mjs +1 -3
- package/dist/compat/util/toArray.d.mts +5 -5
- package/dist/compat/util/toArray.d.ts +5 -5
- package/dist/compat/util/toArray.js +9 -5
- package/dist/compat/util/toArray.mjs +9 -5
- package/dist/compat/util/toPath.js +11 -3
- package/dist/compat/util/toPath.mjs +11 -3
- package/dist/compat/util/toString.js +4 -1
- package/dist/compat/util/toString.mjs +4 -1
- package/dist/fp/array/at.d.mts +1 -1
- package/dist/fp/array/at.d.ts +1 -1
- package/dist/fp/array/orderBy.d.mts +1 -1
- package/dist/fp/array/orderBy.d.ts +1 -1
- package/dist/fp/array/sortBy.d.mts +1 -1
- package/dist/fp/array/sortBy.d.ts +1 -1
- package/dist/fp/array/unzip.d.mts +3 -0
- package/dist/fp/array/unzip.d.ts +3 -0
- package/dist/fp/array/unzip.js +3 -0
- package/dist/fp/array/unzip.mjs +3 -0
- package/dist/fp/iterator/chunk.d.mts +19 -0
- package/dist/fp/iterator/chunk.d.ts +19 -0
- package/dist/fp/iterator/chunk.js +24 -0
- package/dist/fp/iterator/chunk.mjs +24 -0
- package/dist/fp/iterator/count.d.mts +20 -0
- package/dist/fp/iterator/count.d.ts +20 -0
- package/dist/fp/iterator/count.js +25 -0
- package/dist/fp/iterator/count.mjs +25 -0
- package/dist/fp/iterator/drop.d.mts +20 -0
- package/dist/fp/iterator/drop.d.ts +20 -0
- package/dist/fp/iterator/drop.js +24 -0
- package/dist/fp/iterator/drop.mjs +24 -0
- package/dist/fp/iterator/dropWhile.d.mts +18 -0
- package/dist/fp/iterator/dropWhile.d.ts +18 -0
- package/dist/fp/iterator/dropWhile.js +23 -0
- package/dist/fp/iterator/dropWhile.mjs +23 -0
- package/dist/fp/iterator/every.d.mts +20 -0
- package/dist/fp/iterator/every.d.ts +20 -0
- package/dist/fp/iterator/every.js +24 -0
- package/dist/fp/iterator/every.mjs +24 -0
- package/dist/fp/iterator/filter.d.mts +37 -0
- package/dist/fp/iterator/filter.d.ts +37 -0
- package/dist/fp/iterator/filter.js +8 -0
- package/dist/fp/iterator/filter.mjs +8 -0
- package/dist/fp/iterator/find.d.mts +20 -0
- package/dist/fp/iterator/find.d.ts +20 -0
- package/dist/fp/iterator/find.js +24 -0
- package/dist/fp/iterator/find.mjs +24 -0
- package/dist/fp/iterator/flatMap.d.mts +20 -0
- package/dist/fp/iterator/flatMap.d.ts +20 -0
- package/dist/fp/iterator/flatMap.js +24 -0
- package/dist/fp/iterator/flatMap.mjs +24 -0
- package/dist/fp/iterator/forEach.d.mts +22 -0
- package/dist/fp/iterator/forEach.d.ts +22 -0
- package/dist/fp/iterator/forEach.js +26 -0
- package/dist/fp/iterator/forEach.mjs +26 -0
- package/dist/fp/iterator/head.d.mts +19 -0
- package/dist/fp/iterator/head.d.ts +19 -0
- package/dist/fp/iterator/head.js +24 -0
- package/dist/fp/iterator/head.mjs +24 -0
- package/dist/fp/iterator/index.d.mts +21 -0
- package/dist/fp/iterator/index.d.ts +21 -0
- package/dist/fp/iterator/index.js +41 -0
- package/dist/fp/iterator/index.mjs +21 -0
- package/dist/fp/iterator/map.d.mts +20 -0
- package/dist/fp/iterator/map.d.ts +20 -0
- package/dist/fp/iterator/map.js +24 -0
- package/dist/fp/iterator/map.mjs +24 -0
- package/dist/fp/iterator/partition.d.mts +22 -0
- package/dist/fp/iterator/partition.d.ts +22 -0
- package/dist/fp/iterator/partition.js +27 -0
- package/dist/fp/iterator/partition.mjs +27 -0
- package/dist/fp/iterator/reduce.d.mts +24 -0
- package/dist/fp/iterator/reduce.d.ts +24 -0
- package/dist/fp/iterator/reduce.js +28 -0
- package/dist/fp/iterator/reduce.mjs +28 -0
- package/dist/fp/iterator/scan.d.mts +21 -0
- package/dist/fp/iterator/scan.d.ts +21 -0
- package/dist/fp/iterator/scan.js +26 -0
- package/dist/fp/iterator/scan.mjs +26 -0
- package/dist/fp/iterator/some.d.mts +20 -0
- package/dist/fp/iterator/some.d.ts +20 -0
- package/dist/fp/iterator/some.js +24 -0
- package/dist/fp/iterator/some.mjs +24 -0
- package/dist/fp/iterator/take.d.mts +21 -0
- package/dist/fp/iterator/take.d.ts +21 -0
- package/dist/fp/iterator/take.js +25 -0
- package/dist/fp/iterator/take.mjs +25 -0
- package/dist/fp/iterator/takeWhile.d.mts +19 -0
- package/dist/fp/iterator/takeWhile.d.ts +19 -0
- package/dist/fp/iterator/takeWhile.js +24 -0
- package/dist/fp/iterator/takeWhile.mjs +24 -0
- package/dist/fp/iterator/toArray.d.mts +21 -0
- package/dist/fp/iterator/toArray.d.ts +21 -0
- package/dist/fp/iterator/toArray.js +25 -0
- package/dist/fp/iterator/toArray.mjs +25 -0
- package/dist/fp/iterator/uniqBy.d.mts +20 -0
- package/dist/fp/iterator/uniqBy.d.ts +20 -0
- package/dist/fp/iterator/uniqBy.js +25 -0
- package/dist/fp/iterator/uniqBy.mjs +25 -0
- package/dist/fp/iterator/zip.d.mts +20 -0
- package/dist/fp/iterator/zip.d.ts +20 -0
- package/dist/fp/iterator/zip.js +25 -0
- package/dist/fp/iterator/zip.mjs +25 -0
- package/dist/function/memoize.d.mts +3 -2
- package/dist/function/memoize.d.ts +3 -2
- package/dist/function/memoize.js +3 -2
- package/dist/function/memoize.mjs +3 -2
- package/dist/function/partial.d.mts +2 -2
- package/dist/function/partial.d.ts +2 -2
- package/dist/function/partialRight.d.mts +5 -5
- package/dist/function/partialRight.d.ts +5 -5
- package/dist/function/rest.d.mts +1 -1
- package/dist/function/rest.d.ts +1 -1
- package/dist/function/rest.js +1 -1
- package/dist/function/rest.mjs +1 -1
- package/dist/function/retry.d.mts +7 -4
- package/dist/function/retry.d.ts +7 -4
- package/dist/function/retry.js +4 -2
- package/dist/function/retry.mjs +1 -1
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +18 -4
- package/dist/index.mjs +12 -5
- package/dist/iterator/_internal/iterator.js +74 -0
- package/dist/iterator/_internal/iterator.mjs +74 -0
- package/dist/iterator/chunk.d.mts +21 -0
- package/dist/iterator/chunk.d.ts +21 -0
- package/dist/iterator/chunk.js +40 -0
- package/dist/iterator/chunk.mjs +40 -0
- package/dist/iterator/count.d.mts +18 -0
- package/dist/iterator/count.d.ts +18 -0
- package/dist/iterator/count.js +26 -0
- package/dist/iterator/count.mjs +26 -0
- package/dist/iterator/dropWhile.d.mts +20 -0
- package/dist/iterator/dropWhile.d.ts +20 -0
- package/dist/iterator/dropWhile.js +52 -0
- package/dist/iterator/dropWhile.mjs +52 -0
- package/dist/iterator/head.d.mts +21 -0
- package/dist/iterator/head.d.ts +21 -0
- package/dist/iterator/head.js +26 -0
- package/dist/iterator/head.mjs +26 -0
- package/dist/iterator/index.d.mts +12 -0
- package/dist/iterator/index.d.ts +12 -0
- package/dist/iterator/index.js +23 -0
- package/dist/iterator/index.mjs +12 -0
- package/dist/iterator/iterate.d.mts +20 -0
- package/dist/iterator/iterate.d.ts +20 -0
- package/dist/iterator/iterate.js +32 -0
- package/dist/iterator/iterate.mjs +32 -0
- package/dist/iterator/partition.d.mts +18 -0
- package/dist/iterator/partition.d.ts +18 -0
- package/dist/iterator/partition.js +36 -0
- package/dist/iterator/partition.mjs +36 -0
- package/dist/iterator/range.d.mts +42 -0
- package/dist/iterator/range.d.ts +42 -0
- package/dist/iterator/range.js +25 -0
- package/dist/iterator/range.mjs +25 -0
- package/dist/iterator/scan.d.mts +23 -0
- package/dist/iterator/scan.d.ts +23 -0
- package/dist/iterator/scan.js +47 -0
- package/dist/iterator/scan.mjs +47 -0
- package/dist/iterator/takeWhile.d.mts +20 -0
- package/dist/iterator/takeWhile.d.ts +20 -0
- package/dist/iterator/takeWhile.js +34 -0
- package/dist/iterator/takeWhile.mjs +34 -0
- package/dist/iterator/uniqBy.d.mts +22 -0
- package/dist/iterator/uniqBy.d.ts +22 -0
- package/dist/iterator/uniqBy.js +43 -0
- package/dist/iterator/uniqBy.mjs +43 -0
- package/dist/iterator/zip.d.mts +23 -0
- package/dist/iterator/zip.d.ts +23 -0
- package/dist/iterator/zip.js +45 -0
- package/dist/iterator/zip.mjs +45 -0
- package/dist/object/cloneDeepWith.d.mts +3 -1
- package/dist/object/cloneDeepWith.d.ts +3 -1
- package/dist/object/cloneDeepWith.js +3 -1
- package/dist/object/cloneDeepWith.mjs +3 -1
- package/dist/object/deepFreeze.d.mts +20 -0
- package/dist/object/deepFreeze.d.ts +20 -0
- package/dist/object/deepFreeze.js +29 -0
- package/dist/object/deepFreeze.mjs +29 -0
- package/dist/object/flattenObject.d.mts +16 -1
- package/dist/object/flattenObject.d.ts +16 -1
- package/dist/object/flattenObject.js +15 -6
- package/dist/object/flattenObject.mjs +15 -6
- package/dist/object/index.d.mts +7 -1
- package/dist/object/index.d.ts +7 -1
- package/dist/object/index.js +12 -0
- package/dist/object/index.mjs +7 -1
- package/dist/object/mapKeysAsync.d.mts +25 -0
- package/dist/object/mapKeysAsync.d.ts +25 -0
- package/dist/object/mapKeysAsync.js +32 -0
- package/dist/object/mapKeysAsync.mjs +32 -0
- package/dist/object/mapValuesAsync.d.mts +26 -0
- package/dist/object/mapValuesAsync.d.ts +26 -0
- package/dist/object/mapValuesAsync.js +32 -0
- package/dist/object/mapValuesAsync.mjs +32 -0
- package/dist/object/merge.js +2 -4
- package/dist/object/merge.mjs +1 -3
- package/dist/object/mergeWith.js +4 -4
- package/dist/object/mergeWith.mjs +4 -4
- package/dist/object/toCamelCaseKeys.d.mts +2 -6
- package/dist/object/toCamelCaseKeys.d.ts +2 -6
- package/dist/object/toConstantCaseKeys.d.mts +52 -0
- package/dist/object/toConstantCaseKeys.d.ts +52 -0
- package/dist/object/toConstantCaseKeys.js +66 -0
- package/dist/object/toConstantCaseKeys.mjs +66 -0
- package/dist/object/toKebabCaseKeys.d.mts +52 -0
- package/dist/object/toKebabCaseKeys.d.ts +52 -0
- package/dist/object/toKebabCaseKeys.js +66 -0
- package/dist/object/toKebabCaseKeys.mjs +66 -0
- package/dist/object/toMerged.js +4 -4
- package/dist/object/toMerged.mjs +4 -4
- package/dist/object/toPascalCaseKeys.d.mts +52 -0
- package/dist/object/toPascalCaseKeys.d.ts +52 -0
- package/dist/object/toPascalCaseKeys.js +66 -0
- package/dist/object/toPascalCaseKeys.mjs +66 -0
- package/dist/object/toSnakeCaseKeys.d.mts +2 -3
- package/dist/object/toSnakeCaseKeys.d.ts +2 -3
- package/dist/promise/index.d.mts +2 -1
- package/dist/promise/index.d.ts +2 -1
- package/dist/promise/index.js +2 -0
- package/dist/promise/index.mjs +2 -1
- package/dist/promise/limitAsync.d.mts +35 -0
- package/dist/promise/limitAsync.d.ts +35 -0
- package/dist/promise/limitAsync.js +46 -0
- package/dist/promise/limitAsync.mjs +46 -0
- package/dist/string/dedent.d.mts +37 -0
- package/dist/string/dedent.d.ts +37 -0
- package/dist/string/dedent.js +38 -0
- package/dist/string/dedent.mjs +38 -0
- package/dist/string/index.d.mts +2 -1
- package/dist/string/index.d.ts +2 -1
- package/dist/string/index.js +5 -3
- package/dist/string/index.mjs +5 -4
- package/dist/types/ToCamelCaseKeys.d.mts +24 -0
- package/dist/types/ToCamelCaseKeys.d.ts +24 -0
- package/dist/types/ToConstantCaseKeys.d.mts +21 -0
- package/dist/types/ToConstantCaseKeys.d.ts +21 -0
- package/dist/types/ToKebabCaseKeys.d.mts +23 -0
- package/dist/types/ToKebabCaseKeys.d.ts +23 -0
- package/dist/types/ToPascalCaseKeys.d.mts +24 -0
- package/dist/types/ToPascalCaseKeys.d.ts +24 -0
- package/dist/types/ToSnakeCaseKeys.d.mts +21 -0
- package/dist/types/ToSnakeCaseKeys.d.ts +21 -0
- package/dist/types/index.d.mts +6 -1
- package/dist/types/index.d.ts +6 -1
- package/fp/iterator.d.ts +1 -0
- package/fp/iterator.js +1 -0
- package/iterator.d.ts +1 -0
- package/iterator.js +1 -0
- package/package.json +70 -2
package/dist/object/index.d.mts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { clone } from "./clone.mjs";
|
|
2
2
|
import { cloneDeep } from "./cloneDeep.mjs";
|
|
3
3
|
import { cloneDeepWith } from "./cloneDeepWith.mjs";
|
|
4
|
+
import { deepFreeze } from "./deepFreeze.mjs";
|
|
4
5
|
import { findKey } from "./findKey.mjs";
|
|
5
6
|
import { flattenObject } from "./flattenObject.mjs";
|
|
6
7
|
import { invert } from "./invert.mjs";
|
|
7
8
|
import { mapKeys } from "./mapKeys.mjs";
|
|
9
|
+
import { mapKeysAsync } from "./mapKeysAsync.mjs";
|
|
8
10
|
import { mapValues } from "./mapValues.mjs";
|
|
11
|
+
import { mapValuesAsync } from "./mapValuesAsync.mjs";
|
|
9
12
|
import { merge } from "./merge.mjs";
|
|
10
13
|
import { mergeWith } from "./mergeWith.mjs";
|
|
11
14
|
import { omit } from "./omit.mjs";
|
|
@@ -14,6 +17,9 @@ import { pick } from "./pick.mjs";
|
|
|
14
17
|
import { pickBy } from "./pickBy.mjs";
|
|
15
18
|
import { sortKeys } from "./sortKeys.mjs";
|
|
16
19
|
import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs";
|
|
20
|
+
import { toConstantCaseKeys } from "./toConstantCaseKeys.mjs";
|
|
21
|
+
import { toKebabCaseKeys } from "./toKebabCaseKeys.mjs";
|
|
17
22
|
import { toMerged } from "./toMerged.mjs";
|
|
23
|
+
import { toPascalCaseKeys } from "./toPascalCaseKeys.mjs";
|
|
18
24
|
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs";
|
|
19
|
-
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
|
25
|
+
export { clone, cloneDeep, cloneDeepWith, deepFreeze, findKey, flattenObject, invert, mapKeys, mapKeysAsync, mapValues, mapValuesAsync, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toConstantCaseKeys, toKebabCaseKeys, toMerged, toPascalCaseKeys, toSnakeCaseKeys };
|
package/dist/object/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { clone } from "./clone.js";
|
|
2
2
|
import { cloneDeep } from "./cloneDeep.js";
|
|
3
3
|
import { cloneDeepWith } from "./cloneDeepWith.js";
|
|
4
|
+
import { deepFreeze } from "./deepFreeze.js";
|
|
4
5
|
import { findKey } from "./findKey.js";
|
|
5
6
|
import { flattenObject } from "./flattenObject.js";
|
|
6
7
|
import { invert } from "./invert.js";
|
|
7
8
|
import { mapKeys } from "./mapKeys.js";
|
|
9
|
+
import { mapKeysAsync } from "./mapKeysAsync.js";
|
|
8
10
|
import { mapValues } from "./mapValues.js";
|
|
11
|
+
import { mapValuesAsync } from "./mapValuesAsync.js";
|
|
9
12
|
import { merge } from "./merge.js";
|
|
10
13
|
import { mergeWith } from "./mergeWith.js";
|
|
11
14
|
import { omit } from "./omit.js";
|
|
@@ -14,6 +17,9 @@ import { pick } from "./pick.js";
|
|
|
14
17
|
import { pickBy } from "./pickBy.js";
|
|
15
18
|
import { sortKeys } from "./sortKeys.js";
|
|
16
19
|
import { toCamelCaseKeys } from "./toCamelCaseKeys.js";
|
|
20
|
+
import { toConstantCaseKeys } from "./toConstantCaseKeys.js";
|
|
21
|
+
import { toKebabCaseKeys } from "./toKebabCaseKeys.js";
|
|
17
22
|
import { toMerged } from "./toMerged.js";
|
|
23
|
+
import { toPascalCaseKeys } from "./toPascalCaseKeys.js";
|
|
18
24
|
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.js";
|
|
19
|
-
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
|
25
|
+
export { clone, cloneDeep, cloneDeepWith, deepFreeze, findKey, flattenObject, invert, mapKeys, mapKeysAsync, mapValues, mapValuesAsync, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toConstantCaseKeys, toKebabCaseKeys, toMerged, toPascalCaseKeys, toSnakeCaseKeys };
|
package/dist/object/index.js
CHANGED
|
@@ -2,11 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_clone = require("./clone.js");
|
|
3
3
|
const require_cloneDeepWith = require("./cloneDeepWith.js");
|
|
4
4
|
const require_cloneDeep = require("./cloneDeep.js");
|
|
5
|
+
const require_deepFreeze = require("./deepFreeze.js");
|
|
5
6
|
const require_findKey = require("./findKey.js");
|
|
6
7
|
const require_flattenObject = require("./flattenObject.js");
|
|
7
8
|
const require_invert = require("./invert.js");
|
|
8
9
|
const require_mapKeys = require("./mapKeys.js");
|
|
10
|
+
const require_mapKeysAsync = require("./mapKeysAsync.js");
|
|
9
11
|
const require_mapValues = require("./mapValues.js");
|
|
12
|
+
const require_mapValuesAsync = require("./mapValuesAsync.js");
|
|
10
13
|
const require_merge = require("./merge.js");
|
|
11
14
|
const require_mergeWith = require("./mergeWith.js");
|
|
12
15
|
const require_omit = require("./omit.js");
|
|
@@ -15,16 +18,22 @@ const require_pick = require("./pick.js");
|
|
|
15
18
|
const require_pickBy = require("./pickBy.js");
|
|
16
19
|
const require_sortKeys = require("./sortKeys.js");
|
|
17
20
|
const require_toCamelCaseKeys = require("./toCamelCaseKeys.js");
|
|
21
|
+
const require_toConstantCaseKeys = require("./toConstantCaseKeys.js");
|
|
22
|
+
const require_toKebabCaseKeys = require("./toKebabCaseKeys.js");
|
|
18
23
|
const require_toMerged = require("./toMerged.js");
|
|
24
|
+
const require_toPascalCaseKeys = require("./toPascalCaseKeys.js");
|
|
19
25
|
const require_toSnakeCaseKeys = require("./toSnakeCaseKeys.js");
|
|
20
26
|
exports.clone = require_clone.clone;
|
|
21
27
|
exports.cloneDeep = require_cloneDeep.cloneDeep;
|
|
22
28
|
exports.cloneDeepWith = require_cloneDeepWith.cloneDeepWith;
|
|
29
|
+
exports.deepFreeze = require_deepFreeze.deepFreeze;
|
|
23
30
|
exports.findKey = require_findKey.findKey;
|
|
24
31
|
exports.flattenObject = require_flattenObject.flattenObject;
|
|
25
32
|
exports.invert = require_invert.invert;
|
|
26
33
|
exports.mapKeys = require_mapKeys.mapKeys;
|
|
34
|
+
exports.mapKeysAsync = require_mapKeysAsync.mapKeysAsync;
|
|
27
35
|
exports.mapValues = require_mapValues.mapValues;
|
|
36
|
+
exports.mapValuesAsync = require_mapValuesAsync.mapValuesAsync;
|
|
28
37
|
exports.merge = require_merge.merge;
|
|
29
38
|
exports.mergeWith = require_mergeWith.mergeWith;
|
|
30
39
|
exports.omit = require_omit.omit;
|
|
@@ -33,5 +42,8 @@ exports.pick = require_pick.pick;
|
|
|
33
42
|
exports.pickBy = require_pickBy.pickBy;
|
|
34
43
|
exports.sortKeys = require_sortKeys.sortKeys;
|
|
35
44
|
exports.toCamelCaseKeys = require_toCamelCaseKeys.toCamelCaseKeys;
|
|
45
|
+
exports.toConstantCaseKeys = require_toConstantCaseKeys.toConstantCaseKeys;
|
|
46
|
+
exports.toKebabCaseKeys = require_toKebabCaseKeys.toKebabCaseKeys;
|
|
36
47
|
exports.toMerged = require_toMerged.toMerged;
|
|
48
|
+
exports.toPascalCaseKeys = require_toPascalCaseKeys.toPascalCaseKeys;
|
|
37
49
|
exports.toSnakeCaseKeys = require_toSnakeCaseKeys.toSnakeCaseKeys;
|
package/dist/object/index.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { clone } from "./clone.mjs";
|
|
2
2
|
import { cloneDeepWith } from "./cloneDeepWith.mjs";
|
|
3
3
|
import { cloneDeep } from "./cloneDeep.mjs";
|
|
4
|
+
import { deepFreeze } from "./deepFreeze.mjs";
|
|
4
5
|
import { findKey } from "./findKey.mjs";
|
|
5
6
|
import { flattenObject } from "./flattenObject.mjs";
|
|
6
7
|
import { invert } from "./invert.mjs";
|
|
7
8
|
import { mapKeys } from "./mapKeys.mjs";
|
|
9
|
+
import { mapKeysAsync } from "./mapKeysAsync.mjs";
|
|
8
10
|
import { mapValues } from "./mapValues.mjs";
|
|
11
|
+
import { mapValuesAsync } from "./mapValuesAsync.mjs";
|
|
9
12
|
import { merge } from "./merge.mjs";
|
|
10
13
|
import { mergeWith } from "./mergeWith.mjs";
|
|
11
14
|
import { omit } from "./omit.mjs";
|
|
@@ -14,6 +17,9 @@ import { pick } from "./pick.mjs";
|
|
|
14
17
|
import { pickBy } from "./pickBy.mjs";
|
|
15
18
|
import { sortKeys } from "./sortKeys.mjs";
|
|
16
19
|
import { toCamelCaseKeys } from "./toCamelCaseKeys.mjs";
|
|
20
|
+
import { toConstantCaseKeys } from "./toConstantCaseKeys.mjs";
|
|
21
|
+
import { toKebabCaseKeys } from "./toKebabCaseKeys.mjs";
|
|
17
22
|
import { toMerged } from "./toMerged.mjs";
|
|
23
|
+
import { toPascalCaseKeys } from "./toPascalCaseKeys.mjs";
|
|
18
24
|
import { toSnakeCaseKeys } from "./toSnakeCaseKeys.mjs";
|
|
19
|
-
export { clone, cloneDeep, cloneDeepWith, findKey, flattenObject, invert, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toMerged, toSnakeCaseKeys };
|
|
25
|
+
export { clone, cloneDeep, cloneDeepWith, deepFreeze, findKey, flattenObject, invert, mapKeys, mapKeysAsync, mapValues, mapValuesAsync, merge, mergeWith, omit, omitBy, pick, pickBy, sortKeys, toCamelCaseKeys, toConstantCaseKeys, toKebabCaseKeys, toMerged, toPascalCaseKeys, toSnakeCaseKeys };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/object/mapKeysAsync.d.ts
|
|
2
|
+
interface MapKeysAsyncOptions {
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new object with the same values as the given object, but with keys generated
|
|
7
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the object.
|
|
10
|
+
* @template K - The type of the new keys generated by the iteratee function.
|
|
11
|
+
*
|
|
12
|
+
* @param {T} object - The object to iterate over.
|
|
13
|
+
* @param {(value: T[keyof T], key: keyof T, object: T) => Promise<K>} getNewKey - The async function invoked per own enumerable property.
|
|
14
|
+
* @param {MapKeysAsyncOptions} [options] Optional configuration object.
|
|
15
|
+
* @returns {Promise<Record<K, T[keyof T]>>} - A promise that resolves to the new mapped object.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Example usage:
|
|
19
|
+
* const obj = { a: 1, b: 2 };
|
|
20
|
+
* const result = await mapKeysAsync(obj, async (value, key) => key + value);
|
|
21
|
+
* console.log(result); // { a1: 1, b2: 2 }
|
|
22
|
+
*/
|
|
23
|
+
declare function mapKeysAsync<T extends Record<PropertyKey, any>, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => Promise<K>, options?: MapKeysAsyncOptions): Promise<Record<K, T[keyof T]>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { mapKeysAsync };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/object/mapKeysAsync.d.ts
|
|
2
|
+
interface MapKeysAsyncOptions {
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new object with the same values as the given object, but with keys generated
|
|
7
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the object.
|
|
10
|
+
* @template K - The type of the new keys generated by the iteratee function.
|
|
11
|
+
*
|
|
12
|
+
* @param {T} object - The object to iterate over.
|
|
13
|
+
* @param {(value: T[keyof T], key: keyof T, object: T) => Promise<K>} getNewKey - The async function invoked per own enumerable property.
|
|
14
|
+
* @param {MapKeysAsyncOptions} [options] Optional configuration object.
|
|
15
|
+
* @returns {Promise<Record<K, T[keyof T]>>} - A promise that resolves to the new mapped object.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Example usage:
|
|
19
|
+
* const obj = { a: 1, b: 2 };
|
|
20
|
+
* const result = await mapKeysAsync(obj, async (value, key) => key + value);
|
|
21
|
+
* console.log(result); // { a1: 1, b2: 2 }
|
|
22
|
+
*/
|
|
23
|
+
declare function mapKeysAsync<T extends Record<PropertyKey, any>, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => Promise<K>, options?: MapKeysAsyncOptions): Promise<Record<K, T[keyof T]>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { mapKeysAsync };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_limitAsync = require("../promise/limitAsync.js");
|
|
2
|
+
//#region src/object/mapKeysAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new object with the same values as the given object, but with keys generated
|
|
5
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the object.
|
|
8
|
+
* @template K - The type of the new keys generated by the iteratee function.
|
|
9
|
+
*
|
|
10
|
+
* @param {T} object - The object to iterate over.
|
|
11
|
+
* @param {(value: T[keyof T], key: keyof T, object: T) => Promise<K>} getNewKey - The async function invoked per own enumerable property.
|
|
12
|
+
* @param {MapKeysAsyncOptions} [options] Optional configuration object.
|
|
13
|
+
* @returns {Promise<Record<K, T[keyof T]>>} - A promise that resolves to the new mapped object.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Example usage:
|
|
17
|
+
* const obj = { a: 1, b: 2 };
|
|
18
|
+
* const result = await mapKeysAsync(obj, async (value, key) => key + value);
|
|
19
|
+
* console.log(result); // { a1: 1, b2: 2 }
|
|
20
|
+
*/
|
|
21
|
+
async function mapKeysAsync(object, getNewKey, options) {
|
|
22
|
+
const result = {};
|
|
23
|
+
const keys = Object.keys(object);
|
|
24
|
+
if (options?.concurrency) getNewKey = require_limitAsync.limitAsync(getNewKey, options.concurrency);
|
|
25
|
+
await Promise.all(keys.map(async (key) => {
|
|
26
|
+
const value = object[key];
|
|
27
|
+
result[await getNewKey(value, key, object)] = value;
|
|
28
|
+
}));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.mapKeysAsync = mapKeysAsync;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { limitAsync } from "../promise/limitAsync.mjs";
|
|
2
|
+
//#region src/object/mapKeysAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new object with the same values as the given object, but with keys generated
|
|
5
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the object.
|
|
8
|
+
* @template K - The type of the new keys generated by the iteratee function.
|
|
9
|
+
*
|
|
10
|
+
* @param {T} object - The object to iterate over.
|
|
11
|
+
* @param {(value: T[keyof T], key: keyof T, object: T) => Promise<K>} getNewKey - The async function invoked per own enumerable property.
|
|
12
|
+
* @param {MapKeysAsyncOptions} [options] Optional configuration object.
|
|
13
|
+
* @returns {Promise<Record<K, T[keyof T]>>} - A promise that resolves to the new mapped object.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Example usage:
|
|
17
|
+
* const obj = { a: 1, b: 2 };
|
|
18
|
+
* const result = await mapKeysAsync(obj, async (value, key) => key + value);
|
|
19
|
+
* console.log(result); // { a1: 1, b2: 2 }
|
|
20
|
+
*/
|
|
21
|
+
async function mapKeysAsync(object, getNewKey, options) {
|
|
22
|
+
const result = {};
|
|
23
|
+
const keys = Object.keys(object);
|
|
24
|
+
if (options?.concurrency) getNewKey = limitAsync(getNewKey, options.concurrency);
|
|
25
|
+
await Promise.all(keys.map(async (key) => {
|
|
26
|
+
const value = object[key];
|
|
27
|
+
result[await getNewKey(value, key, object)] = value;
|
|
28
|
+
}));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { mapKeysAsync };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/object/mapValuesAsync.d.ts
|
|
2
|
+
interface MapValuesAsyncOptions {
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
7
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the object.
|
|
10
|
+
* @template K - The type of the keys in the object.
|
|
11
|
+
* @template V - The type of the new values generated by the async iteratee function.
|
|
12
|
+
*
|
|
13
|
+
* @param {T} object - The object to iterate over.
|
|
14
|
+
* @param {(value: T[K], key: K, object: T) => Promise<V>} getNewValue - The async function invoked per own enumerable property.
|
|
15
|
+
* @param {MapValuesAsyncOptions} [options] Optional configuration object.
|
|
16
|
+
* @returns {Promise<Record<K, V>>} - A promise that resolves to the new mapped object.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Example usage:
|
|
20
|
+
* const obj = { a: 1, b: 2 };
|
|
21
|
+
* const result = await mapValuesAsync(obj, async (value) => value * 2);
|
|
22
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
23
|
+
*/
|
|
24
|
+
declare function mapValuesAsync<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => Promise<V>, options?: MapValuesAsyncOptions): Promise<Record<K, V>>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { mapValuesAsync };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/object/mapValuesAsync.d.ts
|
|
2
|
+
interface MapValuesAsyncOptions {
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
7
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the object.
|
|
10
|
+
* @template K - The type of the keys in the object.
|
|
11
|
+
* @template V - The type of the new values generated by the async iteratee function.
|
|
12
|
+
*
|
|
13
|
+
* @param {T} object - The object to iterate over.
|
|
14
|
+
* @param {(value: T[K], key: K, object: T) => Promise<V>} getNewValue - The async function invoked per own enumerable property.
|
|
15
|
+
* @param {MapValuesAsyncOptions} [options] Optional configuration object.
|
|
16
|
+
* @returns {Promise<Record<K, V>>} - A promise that resolves to the new mapped object.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Example usage:
|
|
20
|
+
* const obj = { a: 1, b: 2 };
|
|
21
|
+
* const result = await mapValuesAsync(obj, async (value) => value * 2);
|
|
22
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
23
|
+
*/
|
|
24
|
+
declare function mapValuesAsync<T extends object, K extends keyof T, V>(object: T, getNewValue: (value: T[K], key: K, object: T) => Promise<V>, options?: MapValuesAsyncOptions): Promise<Record<K, V>>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { mapValuesAsync };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_limitAsync = require("../promise/limitAsync.js");
|
|
2
|
+
//#region src/object/mapValuesAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
5
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the object.
|
|
8
|
+
* @template K - The type of the keys in the object.
|
|
9
|
+
* @template V - The type of the new values generated by the async iteratee function.
|
|
10
|
+
*
|
|
11
|
+
* @param {T} object - The object to iterate over.
|
|
12
|
+
* @param {(value: T[K], key: K, object: T) => Promise<V>} getNewValue - The async function invoked per own enumerable property.
|
|
13
|
+
* @param {MapValuesAsyncOptions} [options] Optional configuration object.
|
|
14
|
+
* @returns {Promise<Record<K, V>>} - A promise that resolves to the new mapped object.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Example usage:
|
|
18
|
+
* const obj = { a: 1, b: 2 };
|
|
19
|
+
* const result = await mapValuesAsync(obj, async (value) => value * 2);
|
|
20
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
21
|
+
*/
|
|
22
|
+
async function mapValuesAsync(object, getNewValue, options) {
|
|
23
|
+
const result = {};
|
|
24
|
+
const keys = Object.keys(object);
|
|
25
|
+
if (options?.concurrency) getNewValue = require_limitAsync.limitAsync(getNewValue, options.concurrency);
|
|
26
|
+
await Promise.all(keys.map(async (key) => {
|
|
27
|
+
result[key] = await getNewValue(object[key], key, object);
|
|
28
|
+
}));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.mapValuesAsync = mapValuesAsync;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { limitAsync } from "../promise/limitAsync.mjs";
|
|
2
|
+
//#region src/object/mapValuesAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new object with the same keys as the given object, but with values generated
|
|
5
|
+
* by running each own enumerable property of the object through the async iteratee function.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the object.
|
|
8
|
+
* @template K - The type of the keys in the object.
|
|
9
|
+
* @template V - The type of the new values generated by the async iteratee function.
|
|
10
|
+
*
|
|
11
|
+
* @param {T} object - The object to iterate over.
|
|
12
|
+
* @param {(value: T[K], key: K, object: T) => Promise<V>} getNewValue - The async function invoked per own enumerable property.
|
|
13
|
+
* @param {MapValuesAsyncOptions} [options] Optional configuration object.
|
|
14
|
+
* @returns {Promise<Record<K, V>>} - A promise that resolves to the new mapped object.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Example usage:
|
|
18
|
+
* const obj = { a: 1, b: 2 };
|
|
19
|
+
* const result = await mapValuesAsync(obj, async (value) => value * 2);
|
|
20
|
+
* console.log(result); // { a: 2, b: 4 }
|
|
21
|
+
*/
|
|
22
|
+
async function mapValuesAsync(object, getNewValue, options) {
|
|
23
|
+
const result = {};
|
|
24
|
+
const keys = Object.keys(object);
|
|
25
|
+
if (options?.concurrency) getNewValue = limitAsync(getNewValue, options.concurrency);
|
|
26
|
+
await Promise.all(keys.map(async (key) => {
|
|
27
|
+
result[key] = await getNewValue(object[key], key, object);
|
|
28
|
+
}));
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { mapValuesAsync };
|
package/dist/object/merge.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
|
2
|
+
const require_isMergeableValue = require("../_internal/isMergeableValue.js");
|
|
2
3
|
const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js");
|
|
3
4
|
//#region src/object/merge.ts
|
|
4
5
|
/**
|
|
@@ -48,15 +49,12 @@ function merge(target, source) {
|
|
|
48
49
|
if (require_isUnsafeProperty.isUnsafeProperty(key)) continue;
|
|
49
50
|
const sourceValue = source[key];
|
|
50
51
|
const targetValue = target[key];
|
|
51
|
-
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
|
52
|
+
if (require_isMergeableValue.isMergeableValue(sourceValue) && require_isMergeableValue.isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
|
52
53
|
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
|
53
54
|
else if (require_isPlainObject.isPlainObject(sourceValue)) target[key] = merge({}, sourceValue);
|
|
54
55
|
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
55
56
|
}
|
|
56
57
|
return target;
|
|
57
58
|
}
|
|
58
|
-
function isMergeableValue(value) {
|
|
59
|
-
return require_isPlainObject.isPlainObject(value) || Array.isArray(value);
|
|
60
|
-
}
|
|
61
59
|
//#endregion
|
|
62
60
|
exports.merge = merge;
|
package/dist/object/merge.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
|
2
|
+
import { isMergeableValue } from "../_internal/isMergeableValue.mjs";
|
|
2
3
|
import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs";
|
|
3
4
|
//#region src/object/merge.ts
|
|
4
5
|
/**
|
|
@@ -55,8 +56,5 @@ function merge(target, source) {
|
|
|
55
56
|
}
|
|
56
57
|
return target;
|
|
57
58
|
}
|
|
58
|
-
function isMergeableValue(value) {
|
|
59
|
-
return isPlainObject(value) || Array.isArray(value);
|
|
60
|
-
}
|
|
61
59
|
//#endregion
|
|
62
60
|
export { merge };
|
package/dist/object/mergeWith.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_isPlainObject = require("../predicate/isPlainObject.js");
|
|
2
|
+
const require_isMergeableValue = require("../_internal/isMergeableValue.js");
|
|
2
3
|
const require_isUnsafeProperty = require("../_internal/isUnsafeProperty.js");
|
|
3
4
|
//#region src/object/mergeWith.ts
|
|
4
5
|
/**
|
|
@@ -58,10 +59,9 @@ function mergeWith(target, source, merge) {
|
|
|
58
59
|
const targetValue = target[key];
|
|
59
60
|
const merged = merge(targetValue, sourceValue, key, target, source);
|
|
60
61
|
if (merged !== void 0) target[key] = merged;
|
|
61
|
-
else if (
|
|
62
|
-
else target[key] = mergeWith([], sourceValue, merge);
|
|
63
|
-
else if (require_isPlainObject.isPlainObject(sourceValue))
|
|
64
|
-
else target[key] = mergeWith({}, sourceValue, merge);
|
|
62
|
+
else if (require_isMergeableValue.isMergeableValue(sourceValue) && require_isMergeableValue.isMergeableValue(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
|
63
|
+
else if (Array.isArray(sourceValue)) target[key] = mergeWith([], sourceValue, merge);
|
|
64
|
+
else if (require_isPlainObject.isPlainObject(sourceValue)) target[key] = mergeWith({}, sourceValue, merge);
|
|
65
65
|
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
66
66
|
}
|
|
67
67
|
return target;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../predicate/isPlainObject.mjs";
|
|
2
|
+
import { isMergeableValue } from "../_internal/isMergeableValue.mjs";
|
|
2
3
|
import { isUnsafeProperty } from "../_internal/isUnsafeProperty.mjs";
|
|
3
4
|
//#region src/object/mergeWith.ts
|
|
4
5
|
/**
|
|
@@ -58,10 +59,9 @@ function mergeWith(target, source, merge) {
|
|
|
58
59
|
const targetValue = target[key];
|
|
59
60
|
const merged = merge(targetValue, sourceValue, key, target, source);
|
|
60
61
|
if (merged !== void 0) target[key] = merged;
|
|
61
|
-
else if (
|
|
62
|
-
else target[key] = mergeWith([], sourceValue, merge);
|
|
63
|
-
else if (isPlainObject(sourceValue))
|
|
64
|
-
else target[key] = mergeWith({}, sourceValue, merge);
|
|
62
|
+
else if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
|
63
|
+
else if (Array.isArray(sourceValue)) target[key] = mergeWith([], sourceValue, merge);
|
|
64
|
+
else if (isPlainObject(sourceValue)) target[key] = mergeWith({}, sourceValue, merge);
|
|
65
65
|
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
66
66
|
}
|
|
67
67
|
return target;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { ToCamelCaseKeys } from "../types/ToCamelCaseKeys.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/object/toCamelCaseKeys.d.ts
|
|
2
|
-
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
|
3
|
-
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
|
4
|
-
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */
|
|
5
|
-
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
|
6
|
-
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
|
7
|
-
type ToCamelCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToCamelCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToCamel<Extract<K, string>>]: ToCamelCaseKeys<T[K]> } : T;
|
|
8
4
|
/**
|
|
9
5
|
* Creates a new object composed of the properties with keys converted to camelCase.
|
|
10
6
|
*
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { ToCamelCaseKeys } from "../types/ToCamelCaseKeys.js";
|
|
2
|
+
|
|
1
3
|
//#region src/object/toCamelCaseKeys.d.ts
|
|
2
|
-
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
|
3
|
-
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
|
4
|
-
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase the entire string; otherwise, just lowercase the first letter (including PascalCase → camelCase). */
|
|
5
|
-
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
|
6
|
-
type NonPlainObject = Date | RegExp | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Error | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | ((...args: any[]) => any) | typeof globalThis;
|
|
7
|
-
type ToCamelCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToCamelCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToCamel<Extract<K, string>>]: ToCamelCaseKeys<T[K]> } : T;
|
|
8
4
|
/**
|
|
9
5
|
* Creates a new object composed of the properties with keys converted to camelCase.
|
|
10
6
|
*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ToConstantCaseKeys } from "../types/ToConstantCaseKeys.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/object/toConstantCaseKeys.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new object composed of the properties with keys converted to CONSTANT_CASE.
|
|
6
|
+
*
|
|
7
|
+
* This function takes an object and returns a new object that includes the same properties,
|
|
8
|
+
* but with all keys converted to CONSTANT_CASE format.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of object.
|
|
11
|
+
* @param obj - The object to convert keys from.
|
|
12
|
+
* @returns A new object with all keys converted to CONSTANT_CASE.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Example with objects
|
|
16
|
+
* const obj = { userId: 1, firstName: 'John' };
|
|
17
|
+
* const result = toConstantCaseKeys(obj);
|
|
18
|
+
* // result will be { USER_ID: 1, FIRST_NAME: 'John' }
|
|
19
|
+
*
|
|
20
|
+
* // Example with arrays of objects
|
|
21
|
+
* const arr = [
|
|
22
|
+
* { userId: 1, firstName: 'John' },
|
|
23
|
+
* { userId: 2, firstName: 'Jane' }
|
|
24
|
+
* ];
|
|
25
|
+
* const arrResult = toConstantCaseKeys(arr);
|
|
26
|
+
* // arrResult will be [{ USER_ID: 1, FIRST_NAME: 'John' }, { USER_ID: 2, FIRST_NAME: 'Jane' }]
|
|
27
|
+
*
|
|
28
|
+
* // Example with nested objects
|
|
29
|
+
* const nested = {
|
|
30
|
+
* userData: {
|
|
31
|
+
* userId: 1,
|
|
32
|
+
* userAddress: {
|
|
33
|
+
* streetName: 'Main St',
|
|
34
|
+
* zipCode: '12345'
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* };
|
|
38
|
+
* const nestedResult = toConstantCaseKeys(nested);
|
|
39
|
+
* // nestedResult will be:
|
|
40
|
+
* // {
|
|
41
|
+
* // USER_DATA: {
|
|
42
|
+
* // USER_ID: 1,
|
|
43
|
+
* // USER_ADDRESS: {
|
|
44
|
+
* // STREET_NAME: 'Main St',
|
|
45
|
+
* // ZIP_CODE: '12345'
|
|
46
|
+
* // }
|
|
47
|
+
* // }
|
|
48
|
+
* // }
|
|
49
|
+
*/
|
|
50
|
+
declare function toConstantCaseKeys<T>(obj: T): ToConstantCaseKeys<T>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { toConstantCaseKeys };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ToConstantCaseKeys } from "../types/ToConstantCaseKeys.js";
|
|
2
|
+
|
|
3
|
+
//#region src/object/toConstantCaseKeys.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new object composed of the properties with keys converted to CONSTANT_CASE.
|
|
6
|
+
*
|
|
7
|
+
* This function takes an object and returns a new object that includes the same properties,
|
|
8
|
+
* but with all keys converted to CONSTANT_CASE format.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of object.
|
|
11
|
+
* @param obj - The object to convert keys from.
|
|
12
|
+
* @returns A new object with all keys converted to CONSTANT_CASE.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Example with objects
|
|
16
|
+
* const obj = { userId: 1, firstName: 'John' };
|
|
17
|
+
* const result = toConstantCaseKeys(obj);
|
|
18
|
+
* // result will be { USER_ID: 1, FIRST_NAME: 'John' }
|
|
19
|
+
*
|
|
20
|
+
* // Example with arrays of objects
|
|
21
|
+
* const arr = [
|
|
22
|
+
* { userId: 1, firstName: 'John' },
|
|
23
|
+
* { userId: 2, firstName: 'Jane' }
|
|
24
|
+
* ];
|
|
25
|
+
* const arrResult = toConstantCaseKeys(arr);
|
|
26
|
+
* // arrResult will be [{ USER_ID: 1, FIRST_NAME: 'John' }, { USER_ID: 2, FIRST_NAME: 'Jane' }]
|
|
27
|
+
*
|
|
28
|
+
* // Example with nested objects
|
|
29
|
+
* const nested = {
|
|
30
|
+
* userData: {
|
|
31
|
+
* userId: 1,
|
|
32
|
+
* userAddress: {
|
|
33
|
+
* streetName: 'Main St',
|
|
34
|
+
* zipCode: '12345'
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* };
|
|
38
|
+
* const nestedResult = toConstantCaseKeys(nested);
|
|
39
|
+
* // nestedResult will be:
|
|
40
|
+
* // {
|
|
41
|
+
* // USER_DATA: {
|
|
42
|
+
* // USER_ID: 1,
|
|
43
|
+
* // USER_ADDRESS: {
|
|
44
|
+
* // STREET_NAME: 'Main St',
|
|
45
|
+
* // ZIP_CODE: '12345'
|
|
46
|
+
* // }
|
|
47
|
+
* // }
|
|
48
|
+
* // }
|
|
49
|
+
*/
|
|
50
|
+
declare function toConstantCaseKeys<T>(obj: T): ToConstantCaseKeys<T>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { toConstantCaseKeys };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const require_isArray = require("../compat/predicate/isArray.js");
|
|
2
|
+
const require_isPlainObject = require("../compat/predicate/isPlainObject.js");
|
|
3
|
+
const require_constantCase = require("../string/constantCase.js");
|
|
4
|
+
//#region src/object/toConstantCaseKeys.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new object composed of the properties with keys converted to CONSTANT_CASE.
|
|
7
|
+
*
|
|
8
|
+
* This function takes an object and returns a new object that includes the same properties,
|
|
9
|
+
* but with all keys converted to CONSTANT_CASE format.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The type of object.
|
|
12
|
+
* @param obj - The object to convert keys from.
|
|
13
|
+
* @returns A new object with all keys converted to CONSTANT_CASE.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Example with objects
|
|
17
|
+
* const obj = { userId: 1, firstName: 'John' };
|
|
18
|
+
* const result = toConstantCaseKeys(obj);
|
|
19
|
+
* // result will be { USER_ID: 1, FIRST_NAME: 'John' }
|
|
20
|
+
*
|
|
21
|
+
* // Example with arrays of objects
|
|
22
|
+
* const arr = [
|
|
23
|
+
* { userId: 1, firstName: 'John' },
|
|
24
|
+
* { userId: 2, firstName: 'Jane' }
|
|
25
|
+
* ];
|
|
26
|
+
* const arrResult = toConstantCaseKeys(arr);
|
|
27
|
+
* // arrResult will be [{ USER_ID: 1, FIRST_NAME: 'John' }, { USER_ID: 2, FIRST_NAME: 'Jane' }]
|
|
28
|
+
*
|
|
29
|
+
* // Example with nested objects
|
|
30
|
+
* const nested = {
|
|
31
|
+
* userData: {
|
|
32
|
+
* userId: 1,
|
|
33
|
+
* userAddress: {
|
|
34
|
+
* streetName: 'Main St',
|
|
35
|
+
* zipCode: '12345'
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
* const nestedResult = toConstantCaseKeys(nested);
|
|
40
|
+
* // nestedResult will be:
|
|
41
|
+
* // {
|
|
42
|
+
* // USER_DATA: {
|
|
43
|
+
* // USER_ID: 1,
|
|
44
|
+
* // USER_ADDRESS: {
|
|
45
|
+
* // STREET_NAME: 'Main St',
|
|
46
|
+
* // ZIP_CODE: '12345'
|
|
47
|
+
* // }
|
|
48
|
+
* // }
|
|
49
|
+
* // }
|
|
50
|
+
*/
|
|
51
|
+
function toConstantCaseKeys(obj) {
|
|
52
|
+
if (require_isArray.isArray(obj)) return obj.map((item) => toConstantCaseKeys(item));
|
|
53
|
+
if (require_isPlainObject.isPlainObject(obj)) {
|
|
54
|
+
const result = {};
|
|
55
|
+
const keys = Object.keys(obj);
|
|
56
|
+
for (let i = 0; i < keys.length; i++) {
|
|
57
|
+
const key = keys[i];
|
|
58
|
+
const constantKey = require_constantCase.constantCase(key);
|
|
59
|
+
result[constantKey] = toConstantCaseKeys(obj[key]);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.toConstantCaseKeys = toConstantCaseKeys;
|