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,28 @@
|
|
|
1
|
+
//#region src/fp/iterator/reduce.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and folds its elements into a
|
|
4
|
+
* single value, starting from `initial`, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.reduce`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @template U - The type of the accumulated value.
|
|
12
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
13
|
+
* @param initial - The initial accumulator value.
|
|
14
|
+
* @returns A function mapping an `Iterator<T>` to the final accumulated value.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
18
|
+
* import { reduce } from 'es-toolkit/fp/iterator';
|
|
19
|
+
*
|
|
20
|
+
* pipe([1, 2, 3].values(), reduce((acc, x) => acc + x, 0)); // => 6
|
|
21
|
+
*/
|
|
22
|
+
function reduce(callback, initial) {
|
|
23
|
+
return function reduceInIterator(source) {
|
|
24
|
+
return Iterator.from(source).reduce(callback, initial);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.reduce = reduce;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/fp/iterator/reduce.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and folds its elements into a
|
|
4
|
+
* single value, starting from `initial`, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.reduce`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @template U - The type of the accumulated value.
|
|
12
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
13
|
+
* @param initial - The initial accumulator value.
|
|
14
|
+
* @returns A function mapping an `Iterator<T>` to the final accumulated value.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
18
|
+
* import { reduce } from 'es-toolkit/fp/iterator';
|
|
19
|
+
*
|
|
20
|
+
* pipe([1, 2, 3].values(), reduce((acc, x) => acc + x, 0)); // => 6
|
|
21
|
+
*/
|
|
22
|
+
function reduce(callback, initial) {
|
|
23
|
+
return function reduceInIterator(source) {
|
|
24
|
+
return Iterator.from(source).reduce(callback, initial);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { reduce };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/scan.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the running accumulation of an iterator,
|
|
4
|
+
* emitting `initial` first and then the accumulator after each element, for use
|
|
5
|
+
* with {@link pipe}.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @template U - The type of the accumulated value.
|
|
9
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
10
|
+
* @param initial - The initial accumulator, emitted as the first value.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<U>`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { scan, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), scan((acc, x) => acc + x, 0), toArray()); // => [0, 1, 3, 6]
|
|
18
|
+
*/
|
|
19
|
+
declare function scan<T, U>(callback: (accumulator: U, value: T, index: number) => U, initial: U): (source: Iterator<T>) => IteratorObject<U, undefined>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { scan };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/scan.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the running accumulation of an iterator,
|
|
4
|
+
* emitting `initial` first and then the accumulator after each element, for use
|
|
5
|
+
* with {@link pipe}.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @template U - The type of the accumulated value.
|
|
9
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
10
|
+
* @param initial - The initial accumulator, emitted as the first value.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<U>`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { scan, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), scan((acc, x) => acc + x, 0), toArray()); // => [0, 1, 3, 6]
|
|
18
|
+
*/
|
|
19
|
+
declare function scan<T, U>(callback: (accumulator: U, value: T, index: number) => U, initial: U): (source: Iterator<T>) => IteratorObject<U, undefined>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { scan };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_scan = require("../../iterator/scan.js");
|
|
2
|
+
//#region src/fp/iterator/scan.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields the running accumulation of an iterator,
|
|
5
|
+
* emitting `initial` first and then the accumulator after each element, for use
|
|
6
|
+
* with {@link pipe}.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @template U - The type of the accumulated value.
|
|
10
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
11
|
+
* @param initial - The initial accumulator, emitted as the first value.
|
|
12
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<U>`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
16
|
+
* import { scan, toArray } from 'es-toolkit/fp/iterator';
|
|
17
|
+
*
|
|
18
|
+
* pipe([1, 2, 3].values(), scan((acc, x) => acc + x, 0), toArray()); // => [0, 1, 3, 6]
|
|
19
|
+
*/
|
|
20
|
+
function scan(callback, initial) {
|
|
21
|
+
return function scanInIterator(source) {
|
|
22
|
+
return require_scan.scan(source, callback, initial);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.scan = scan;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { scan as scan$1 } from "../../iterator/scan.mjs";
|
|
2
|
+
//#region src/fp/iterator/scan.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields the running accumulation of an iterator,
|
|
5
|
+
* emitting `initial` first and then the accumulator after each element, for use
|
|
6
|
+
* with {@link pipe}.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @template U - The type of the accumulated value.
|
|
10
|
+
* @param callback - Called with `(accumulator, value, index)`; returns the next accumulator.
|
|
11
|
+
* @param initial - The initial accumulator, emitted as the first value.
|
|
12
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<U>`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
16
|
+
* import { scan, toArray } from 'es-toolkit/fp/iterator';
|
|
17
|
+
*
|
|
18
|
+
* pipe([1, 2, 3].values(), scan((acc, x) => acc + x, 0), toArray()); // => [0, 1, 3, 6]
|
|
19
|
+
*/
|
|
20
|
+
function scan(callback, initial) {
|
|
21
|
+
return function scanInIterator(source) {
|
|
22
|
+
return scan$1(source, callback, initial);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { scan };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/iterator/some.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator until `predicate` returns truthy
|
|
4
|
+
* and reports whether any element matched, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.some` and stops
|
|
6
|
+
* pulling at the first match.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param predicate - Called with `(value, index)`; truthy short-circuits to `true`.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a boolean.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { some } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3].values(), some(x => x > 2)); // => true
|
|
17
|
+
*/
|
|
18
|
+
declare function some<T>(predicate: (value: T, index: number) => unknown): (source: Iterator<T>) => boolean;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { some };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/iterator/some.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator until `predicate` returns truthy
|
|
4
|
+
* and reports whether any element matched, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.some` and stops
|
|
6
|
+
* pulling at the first match.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param predicate - Called with `(value, index)`; truthy short-circuits to `true`.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a boolean.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { some } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3].values(), some(x => x > 2)); // => true
|
|
17
|
+
*/
|
|
18
|
+
declare function some<T>(predicate: (value: T, index: number) => unknown): (source: Iterator<T>) => boolean;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { some };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/fp/iterator/some.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator until `predicate` returns truthy
|
|
4
|
+
* and reports whether any element matched, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.some` and stops
|
|
6
|
+
* pulling at the first match.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param predicate - Called with `(value, index)`; truthy short-circuits to `true`.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a boolean.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { some } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3].values(), some(x => x > 2)); // => true
|
|
17
|
+
*/
|
|
18
|
+
function some(predicate) {
|
|
19
|
+
return function someInIterator(source) {
|
|
20
|
+
return Iterator.from(source).some(predicate);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.some = some;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/fp/iterator/some.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator until `predicate` returns truthy
|
|
4
|
+
* and reports whether any element matched, for use as the terminal step of a
|
|
5
|
+
* {@link pipe}. It delegates to the native `Iterator.prototype.some` and stops
|
|
6
|
+
* pulling at the first match.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param predicate - Called with `(value, index)`; truthy short-circuits to `true`.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a boolean.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { some } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3].values(), some(x => x > 2)); // => true
|
|
17
|
+
*/
|
|
18
|
+
function some(predicate) {
|
|
19
|
+
return function someInIterator(source) {
|
|
20
|
+
return Iterator.from(source).some(predicate);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { some };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/take.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the first `limit` elements of an
|
|
4
|
+
* iterator, for use with {@link pipe}. It delegates to the native
|
|
5
|
+
* `Iterator.prototype.take`, which stops pulling from the source once `limit`
|
|
6
|
+
* elements have been produced.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param limit - The number of elements to take; must be a non-negative integer.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
* @throws {RangeError} Throws if `limit` is negative or `NaN` (native behavior).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { take } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3, 4, 5].values(), take(3)).toArray(); // => [1, 2, 3]
|
|
18
|
+
*/
|
|
19
|
+
declare function take<T>(limit: number): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { take };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/take.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the first `limit` elements of an
|
|
4
|
+
* iterator, for use with {@link pipe}. It delegates to the native
|
|
5
|
+
* `Iterator.prototype.take`, which stops pulling from the source once `limit`
|
|
6
|
+
* elements have been produced.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param limit - The number of elements to take; must be a non-negative integer.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
* @throws {RangeError} Throws if `limit` is negative or `NaN` (native behavior).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { take } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3, 4, 5].values(), take(3)).toArray(); // => [1, 2, 3]
|
|
18
|
+
*/
|
|
19
|
+
declare function take<T>(limit: number): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { take };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/fp/iterator/take.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the first `limit` elements of an
|
|
4
|
+
* iterator, for use with {@link pipe}. It delegates to the native
|
|
5
|
+
* `Iterator.prototype.take`, which stops pulling from the source once `limit`
|
|
6
|
+
* elements have been produced.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param limit - The number of elements to take; must be a non-negative integer.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
* @throws {RangeError} Throws if `limit` is negative or `NaN` (native behavior).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { take } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3, 4, 5].values(), take(3)).toArray(); // => [1, 2, 3]
|
|
18
|
+
*/
|
|
19
|
+
function take(limit) {
|
|
20
|
+
return function takeInIterator(source) {
|
|
21
|
+
return Iterator.from(source).take(limit);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.take = take;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/fp/iterator/take.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the first `limit` elements of an
|
|
4
|
+
* iterator, for use with {@link pipe}. It delegates to the native
|
|
5
|
+
* `Iterator.prototype.take`, which stops pulling from the source once `limit`
|
|
6
|
+
* elements have been produced.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param limit - The number of elements to take; must be a non-negative integer.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
* @throws {RangeError} Throws if `limit` is negative or `NaN` (native behavior).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { take } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3, 4, 5].values(), take(3)).toArray(); // => [1, 2, 3]
|
|
18
|
+
*/
|
|
19
|
+
function take(limit) {
|
|
20
|
+
return function takeInIterator(source) {
|
|
21
|
+
return Iterator.from(source).take(limit);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { take };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/fp/iterator/takeWhile.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields elements of an iterator while
|
|
4
|
+
* `shouldContinue` returns truthy, stopping at the first failure, for use with
|
|
5
|
+
* {@link pipe}.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @param shouldContinue - Called with `(value, index)`; iteration stops once it returns falsy.
|
|
9
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
13
|
+
* import { takeWhile, toArray } from 'es-toolkit/fp/iterator';
|
|
14
|
+
*
|
|
15
|
+
* pipe([1, 2, 3, 1].values(), takeWhile(x => x < 3), toArray()); // => [1, 2]
|
|
16
|
+
*/
|
|
17
|
+
declare function takeWhile<T>(shouldContinue: (value: T, index: number) => boolean): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { takeWhile };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/fp/iterator/takeWhile.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields elements of an iterator while
|
|
4
|
+
* `shouldContinue` returns truthy, stopping at the first failure, for use with
|
|
5
|
+
* {@link pipe}.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @param shouldContinue - Called with `(value, index)`; iteration stops once it returns falsy.
|
|
9
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
13
|
+
* import { takeWhile, toArray } from 'es-toolkit/fp/iterator';
|
|
14
|
+
*
|
|
15
|
+
* pipe([1, 2, 3, 1].values(), takeWhile(x => x < 3), toArray()); // => [1, 2]
|
|
16
|
+
*/
|
|
17
|
+
declare function takeWhile<T>(shouldContinue: (value: T, index: number) => boolean): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { takeWhile };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_takeWhile = require("../../iterator/takeWhile.js");
|
|
2
|
+
//#region src/fp/iterator/takeWhile.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields elements of an iterator while
|
|
5
|
+
* `shouldContinue` returns truthy, stopping at the first failure, for use with
|
|
6
|
+
* {@link pipe}.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param shouldContinue - Called with `(value, index)`; iteration stops once it returns falsy.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { takeWhile, toArray } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3, 1].values(), takeWhile(x => x < 3), toArray()); // => [1, 2]
|
|
17
|
+
*/
|
|
18
|
+
function takeWhile(shouldContinue) {
|
|
19
|
+
return function takeWhileInIterator(source) {
|
|
20
|
+
return require_takeWhile.takeWhile(source, shouldContinue);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.takeWhile = takeWhile;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { takeWhile as takeWhile$1 } from "../../iterator/takeWhile.mjs";
|
|
2
|
+
//#region src/fp/iterator/takeWhile.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields elements of an iterator while
|
|
5
|
+
* `shouldContinue` returns truthy, stopping at the first failure, for use with
|
|
6
|
+
* {@link pipe}.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @param shouldContinue - Called with `(value, index)`; iteration stops once it returns falsy.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { takeWhile, toArray } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3, 1].values(), takeWhile(x => x < 3), toArray()); // => [1, 2]
|
|
17
|
+
*/
|
|
18
|
+
function takeWhile(shouldContinue) {
|
|
19
|
+
return function takeWhileInIterator(source) {
|
|
20
|
+
return takeWhile$1(source, shouldContinue);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { takeWhile };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/toArray.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and collects its elements into an
|
|
4
|
+
* array, for use as the terminal step of a {@link pipe}. It delegates to the
|
|
5
|
+
* native `Iterator.prototype.toArray`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a `T[]`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { map, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), map(x => x * 2), toArray()); // => [2, 4, 6]
|
|
18
|
+
*/
|
|
19
|
+
declare function toArray<T>(): (source: Iterator<T>) => T[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { toArray };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/iterator/toArray.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and collects its elements into an
|
|
4
|
+
* array, for use as the terminal step of a {@link pipe}. It delegates to the
|
|
5
|
+
* native `Iterator.prototype.toArray`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a `T[]`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { map, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), map(x => x * 2), toArray()); // => [2, 4, 6]
|
|
18
|
+
*/
|
|
19
|
+
declare function toArray<T>(): (source: Iterator<T>) => T[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { toArray };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/fp/iterator/toArray.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and collects its elements into an
|
|
4
|
+
* array, for use as the terminal step of a {@link pipe}. It delegates to the
|
|
5
|
+
* native `Iterator.prototype.toArray`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a `T[]`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { map, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), map(x => x * 2), toArray()); // => [2, 4, 6]
|
|
18
|
+
*/
|
|
19
|
+
function toArray() {
|
|
20
|
+
return function toArrayInIterator(source) {
|
|
21
|
+
return Iterator.from(source).toArray();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.toArray = toArray;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/fp/iterator/toArray.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that consumes an iterator and collects its elements into an
|
|
4
|
+
* array, for use as the terminal step of a {@link pipe}. It delegates to the
|
|
5
|
+
* native `Iterator.prototype.toArray`.
|
|
6
|
+
*
|
|
7
|
+
* This is a terminal operation: it pulls every element, so it must not be used
|
|
8
|
+
* on an infinite iterator.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements produced by the source iterator.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a `T[]`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { map, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1, 2, 3].values(), map(x => x * 2), toArray()); // => [2, 4, 6]
|
|
18
|
+
*/
|
|
19
|
+
function toArray() {
|
|
20
|
+
return function toArrayInIterator(source) {
|
|
21
|
+
return Iterator.from(source).toArray();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { toArray };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/iterator/uniqBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the elements of an iterator whose mapped
|
|
4
|
+
* key has not been seen before, preserving first-occurrence order, for use with
|
|
5
|
+
* {@link pipe}. Keys are compared with SameValueZero semantics.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @template K - The type of the key used for comparison.
|
|
9
|
+
* @param getKey - Maps an element to the key used to detect duplicates.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { uniqBy, toArray } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1.1, 1.2, 2.3].values(), uniqBy(Math.floor), toArray()); // => [1.1, 2.3]
|
|
17
|
+
*/
|
|
18
|
+
declare function uniqBy<T, K>(getKey: (value: T) => K): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { uniqBy };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/iterator/uniqBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily yields the elements of an iterator whose mapped
|
|
4
|
+
* key has not been seen before, preserving first-occurrence order, for use with
|
|
5
|
+
* {@link pipe}. Keys are compared with SameValueZero semantics.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the source iterator.
|
|
8
|
+
* @template K - The type of the key used for comparison.
|
|
9
|
+
* @param getKey - Maps an element to the key used to detect duplicates.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { uniqBy, toArray } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1.1, 1.2, 2.3].values(), uniqBy(Math.floor), toArray()); // => [1.1, 2.3]
|
|
17
|
+
*/
|
|
18
|
+
declare function uniqBy<T, K>(getKey: (value: T) => K): (source: Iterator<T>) => IteratorObject<T, undefined>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { uniqBy };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_uniqBy = require("../../iterator/uniqBy.js");
|
|
2
|
+
//#region src/fp/iterator/uniqBy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields the elements of an iterator whose mapped
|
|
5
|
+
* key has not been seen before, preserving first-occurrence order, for use with
|
|
6
|
+
* {@link pipe}. Keys are compared with SameValueZero semantics.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @template K - The type of the key used for comparison.
|
|
10
|
+
* @param getKey - Maps an element to the key used to detect duplicates.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { uniqBy, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1.1, 1.2, 2.3].values(), uniqBy(Math.floor), toArray()); // => [1.1, 2.3]
|
|
18
|
+
*/
|
|
19
|
+
function uniqBy(getKey) {
|
|
20
|
+
return function uniqByInIterator(source) {
|
|
21
|
+
return require_uniqBy.uniqBy(source, getKey);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.uniqBy = uniqBy;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { uniqBy as uniqBy$1 } from "../../iterator/uniqBy.mjs";
|
|
2
|
+
//#region src/fp/iterator/uniqBy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that lazily yields the elements of an iterator whose mapped
|
|
5
|
+
* key has not been seen before, preserving first-occurrence order, for use with
|
|
6
|
+
* {@link pipe}. Keys are compared with SameValueZero semantics.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements produced by the source iterator.
|
|
9
|
+
* @template K - The type of the key used for comparison.
|
|
10
|
+
* @param getKey - Maps an element to the key used to detect duplicates.
|
|
11
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<T>`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
15
|
+
* import { uniqBy, toArray } from 'es-toolkit/fp/iterator';
|
|
16
|
+
*
|
|
17
|
+
* pipe([1.1, 1.2, 2.3].values(), uniqBy(Math.floor), toArray()); // => [1.1, 2.3]
|
|
18
|
+
*/
|
|
19
|
+
function uniqBy(getKey) {
|
|
20
|
+
return function uniqByInIterator(source) {
|
|
21
|
+
return uniqBy$1(source, getKey);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { uniqBy };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/iterator/zip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that lazily pairs the elements of the piped iterator with
|
|
4
|
+
* those of `other`, for use with {@link pipe}. Iteration stops as soon as either
|
|
5
|
+
* iterator is exhausted.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of elements produced by the piped iterator.
|
|
8
|
+
* @template U - The type of elements produced by `other`.
|
|
9
|
+
* @param other - The iterator to pair with the piped one.
|
|
10
|
+
* @returns A function mapping an `Iterator<T>` to a lazy `IteratorObject<[T, U]>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe } from 'es-toolkit/fp';
|
|
14
|
+
* import { zip, toArray } from 'es-toolkit/fp/iterator';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2, 3].values(), zip(['a', 'b'].values()), toArray()); // => [[1, 'a'], [2, 'b']]
|
|
17
|
+
*/
|
|
18
|
+
declare function zip<T, U>(other: Iterator<U>): (source: Iterator<T>) => IteratorObject<[T, U], undefined>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { zip };
|