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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/promise/limitAsync.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an async function to limit the number of concurrent executions.
|
|
4
|
+
*
|
|
5
|
+
* This function creates a wrapper around an async callback that ensures at most
|
|
6
|
+
* `concurrency` number of executions can run simultaneously. Additional calls will
|
|
7
|
+
* wait until a slot becomes available.
|
|
8
|
+
*
|
|
9
|
+
* @template F - The type of the async function to wrap.
|
|
10
|
+
* @param callback The async function to wrap with concurrency control.
|
|
11
|
+
* @param concurrency Maximum number of concurrent executions allowed.
|
|
12
|
+
* @returns A wrapped version of the callback with concurrency limiting.
|
|
13
|
+
* @example
|
|
14
|
+
* const limitedFetch = limitAsync(async (url) => {
|
|
15
|
+
* return await fetch(url);
|
|
16
|
+
* }, 3);
|
|
17
|
+
*
|
|
18
|
+
* // Only 3 fetches will run concurrently
|
|
19
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];
|
|
20
|
+
* await Promise.all(urls.map(url => limitedFetch(url)));
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const processItem = async (item) => {
|
|
24
|
+
* // Expensive async operation
|
|
25
|
+
* return await heavyComputation(item);
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* const limitedProcess = limitAsync(processItem, 2);
|
|
29
|
+
* const items = [1, 2, 3, 4, 5];
|
|
30
|
+
* // At most 2 items will be processed concurrently
|
|
31
|
+
* await Promise.all(items.map(item => limitedProcess(item)));
|
|
32
|
+
*/
|
|
33
|
+
declare function limitAsync<F extends (...args: any[]) => Promise<any>>(callback: F, concurrency: number): F;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { limitAsync };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/promise/limitAsync.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an async function to limit the number of concurrent executions.
|
|
4
|
+
*
|
|
5
|
+
* This function creates a wrapper around an async callback that ensures at most
|
|
6
|
+
* `concurrency` number of executions can run simultaneously. Additional calls will
|
|
7
|
+
* wait until a slot becomes available.
|
|
8
|
+
*
|
|
9
|
+
* @template F - The type of the async function to wrap.
|
|
10
|
+
* @param callback The async function to wrap with concurrency control.
|
|
11
|
+
* @param concurrency Maximum number of concurrent executions allowed.
|
|
12
|
+
* @returns A wrapped version of the callback with concurrency limiting.
|
|
13
|
+
* @example
|
|
14
|
+
* const limitedFetch = limitAsync(async (url) => {
|
|
15
|
+
* return await fetch(url);
|
|
16
|
+
* }, 3);
|
|
17
|
+
*
|
|
18
|
+
* // Only 3 fetches will run concurrently
|
|
19
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];
|
|
20
|
+
* await Promise.all(urls.map(url => limitedFetch(url)));
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const processItem = async (item) => {
|
|
24
|
+
* // Expensive async operation
|
|
25
|
+
* return await heavyComputation(item);
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* const limitedProcess = limitAsync(processItem, 2);
|
|
29
|
+
* const items = [1, 2, 3, 4, 5];
|
|
30
|
+
* // At most 2 items will be processed concurrently
|
|
31
|
+
* await Promise.all(items.map(item => limitedProcess(item)));
|
|
32
|
+
*/
|
|
33
|
+
declare function limitAsync<F extends (...args: any[]) => Promise<any>>(callback: F, concurrency: number): F;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { limitAsync };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_semaphore = require("./semaphore.js");
|
|
2
|
+
//#region src/promise/limitAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Wraps an async function to limit the number of concurrent executions.
|
|
5
|
+
*
|
|
6
|
+
* This function creates a wrapper around an async callback that ensures at most
|
|
7
|
+
* `concurrency` number of executions can run simultaneously. Additional calls will
|
|
8
|
+
* wait until a slot becomes available.
|
|
9
|
+
*
|
|
10
|
+
* @template F - The type of the async function to wrap.
|
|
11
|
+
* @param callback The async function to wrap with concurrency control.
|
|
12
|
+
* @param concurrency Maximum number of concurrent executions allowed.
|
|
13
|
+
* @returns A wrapped version of the callback with concurrency limiting.
|
|
14
|
+
* @example
|
|
15
|
+
* const limitedFetch = limitAsync(async (url) => {
|
|
16
|
+
* return await fetch(url);
|
|
17
|
+
* }, 3);
|
|
18
|
+
*
|
|
19
|
+
* // Only 3 fetches will run concurrently
|
|
20
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];
|
|
21
|
+
* await Promise.all(urls.map(url => limitedFetch(url)));
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const processItem = async (item) => {
|
|
25
|
+
* // Expensive async operation
|
|
26
|
+
* return await heavyComputation(item);
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* const limitedProcess = limitAsync(processItem, 2);
|
|
30
|
+
* const items = [1, 2, 3, 4, 5];
|
|
31
|
+
* // At most 2 items will be processed concurrently
|
|
32
|
+
* await Promise.all(items.map(item => limitedProcess(item)));
|
|
33
|
+
*/
|
|
34
|
+
function limitAsync(callback, concurrency) {
|
|
35
|
+
const semaphore = new require_semaphore.Semaphore(concurrency);
|
|
36
|
+
return async function(...args) {
|
|
37
|
+
try {
|
|
38
|
+
await semaphore.acquire();
|
|
39
|
+
return await callback.apply(this, args);
|
|
40
|
+
} finally {
|
|
41
|
+
semaphore.release();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.limitAsync = limitAsync;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Semaphore } from "./semaphore.mjs";
|
|
2
|
+
//#region src/promise/limitAsync.ts
|
|
3
|
+
/**
|
|
4
|
+
* Wraps an async function to limit the number of concurrent executions.
|
|
5
|
+
*
|
|
6
|
+
* This function creates a wrapper around an async callback that ensures at most
|
|
7
|
+
* `concurrency` number of executions can run simultaneously. Additional calls will
|
|
8
|
+
* wait until a slot becomes available.
|
|
9
|
+
*
|
|
10
|
+
* @template F - The type of the async function to wrap.
|
|
11
|
+
* @param callback The async function to wrap with concurrency control.
|
|
12
|
+
* @param concurrency Maximum number of concurrent executions allowed.
|
|
13
|
+
* @returns A wrapped version of the callback with concurrency limiting.
|
|
14
|
+
* @example
|
|
15
|
+
* const limitedFetch = limitAsync(async (url) => {
|
|
16
|
+
* return await fetch(url);
|
|
17
|
+
* }, 3);
|
|
18
|
+
*
|
|
19
|
+
* // Only 3 fetches will run concurrently
|
|
20
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];
|
|
21
|
+
* await Promise.all(urls.map(url => limitedFetch(url)));
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const processItem = async (item) => {
|
|
25
|
+
* // Expensive async operation
|
|
26
|
+
* return await heavyComputation(item);
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* const limitedProcess = limitAsync(processItem, 2);
|
|
30
|
+
* const items = [1, 2, 3, 4, 5];
|
|
31
|
+
* // At most 2 items will be processed concurrently
|
|
32
|
+
* await Promise.all(items.map(item => limitedProcess(item)));
|
|
33
|
+
*/
|
|
34
|
+
function limitAsync(callback, concurrency) {
|
|
35
|
+
const semaphore = new Semaphore(concurrency);
|
|
36
|
+
return async function(...args) {
|
|
37
|
+
try {
|
|
38
|
+
await semaphore.acquire();
|
|
39
|
+
return await callback.apply(this, args);
|
|
40
|
+
} finally {
|
|
41
|
+
semaphore.release();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { limitAsync };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/string/dedent.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Removes common leading whitespace from each line of a multi-line string.
|
|
4
|
+
*
|
|
5
|
+
* This function can be used as a regular function, as a tagged template literal,
|
|
6
|
+
* or composed with another tag function (TC39 String.dedent proposal).
|
|
7
|
+
* It calculates the common indentation across all non-empty lines and removes it,
|
|
8
|
+
* preserving relative indentation differences between lines.
|
|
9
|
+
* The first and last lines are removed if they are empty or contain only whitespace.
|
|
10
|
+
*
|
|
11
|
+
* @param {string | TemplateStringsArray | Function} str - The string, template literal, or tag function to dedent.
|
|
12
|
+
* @param {unknown[]} values - The values to interpolate when used as a tagged template literal.
|
|
13
|
+
* @returns {string | Function} The dedented string, or a dedented tag function when composed.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // As a regular function
|
|
17
|
+
* dedent(" hello\n world"); // "hello\nworld"
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // As a tagged template literal
|
|
21
|
+
* dedent`
|
|
22
|
+
* hello
|
|
23
|
+
* world
|
|
24
|
+
* `; // "hello\nworld"
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Tag composition
|
|
28
|
+
* const html = dedent((strings, ...values) => strings.join(''));
|
|
29
|
+
* html`
|
|
30
|
+
* <div>Hello</div>
|
|
31
|
+
* `; // "<div>Hello</div>"
|
|
32
|
+
*/
|
|
33
|
+
declare function dedent(str: string): string;
|
|
34
|
+
declare function dedent(str: TemplateStringsArray, ...values: unknown[]): string;
|
|
35
|
+
declare function dedent<T>(tagFn: (strings: TemplateStringsArray, ...values: unknown[]) => T): (strings: TemplateStringsArray, ...values: unknown[]) => T;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { dedent };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/string/dedent.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Removes common leading whitespace from each line of a multi-line string.
|
|
4
|
+
*
|
|
5
|
+
* This function can be used as a regular function, as a tagged template literal,
|
|
6
|
+
* or composed with another tag function (TC39 String.dedent proposal).
|
|
7
|
+
* It calculates the common indentation across all non-empty lines and removes it,
|
|
8
|
+
* preserving relative indentation differences between lines.
|
|
9
|
+
* The first and last lines are removed if they are empty or contain only whitespace.
|
|
10
|
+
*
|
|
11
|
+
* @param {string | TemplateStringsArray | Function} str - The string, template literal, or tag function to dedent.
|
|
12
|
+
* @param {unknown[]} values - The values to interpolate when used as a tagged template literal.
|
|
13
|
+
* @returns {string | Function} The dedented string, or a dedented tag function when composed.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // As a regular function
|
|
17
|
+
* dedent(" hello\n world"); // "hello\nworld"
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // As a tagged template literal
|
|
21
|
+
* dedent`
|
|
22
|
+
* hello
|
|
23
|
+
* world
|
|
24
|
+
* `; // "hello\nworld"
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Tag composition
|
|
28
|
+
* const html = dedent((strings, ...values) => strings.join(''));
|
|
29
|
+
* html`
|
|
30
|
+
* <div>Hello</div>
|
|
31
|
+
* `; // "<div>Hello</div>"
|
|
32
|
+
*/
|
|
33
|
+
declare function dedent(str: string): string;
|
|
34
|
+
declare function dedent(str: TemplateStringsArray, ...values: unknown[]): string;
|
|
35
|
+
declare function dedent<T>(tagFn: (strings: TemplateStringsArray, ...values: unknown[]) => T): (strings: TemplateStringsArray, ...values: unknown[]) => T;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { dedent };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/string/dedent.ts
|
|
2
|
+
function dedent(str, ...values) {
|
|
3
|
+
switch (typeof str) {
|
|
4
|
+
case "function": return function(strings, ...args) {
|
|
5
|
+
return str(dedentTemplateStringsArray(strings), ...args);
|
|
6
|
+
};
|
|
7
|
+
case "string": return dedentImpl(str);
|
|
8
|
+
default: {
|
|
9
|
+
let text = str[0];
|
|
10
|
+
for (let i = 0; i < values.length; i++) text += String(values[i]) + str[i + 1];
|
|
11
|
+
return dedentImpl(text);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function dedentTemplateStringsArray(strings) {
|
|
16
|
+
const parts = dedentImpl(strings.join("\0")).split("\0");
|
|
17
|
+
return Object.assign(parts, { raw: parts });
|
|
18
|
+
}
|
|
19
|
+
function dedentImpl(text) {
|
|
20
|
+
text = text.replace(/\r\n/g, "\n");
|
|
21
|
+
const lines = text.split("\n");
|
|
22
|
+
if (lines.length > 0 && lines[0].trim() === "") lines.shift();
|
|
23
|
+
if (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
24
|
+
let commonIndent = Infinity;
|
|
25
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26
|
+
const line = lines[i];
|
|
27
|
+
if (line.trim() === "") continue;
|
|
28
|
+
let indent = 0;
|
|
29
|
+
while (indent < line.length && (line[indent] === " " || line[indent] === " ")) indent++;
|
|
30
|
+
if (indent < commonIndent) commonIndent = indent;
|
|
31
|
+
}
|
|
32
|
+
if (commonIndent === Infinity) return "";
|
|
33
|
+
for (let i = 0; i < lines.length; i++) if (lines[i].trim() === "") lines[i] = "";
|
|
34
|
+
else lines[i] = lines[i].slice(commonIndent);
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.dedent = dedent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/string/dedent.ts
|
|
2
|
+
function dedent(str, ...values) {
|
|
3
|
+
switch (typeof str) {
|
|
4
|
+
case "function": return function(strings, ...args) {
|
|
5
|
+
return str(dedentTemplateStringsArray(strings), ...args);
|
|
6
|
+
};
|
|
7
|
+
case "string": return dedentImpl(str);
|
|
8
|
+
default: {
|
|
9
|
+
let text = str[0];
|
|
10
|
+
for (let i = 0; i < values.length; i++) text += String(values[i]) + str[i + 1];
|
|
11
|
+
return dedentImpl(text);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function dedentTemplateStringsArray(strings) {
|
|
16
|
+
const parts = dedentImpl(strings.join("\0")).split("\0");
|
|
17
|
+
return Object.assign(parts, { raw: parts });
|
|
18
|
+
}
|
|
19
|
+
function dedentImpl(text) {
|
|
20
|
+
text = text.replace(/\r\n/g, "\n");
|
|
21
|
+
const lines = text.split("\n");
|
|
22
|
+
if (lines.length > 0 && lines[0].trim() === "") lines.shift();
|
|
23
|
+
if (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
24
|
+
let commonIndent = Infinity;
|
|
25
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26
|
+
const line = lines[i];
|
|
27
|
+
if (line.trim() === "") continue;
|
|
28
|
+
let indent = 0;
|
|
29
|
+
while (indent < line.length && (line[indent] === " " || line[indent] === " ")) indent++;
|
|
30
|
+
if (indent < commonIndent) commonIndent = indent;
|
|
31
|
+
}
|
|
32
|
+
if (commonIndent === Infinity) return "";
|
|
33
|
+
for (let i = 0; i < lines.length; i++) if (lines[i].trim() === "") lines[i] = "";
|
|
34
|
+
else lines[i] = lines[i].slice(commonIndent);
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { dedent };
|
package/dist/string/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { camelCase } from "./camelCase.mjs";
|
|
|
2
2
|
import { capitalize } from "./capitalize.mjs";
|
|
3
3
|
import { constantCase } from "./constantCase.mjs";
|
|
4
4
|
import { deburr } from "./deburr.mjs";
|
|
5
|
+
import { dedent } from "./dedent.mjs";
|
|
5
6
|
import { escape } from "./escape.mjs";
|
|
6
7
|
import { escapeRegExp } from "./escapeRegExp.mjs";
|
|
7
8
|
import { kebabCase } from "./kebabCase.mjs";
|
|
@@ -19,4 +20,4 @@ import { unescape } from "./unescape.mjs";
|
|
|
19
20
|
import { upperCase } from "./upperCase.mjs";
|
|
20
21
|
import { upperFirst } from "./upperFirst.mjs";
|
|
21
22
|
import { words } from "./words.mjs";
|
|
22
|
-
export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
|
23
|
+
export { camelCase, capitalize, constantCase, deburr, dedent, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
package/dist/string/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { camelCase } from "./camelCase.js";
|
|
|
2
2
|
import { capitalize } from "./capitalize.js";
|
|
3
3
|
import { constantCase } from "./constantCase.js";
|
|
4
4
|
import { deburr } from "./deburr.js";
|
|
5
|
+
import { dedent } from "./dedent.js";
|
|
5
6
|
import { escape } from "./escape.js";
|
|
6
7
|
import { escapeRegExp } from "./escapeRegExp.js";
|
|
7
8
|
import { kebabCase } from "./kebabCase.js";
|
|
@@ -19,4 +20,4 @@ import { unescape } from "./unescape.js";
|
|
|
19
20
|
import { upperCase } from "./upperCase.js";
|
|
20
21
|
import { upperFirst } from "./upperFirst.js";
|
|
21
22
|
import { words } from "./words.js";
|
|
22
|
-
export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
|
23
|
+
export { camelCase, capitalize, constantCase, deburr, dedent, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
package/dist/string/index.js
CHANGED
|
@@ -2,16 +2,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_capitalize = require("./capitalize.js");
|
|
3
3
|
const require_words = require("./words.js");
|
|
4
4
|
const require_camelCase = require("./camelCase.js");
|
|
5
|
-
const require_snakeCase = require("./snakeCase.js");
|
|
6
5
|
const require_constantCase = require("./constantCase.js");
|
|
6
|
+
const require_kebabCase = require("./kebabCase.js");
|
|
7
|
+
const require_pascalCase = require("./pascalCase.js");
|
|
8
|
+
const require_snakeCase = require("./snakeCase.js");
|
|
7
9
|
const require_deburr = require("./deburr.js");
|
|
10
|
+
const require_dedent = require("./dedent.js");
|
|
8
11
|
const require_escape = require("./escape.js");
|
|
9
12
|
const require_escapeRegExp = require("./escapeRegExp.js");
|
|
10
|
-
const require_kebabCase = require("./kebabCase.js");
|
|
11
13
|
const require_lowerCase = require("./lowerCase.js");
|
|
12
14
|
const require_lowerFirst = require("./lowerFirst.js");
|
|
13
15
|
const require_pad = require("./pad.js");
|
|
14
|
-
const require_pascalCase = require("./pascalCase.js");
|
|
15
16
|
const require_reverseString = require("./reverseString.js");
|
|
16
17
|
const require_startCase = require("./startCase.js");
|
|
17
18
|
const require_trimEnd = require("./trimEnd.js");
|
|
@@ -24,6 +25,7 @@ exports.camelCase = require_camelCase.camelCase;
|
|
|
24
25
|
exports.capitalize = require_capitalize.capitalize;
|
|
25
26
|
exports.constantCase = require_constantCase.constantCase;
|
|
26
27
|
exports.deburr = require_deburr.deburr;
|
|
28
|
+
exports.dedent = require_dedent.dedent;
|
|
27
29
|
exports.escape = require_escape.escape;
|
|
28
30
|
exports.escapeRegExp = require_escapeRegExp.escapeRegExp;
|
|
29
31
|
exports.kebabCase = require_kebabCase.kebabCase;
|
package/dist/string/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { capitalize } from "./capitalize.mjs";
|
|
2
2
|
import { words } from "./words.mjs";
|
|
3
3
|
import { camelCase } from "./camelCase.mjs";
|
|
4
|
-
import { snakeCase } from "./snakeCase.mjs";
|
|
5
4
|
import { constantCase } from "./constantCase.mjs";
|
|
5
|
+
import { kebabCase } from "./kebabCase.mjs";
|
|
6
|
+
import { pascalCase } from "./pascalCase.mjs";
|
|
7
|
+
import { snakeCase } from "./snakeCase.mjs";
|
|
6
8
|
import { deburr } from "./deburr.mjs";
|
|
9
|
+
import { dedent } from "./dedent.mjs";
|
|
7
10
|
import { escape } from "./escape.mjs";
|
|
8
11
|
import { escapeRegExp } from "./escapeRegExp.mjs";
|
|
9
|
-
import { kebabCase } from "./kebabCase.mjs";
|
|
10
12
|
import { lowerCase } from "./lowerCase.mjs";
|
|
11
13
|
import { lowerFirst } from "./lowerFirst.mjs";
|
|
12
14
|
import { pad } from "./pad.mjs";
|
|
13
|
-
import { pascalCase } from "./pascalCase.mjs";
|
|
14
15
|
import { reverseString } from "./reverseString.mjs";
|
|
15
16
|
import { startCase } from "./startCase.mjs";
|
|
16
17
|
import { trimEnd } from "./trimEnd.mjs";
|
|
@@ -19,4 +20,4 @@ import { trim } from "./trim.mjs";
|
|
|
19
20
|
import { unescape } from "./unescape.mjs";
|
|
20
21
|
import { upperCase } from "./upperCase.mjs";
|
|
21
22
|
import { upperFirst } from "./upperFirst.mjs";
|
|
22
|
-
export { camelCase, capitalize, constantCase, deburr, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
|
23
|
+
export { camelCase, capitalize, constantCase, deburr, dedent, escape, escapeRegExp, kebabCase, lowerCase, lowerFirst, pad, pascalCase, reverseString, snakeCase, startCase, trim, trimEnd, trimStart, unescape, upperCase, upperFirst, words };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToCamelCaseKeys.d.ts
|
|
4
|
+
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
|
5
|
+
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
|
6
|
+
/** 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). */
|
|
7
|
+
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Converts the keys of `T` to camelCase recursively.
|
|
10
|
+
*
|
|
11
|
+
* This is the return type of the `toCamelCaseKeys` function. Recurses into
|
|
12
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type whose keys are converted.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* type Response = { user_id: number; first_name: string };
|
|
19
|
+
* type Converted = ToCamelCaseKeys<Response>;
|
|
20
|
+
* // => { userId: number; firstName: string }
|
|
21
|
+
*/
|
|
22
|
+
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;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToCamelCaseKeys };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToCamelCaseKeys.d.ts
|
|
4
|
+
type SnakeToCamel<S extends string> = S extends `${infer H}_${infer T}` ? `${Lowercase<H>}${Capitalize<SnakeToCamel<T>>}` : Lowercase<S>;
|
|
5
|
+
type PascalToCamel<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S;
|
|
6
|
+
/** 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). */
|
|
7
|
+
type AnyToCamel<S extends string> = S extends `${string}_${string}` ? SnakeToCamel<S> : S extends Uppercase<S> ? Lowercase<S> : PascalToCamel<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Converts the keys of `T` to camelCase recursively.
|
|
10
|
+
*
|
|
11
|
+
* This is the return type of the `toCamelCaseKeys` function. Recurses into
|
|
12
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type whose keys are converted.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* type Response = { user_id: number; first_name: string };
|
|
19
|
+
* type Converted = ToCamelCaseKeys<Response>;
|
|
20
|
+
* // => { userId: number; firstName: string }
|
|
21
|
+
*/
|
|
22
|
+
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;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToCamelCaseKeys };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToConstantCaseKeys.d.ts
|
|
4
|
+
type ConstantCase<S extends string> = S extends Lowercase<S> ? Uppercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Uppercase<P1>}${ConstantCase<P2>}` : `${Uppercase<P1>}_${ConstantCase<Uncapitalize<P2>>}` : Uppercase<S>;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the keys of `T` to CONSTANT_CASE recursively.
|
|
7
|
+
*
|
|
8
|
+
* This is the return type of the `toConstantCaseKeys` function. Recurses into
|
|
9
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
10
|
+
* pass through unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type whose keys are converted.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* type Response = { userId: number; firstName: string };
|
|
16
|
+
* type Converted = ToConstantCaseKeys<Response>;
|
|
17
|
+
* // => { USER_ID: number; FIRST_NAME: string }
|
|
18
|
+
*/
|
|
19
|
+
type ToConstantCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToConstantCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as ConstantCase<string & K>]: ToConstantCaseKeys<T[K]> } : T;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ToConstantCaseKeys };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToConstantCaseKeys.d.ts
|
|
4
|
+
type ConstantCase<S extends string> = S extends Lowercase<S> ? Uppercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Uppercase<P1>}${ConstantCase<P2>}` : `${Uppercase<P1>}_${ConstantCase<Uncapitalize<P2>>}` : Uppercase<S>;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the keys of `T` to CONSTANT_CASE recursively.
|
|
7
|
+
*
|
|
8
|
+
* This is the return type of the `toConstantCaseKeys` function. Recurses into
|
|
9
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
10
|
+
* pass through unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type whose keys are converted.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* type Response = { userId: number; firstName: string };
|
|
16
|
+
* type Converted = ToConstantCaseKeys<Response>;
|
|
17
|
+
* // => { USER_ID: number; FIRST_NAME: string }
|
|
18
|
+
*/
|
|
19
|
+
type ToConstantCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToConstantCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as ConstantCase<string & K>]: ToConstantCaseKeys<T[K]> } : T;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ToConstantCaseKeys };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToKebabCaseKeys.d.ts
|
|
4
|
+
type SnakeToKebab<S extends string> = S extends `${infer P1}_${infer P2}` ? Lowercase<`${P1}-${SnakeToKebab<P2>}`> : Lowercase<S>;
|
|
5
|
+
type CamelToKebab<S extends string> = S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${CamelToKebab<P2>}` : `${Lowercase<P1>}-${CamelToKebab<Uncapitalize<P2>>}` : S;
|
|
6
|
+
type KebabCase<S extends string> = S extends `${string}_${string}` ? SnakeToKebab<S> : S extends Uppercase<S> ? Lowercase<S> : CamelToKebab<S>;
|
|
7
|
+
/**
|
|
8
|
+
* Converts the keys of `T` to kebab-case recursively.
|
|
9
|
+
*
|
|
10
|
+
* This is the return type of the `toKebabCaseKeys` function. Recurses into
|
|
11
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
12
|
+
* pass through unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type whose keys are converted.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* type Response = { userId: number; firstName: string };
|
|
18
|
+
* type Converted = ToKebabCaseKeys<Response>;
|
|
19
|
+
* // => { 'user-id': number; 'first-name': string }
|
|
20
|
+
*/
|
|
21
|
+
type ToKebabCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToKebabCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as KebabCase<string & K>]: ToKebabCaseKeys<T[K]> } : T;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ToKebabCaseKeys };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToKebabCaseKeys.d.ts
|
|
4
|
+
type SnakeToKebab<S extends string> = S extends `${infer P1}_${infer P2}` ? Lowercase<`${P1}-${SnakeToKebab<P2>}`> : Lowercase<S>;
|
|
5
|
+
type CamelToKebab<S extends string> = S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${CamelToKebab<P2>}` : `${Lowercase<P1>}-${CamelToKebab<Uncapitalize<P2>>}` : S;
|
|
6
|
+
type KebabCase<S extends string> = S extends `${string}_${string}` ? SnakeToKebab<S> : S extends Uppercase<S> ? Lowercase<S> : CamelToKebab<S>;
|
|
7
|
+
/**
|
|
8
|
+
* Converts the keys of `T` to kebab-case recursively.
|
|
9
|
+
*
|
|
10
|
+
* This is the return type of the `toKebabCaseKeys` function. Recurses into
|
|
11
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
12
|
+
* pass through unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type whose keys are converted.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* type Response = { userId: number; firstName: string };
|
|
18
|
+
* type Converted = ToKebabCaseKeys<Response>;
|
|
19
|
+
* // => { 'user-id': number; 'first-name': string }
|
|
20
|
+
*/
|
|
21
|
+
type ToKebabCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToKebabCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as KebabCase<string & K>]: ToKebabCaseKeys<T[K]> } : T;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ToKebabCaseKeys };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToPascalCaseKeys.d.ts
|
|
4
|
+
type SnakeToPascal<S extends string> = S extends `${infer H}_${infer T}` ? `${Capitalize<Lowercase<H>>}${Capitalize<SnakeToPascal<T>>}` : Capitalize<Lowercase<S>>;
|
|
5
|
+
type CamelToPascal<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
|
|
6
|
+
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase and capitalize the entire string; otherwise, just uppercase the first letter (including camelCase → PascalCase). */
|
|
7
|
+
type AnyToPascal<S extends string> = S extends `${string}_${string}` ? SnakeToPascal<S> : S extends Uppercase<S> ? Capitalize<Lowercase<S>> : CamelToPascal<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Converts the keys of `T` to PascalCase recursively.
|
|
10
|
+
*
|
|
11
|
+
* This is the return type of the `toPascalCaseKeys` function. Recurses into
|
|
12
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type whose keys are converted.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* type Response = { userId: number; firstName: string };
|
|
19
|
+
* type Converted = ToPascalCaseKeys<Response>;
|
|
20
|
+
* // => { UserId: number; FirstName: string }
|
|
21
|
+
*/
|
|
22
|
+
type ToPascalCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToPascalCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToPascal<Extract<K, string>>]: ToPascalCaseKeys<T[K]> } : T;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToPascalCaseKeys };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToPascalCaseKeys.d.ts
|
|
4
|
+
type SnakeToPascal<S extends string> = S extends `${infer H}_${infer T}` ? `${Capitalize<Lowercase<H>>}${Capitalize<SnakeToPascal<T>>}` : Capitalize<Lowercase<S>>;
|
|
5
|
+
type CamelToPascal<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
|
|
6
|
+
/** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase and capitalize the entire string; otherwise, just uppercase the first letter (including camelCase → PascalCase). */
|
|
7
|
+
type AnyToPascal<S extends string> = S extends `${string}_${string}` ? SnakeToPascal<S> : S extends Uppercase<S> ? Capitalize<Lowercase<S>> : CamelToPascal<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Converts the keys of `T` to PascalCase recursively.
|
|
10
|
+
*
|
|
11
|
+
* This is the return type of the `toPascalCaseKeys` function. Recurses into
|
|
12
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
13
|
+
* pass through unchanged.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type whose keys are converted.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* type Response = { userId: number; firstName: string };
|
|
19
|
+
* type Converted = ToPascalCaseKeys<Response>;
|
|
20
|
+
* // => { UserId: number; FirstName: string }
|
|
21
|
+
*/
|
|
22
|
+
type ToPascalCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToPascalCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as AnyToPascal<Extract<K, string>>]: ToPascalCaseKeys<T[K]> } : T;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ToPascalCaseKeys };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToSnakeCaseKeys.d.ts
|
|
4
|
+
type SnakeCase<S extends string> = S extends Uppercase<S> ? Lowercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${SnakeCase<P2>}` : `${Lowercase<P1>}_${SnakeCase<Uncapitalize<P2>>}` : Lowercase<S>;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the keys of `T` to snake_case recursively.
|
|
7
|
+
*
|
|
8
|
+
* This is the return type of the `toSnakeCaseKeys` function. Recurses into
|
|
9
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
10
|
+
* pass through unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type whose keys are converted.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* type Request = { userId: number; firstName: string };
|
|
16
|
+
* type Converted = ToSnakeCaseKeys<Request>;
|
|
17
|
+
* // => { user_id: number; first_name: string }
|
|
18
|
+
*/
|
|
19
|
+
type ToSnakeCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToSnakeCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as SnakeCase<string & K>]: ToSnakeCaseKeys<T[K]> } : T;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ToSnakeCaseKeys };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NonPlainObject } from "../_internal/NonPlainObject.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/ToSnakeCaseKeys.d.ts
|
|
4
|
+
type SnakeCase<S extends string> = S extends Uppercase<S> ? Lowercase<S> : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize<P2> ? `${Lowercase<P1>}${SnakeCase<P2>}` : `${Lowercase<P1>}_${SnakeCase<Uncapitalize<P2>>}` : Lowercase<S>;
|
|
5
|
+
/**
|
|
6
|
+
* Converts the keys of `T` to snake_case recursively.
|
|
7
|
+
*
|
|
8
|
+
* This is the return type of the `toSnakeCaseKeys` function. Recurses into
|
|
9
|
+
* plain objects and arrays; built-in objects like `Date`, `Map`, and functions
|
|
10
|
+
* pass through unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type whose keys are converted.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* type Request = { userId: number; firstName: string };
|
|
16
|
+
* type Converted = ToSnakeCaseKeys<Request>;
|
|
17
|
+
* // => { user_id: number; first_name: string }
|
|
18
|
+
*/
|
|
19
|
+
type ToSnakeCaseKeys<T> = T extends NonPlainObject ? T : T extends any[] ? Array<ToSnakeCaseKeys<T[number]>> : T extends Record<string, any> ? { [K in keyof T as SnakeCase<string & K>]: ToSnakeCaseKeys<T[K]> } : T;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ToSnakeCaseKeys };
|