es-toolkit 1.48.1 → 1.49.0
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 +23 -0
- package/dist/array/chunkBy.d.mts +32 -0
- package/dist/array/chunkBy.d.ts +32 -0
- package/dist/array/chunkBy.js +42 -0
- package/dist/array/chunkBy.mjs +42 -0
- package/dist/array/index.d.mts +2 -1
- package/dist/array/index.d.ts +2 -1
- package/dist/array/index.js +2 -0
- package/dist/array/index.mjs +2 -1
- package/dist/array/take.d.mts +1 -7
- package/dist/array/take.d.ts +1 -7
- package/dist/array/take.js +1 -9
- package/dist/array/take.mjs +1 -9
- package/dist/array/takeRight.d.mts +2 -2
- package/dist/array/takeRight.d.ts +2 -2
- package/dist/array/takeRight.js +2 -4
- package/dist/array/takeRight.mjs +2 -4
- package/dist/array/windowed.d.mts +1 -1
- package/dist/array/windowed.d.ts +1 -1
- package/dist/browser.global.js +3 -3
- package/dist/compat/array/chunk.js +4 -2
- package/dist/compat/array/chunk.mjs +4 -2
- package/dist/compat/array/differenceBy.js +5 -5
- package/dist/compat/array/differenceBy.mjs +5 -5
- package/dist/compat/array/drop.d.mts +2 -3
- package/dist/compat/array/drop.d.ts +2 -3
- package/dist/compat/array/drop.js +4 -4
- package/dist/compat/array/drop.mjs +4 -4
- package/dist/compat/array/dropRight.js +1 -1
- package/dist/compat/array/dropRight.mjs +1 -1
- package/dist/compat/array/dropRightWhile.d.mts +1 -1
- package/dist/compat/array/dropRightWhile.d.ts +1 -1
- package/dist/compat/array/dropRightWhile.js +5 -4
- package/dist/compat/array/dropRightWhile.mjs +5 -4
- package/dist/compat/array/dropWhile.d.mts +2 -2
- package/dist/compat/array/dropWhile.d.ts +2 -2
- package/dist/compat/array/dropWhile.js +4 -4
- package/dist/compat/array/dropWhile.mjs +4 -4
- package/dist/compat/array/findLast.js +1 -1
- package/dist/compat/array/findLast.mjs +1 -1
- package/dist/compat/array/includes.js +1 -1
- package/dist/compat/array/includes.mjs +1 -1
- package/dist/compat/array/nth.js +1 -1
- package/dist/compat/array/nth.mjs +1 -1
- package/dist/compat/array/slice.js +1 -1
- package/dist/compat/array/slice.mjs +1 -1
- package/dist/compat/array/sortedIndexBy.js +1 -1
- package/dist/compat/array/sortedIndexBy.mjs +1 -1
- package/dist/compat/array/take.js +2 -2
- package/dist/compat/array/take.mjs +2 -2
- package/dist/compat/array/takeRight.js +1 -1
- package/dist/compat/array/takeRight.mjs +1 -1
- package/dist/compat/compat.js +4 -4
- package/dist/compat/compat.mjs +4 -4
- package/dist/compat/index.js +4 -4
- package/dist/compat/index.mjs +4 -4
- package/dist/compat/math/add.js +1 -1
- package/dist/compat/math/add.mjs +1 -1
- package/dist/compat/math/divide.js +1 -1
- package/dist/compat/math/divide.mjs +1 -1
- package/dist/compat/math/multiply.js +1 -1
- package/dist/compat/math/multiply.mjs +1 -1
- package/dist/compat/math/random.js +3 -1
- package/dist/compat/math/random.mjs +3 -1
- package/dist/compat/math/subtract.js +1 -1
- package/dist/compat/math/subtract.mjs +1 -1
- package/dist/compat/object/get.js +1 -1
- package/dist/compat/object/get.mjs +1 -1
- package/dist/compat/object/omitBy.js +1 -1
- package/dist/compat/object/omitBy.mjs +1 -1
- package/dist/compat/object/pick.js +1 -1
- package/dist/compat/object/pick.mjs +1 -1
- package/dist/compat/object/pickBy.js +1 -1
- package/dist/compat/object/pickBy.mjs +1 -1
- package/dist/compat/string/repeat.js +1 -1
- package/dist/compat/string/repeat.mjs +1 -1
- package/dist/fp/_internal/lazy.js +58 -0
- package/dist/fp/_internal/lazy.mjs +57 -0
- package/dist/fp/array/at.d.mts +20 -0
- package/dist/fp/array/at.d.ts +20 -0
- package/dist/fp/array/at.js +25 -0
- package/dist/fp/array/at.mjs +25 -0
- package/dist/fp/array/cartesianProduct.d.mts +61 -0
- package/dist/fp/array/cartesianProduct.d.ts +61 -0
- package/dist/fp/array/cartesianProduct.js +9 -0
- package/dist/fp/array/cartesianProduct.mjs +9 -0
- package/dist/fp/array/chunk.d.mts +19 -0
- package/dist/fp/array/chunk.d.ts +19 -0
- package/dist/fp/array/chunk.js +24 -0
- package/dist/fp/array/chunk.mjs +24 -0
- package/dist/fp/array/chunkBy.d.mts +20 -0
- package/dist/fp/array/chunkBy.d.ts +20 -0
- package/dist/fp/array/chunkBy.js +25 -0
- package/dist/fp/array/chunkBy.mjs +25 -0
- package/dist/fp/array/combinations.d.mts +21 -0
- package/dist/fp/array/combinations.d.ts +21 -0
- package/dist/fp/array/combinations.js +26 -0
- package/dist/fp/array/combinations.mjs +26 -0
- package/dist/fp/array/compact.d.mts +22 -0
- package/dist/fp/array/compact.d.ts +22 -0
- package/dist/fp/array/compact.js +31 -0
- package/dist/fp/array/compact.mjs +30 -0
- package/dist/fp/array/countBy.d.mts +21 -0
- package/dist/fp/array/countBy.d.ts +21 -0
- package/dist/fp/array/countBy.js +26 -0
- package/dist/fp/array/countBy.mjs +26 -0
- package/dist/fp/array/difference.d.mts +21 -0
- package/dist/fp/array/difference.d.ts +21 -0
- package/dist/fp/array/difference.js +32 -0
- package/dist/fp/array/difference.mjs +31 -0
- package/dist/fp/array/differenceBy.d.mts +22 -0
- package/dist/fp/array/differenceBy.d.ts +22 -0
- package/dist/fp/array/differenceBy.js +33 -0
- package/dist/fp/array/differenceBy.mjs +32 -0
- package/dist/fp/array/differenceWith.d.mts +22 -0
- package/dist/fp/array/differenceWith.d.ts +22 -0
- package/dist/fp/array/differenceWith.js +32 -0
- package/dist/fp/array/differenceWith.mjs +31 -0
- package/dist/fp/array/drop.d.mts +20 -0
- package/dist/fp/array/drop.d.ts +20 -0
- package/dist/fp/array/drop.js +31 -0
- package/dist/fp/array/drop.mjs +30 -0
- package/dist/fp/array/dropRight.d.mts +20 -0
- package/dist/fp/array/dropRight.d.ts +20 -0
- package/dist/fp/array/dropRight.js +25 -0
- package/dist/fp/array/dropRight.mjs +25 -0
- package/dist/fp/array/dropRightWhile.d.mts +20 -0
- package/dist/fp/array/dropRightWhile.d.ts +20 -0
- package/dist/fp/array/dropRightWhile.js +25 -0
- package/dist/fp/array/dropRightWhile.mjs +25 -0
- package/dist/fp/array/dropWhile.d.mts +20 -0
- package/dist/fp/array/dropWhile.d.ts +20 -0
- package/dist/fp/array/dropWhile.js +36 -0
- package/dist/fp/array/dropWhile.mjs +36 -0
- package/dist/fp/array/filter.d.mts +45 -0
- package/dist/fp/array/filter.d.ts +45 -0
- package/dist/fp/array/filter.js +13 -0
- package/dist/fp/array/filter.mjs +12 -0
- package/dist/fp/array/find.d.mts +39 -0
- package/dist/fp/array/find.d.ts +39 -0
- package/dist/fp/array/find.js +8 -0
- package/dist/fp/array/find.mjs +8 -0
- package/dist/fp/array/findIndex.d.mts +20 -0
- package/dist/fp/array/findIndex.d.ts +20 -0
- package/dist/fp/array/findIndex.js +24 -0
- package/dist/fp/array/findIndex.mjs +24 -0
- package/dist/fp/array/findLast.d.mts +39 -0
- package/dist/fp/array/findLast.d.ts +39 -0
- package/dist/fp/array/findLast.js +11 -0
- package/dist/fp/array/findLast.mjs +11 -0
- package/dist/fp/array/findLastIndex.d.mts +20 -0
- package/dist/fp/array/findLastIndex.d.ts +20 -0
- package/dist/fp/array/findLastIndex.js +25 -0
- package/dist/fp/array/findLastIndex.mjs +25 -0
- package/dist/fp/array/flatMap.d.mts +28 -0
- package/dist/fp/array/flatMap.d.ts +28 -0
- package/dist/fp/array/flatMap.js +39 -0
- package/dist/fp/array/flatMap.mjs +38 -0
- package/dist/fp/array/flatMapDeep.d.mts +23 -0
- package/dist/fp/array/flatMapDeep.d.ts +23 -0
- package/dist/fp/array/flatMapDeep.js +38 -0
- package/dist/fp/array/flatMapDeep.mjs +37 -0
- package/dist/fp/array/flatten.d.mts +21 -0
- package/dist/fp/array/flatten.d.ts +21 -0
- package/dist/fp/array/flatten.js +39 -0
- package/dist/fp/array/flatten.mjs +38 -0
- package/dist/fp/array/flattenDeep.d.mts +21 -0
- package/dist/fp/array/flattenDeep.d.ts +21 -0
- package/dist/fp/array/flattenDeep.js +36 -0
- package/dist/fp/array/flattenDeep.mjs +35 -0
- package/dist/fp/array/forEach.d.mts +22 -0
- package/dist/fp/array/forEach.d.ts +22 -0
- package/dist/fp/array/forEach.js +33 -0
- package/dist/fp/array/forEach.mjs +32 -0
- package/dist/fp/array/groupBy.d.mts +21 -0
- package/dist/fp/array/groupBy.d.ts +21 -0
- package/dist/fp/array/groupBy.js +26 -0
- package/dist/fp/array/groupBy.mjs +26 -0
- package/dist/fp/array/head.d.mts +35 -0
- package/dist/fp/array/head.d.ts +35 -0
- package/dist/fp/array/head.js +9 -0
- package/dist/fp/array/head.mjs +9 -0
- package/dist/fp/array/index.d.mts +69 -0
- package/dist/fp/array/index.d.ts +69 -0
- package/dist/fp/array/index.js +68 -0
- package/dist/fp/array/index.mjs +68 -0
- package/dist/fp/array/initial.d.mts +19 -0
- package/dist/fp/array/initial.d.ts +19 -0
- package/dist/fp/array/initial.js +24 -0
- package/dist/fp/array/initial.mjs +24 -0
- package/dist/fp/array/intersection.d.mts +21 -0
- package/dist/fp/array/intersection.d.ts +21 -0
- package/dist/fp/array/intersection.js +32 -0
- package/dist/fp/array/intersection.mjs +31 -0
- package/dist/fp/array/intersectionBy.d.mts +22 -0
- package/dist/fp/array/intersectionBy.d.ts +22 -0
- package/dist/fp/array/intersectionBy.js +33 -0
- package/dist/fp/array/intersectionBy.mjs +32 -0
- package/dist/fp/array/intersectionWith.d.mts +22 -0
- package/dist/fp/array/intersectionWith.d.ts +22 -0
- package/dist/fp/array/intersectionWith.js +32 -0
- package/dist/fp/array/intersectionWith.mjs +31 -0
- package/dist/fp/array/isSubset.d.mts +20 -0
- package/dist/fp/array/isSubset.d.ts +20 -0
- package/dist/fp/array/isSubset.js +25 -0
- package/dist/fp/array/isSubset.mjs +25 -0
- package/dist/fp/array/isSubsetWith.d.mts +21 -0
- package/dist/fp/array/isSubsetWith.d.ts +21 -0
- package/dist/fp/array/isSubsetWith.js +26 -0
- package/dist/fp/array/isSubsetWith.mjs +26 -0
- package/dist/fp/array/join.d.mts +20 -0
- package/dist/fp/array/join.d.ts +20 -0
- package/dist/fp/array/join.js +24 -0
- package/dist/fp/array/join.mjs +24 -0
- package/dist/fp/array/keyBy.d.mts +21 -0
- package/dist/fp/array/keyBy.d.ts +21 -0
- package/dist/fp/array/keyBy.js +26 -0
- package/dist/fp/array/keyBy.mjs +26 -0
- package/dist/fp/array/last.d.mts +35 -0
- package/dist/fp/array/last.d.ts +35 -0
- package/dist/fp/array/last.js +9 -0
- package/dist/fp/array/last.mjs +9 -0
- package/dist/fp/array/length.d.mts +18 -0
- package/dist/fp/array/length.d.ts +18 -0
- package/dist/fp/array/length.js +22 -0
- package/dist/fp/array/length.mjs +22 -0
- package/dist/fp/array/map.d.mts +27 -0
- package/dist/fp/array/map.d.ts +27 -0
- package/dist/fp/array/map.js +36 -0
- package/dist/fp/array/map.mjs +35 -0
- package/dist/fp/array/maxBy.d.mts +37 -0
- package/dist/fp/array/maxBy.d.ts +37 -0
- package/dist/fp/array/maxBy.js +9 -0
- package/dist/fp/array/maxBy.mjs +9 -0
- package/dist/fp/array/minBy.d.mts +37 -0
- package/dist/fp/array/minBy.d.ts +37 -0
- package/dist/fp/array/minBy.js +9 -0
- package/dist/fp/array/minBy.mjs +9 -0
- package/dist/fp/array/orderBy.d.mts +21 -0
- package/dist/fp/array/orderBy.d.ts +21 -0
- package/dist/fp/array/orderBy.js +26 -0
- package/dist/fp/array/orderBy.mjs +26 -0
- package/dist/fp/array/partition.d.mts +39 -0
- package/dist/fp/array/partition.d.ts +39 -0
- package/dist/fp/array/partition.js +9 -0
- package/dist/fp/array/partition.mjs +9 -0
- package/dist/fp/array/reverse.d.mts +19 -0
- package/dist/fp/array/reverse.d.ts +19 -0
- package/dist/fp/array/reverse.js +23 -0
- package/dist/fp/array/reverse.mjs +23 -0
- package/dist/fp/array/sample.d.mts +18 -0
- package/dist/fp/array/sample.d.ts +18 -0
- package/dist/fp/array/sample.js +23 -0
- package/dist/fp/array/sample.mjs +23 -0
- package/dist/fp/array/sampleSize.d.mts +20 -0
- package/dist/fp/array/sampleSize.d.ts +20 -0
- package/dist/fp/array/sampleSize.js +25 -0
- package/dist/fp/array/sampleSize.mjs +25 -0
- package/dist/fp/array/shuffle.d.mts +19 -0
- package/dist/fp/array/shuffle.d.ts +19 -0
- package/dist/fp/array/shuffle.js +24 -0
- package/dist/fp/array/shuffle.mjs +24 -0
- package/dist/fp/array/sortBy.d.mts +26 -0
- package/dist/fp/array/sortBy.d.ts +26 -0
- package/dist/fp/array/sortBy.js +31 -0
- package/dist/fp/array/sortBy.mjs +31 -0
- package/dist/fp/array/tail.d.mts +19 -0
- package/dist/fp/array/tail.d.ts +19 -0
- package/dist/fp/array/tail.js +24 -0
- package/dist/fp/array/tail.mjs +24 -0
- package/dist/fp/array/take.d.mts +26 -0
- package/dist/fp/array/take.d.ts +26 -0
- package/dist/fp/array/take.js +39 -0
- package/dist/fp/array/take.mjs +38 -0
- package/dist/fp/array/takeRight.d.mts +20 -0
- package/dist/fp/array/takeRight.d.ts +20 -0
- package/dist/fp/array/takeRight.js +25 -0
- package/dist/fp/array/takeRight.mjs +25 -0
- package/dist/fp/array/takeRightWhile.d.mts +20 -0
- package/dist/fp/array/takeRightWhile.d.ts +20 -0
- package/dist/fp/array/takeRightWhile.js +25 -0
- package/dist/fp/array/takeRightWhile.mjs +25 -0
- package/dist/fp/array/takeWhile.d.mts +21 -0
- package/dist/fp/array/takeWhile.d.ts +21 -0
- package/dist/fp/array/takeWhile.js +32 -0
- package/dist/fp/array/takeWhile.mjs +31 -0
- package/dist/fp/array/toFilled.d.mts +23 -0
- package/dist/fp/array/toFilled.d.ts +23 -0
- package/dist/fp/array/toFilled.js +30 -0
- package/dist/fp/array/toFilled.mjs +30 -0
- package/dist/fp/array/union.d.mts +20 -0
- package/dist/fp/array/union.d.ts +20 -0
- package/dist/fp/array/union.js +25 -0
- package/dist/fp/array/union.mjs +25 -0
- package/dist/fp/array/unionBy.d.mts +22 -0
- package/dist/fp/array/unionBy.d.ts +22 -0
- package/dist/fp/array/unionBy.js +27 -0
- package/dist/fp/array/unionBy.mjs +27 -0
- package/dist/fp/array/unionWith.d.mts +21 -0
- package/dist/fp/array/unionWith.d.ts +21 -0
- package/dist/fp/array/unionWith.js +26 -0
- package/dist/fp/array/unionWith.mjs +26 -0
- package/dist/fp/array/uniq.d.mts +21 -0
- package/dist/fp/array/uniq.d.ts +21 -0
- package/dist/fp/array/uniq.js +36 -0
- package/dist/fp/array/uniq.mjs +36 -0
- package/dist/fp/array/uniqBy.d.mts +21 -0
- package/dist/fp/array/uniqBy.d.ts +21 -0
- package/dist/fp/array/uniqBy.js +38 -0
- package/dist/fp/array/uniqBy.mjs +38 -0
- package/dist/fp/array/uniqWith.d.mts +20 -0
- package/dist/fp/array/uniqWith.d.ts +20 -0
- package/dist/fp/array/uniqWith.js +35 -0
- package/dist/fp/array/uniqWith.mjs +35 -0
- package/dist/fp/array/unzip.d.mts +20 -0
- package/dist/fp/array/unzip.d.ts +20 -0
- package/dist/fp/array/unzip.js +24 -0
- package/dist/fp/array/unzip.mjs +24 -0
- package/dist/fp/array/unzipWith.d.mts +21 -0
- package/dist/fp/array/unzipWith.d.ts +21 -0
- package/dist/fp/array/unzipWith.js +26 -0
- package/dist/fp/array/unzipWith.mjs +26 -0
- package/dist/fp/array/windowed.d.mts +25 -0
- package/dist/fp/array/windowed.d.ts +25 -0
- package/dist/fp/array/windowed.js +50 -0
- package/dist/fp/array/windowed.mjs +50 -0
- package/dist/fp/array/without.d.mts +19 -0
- package/dist/fp/array/without.d.ts +19 -0
- package/dist/fp/array/without.js +30 -0
- package/dist/fp/array/without.mjs +29 -0
- package/dist/fp/array/xor.d.mts +20 -0
- package/dist/fp/array/xor.d.ts +20 -0
- package/dist/fp/array/xor.js +25 -0
- package/dist/fp/array/xor.mjs +25 -0
- package/dist/fp/array/xorBy.d.mts +22 -0
- package/dist/fp/array/xorBy.d.ts +22 -0
- package/dist/fp/array/xorBy.js +27 -0
- package/dist/fp/array/xorBy.mjs +27 -0
- package/dist/fp/array/xorWith.d.mts +21 -0
- package/dist/fp/array/xorWith.d.ts +21 -0
- package/dist/fp/array/xorWith.js +26 -0
- package/dist/fp/array/xorWith.mjs +26 -0
- package/dist/fp/array/zip.d.mts +61 -0
- package/dist/fp/array/zip.d.ts +61 -0
- package/dist/fp/array/zip.js +9 -0
- package/dist/fp/array/zip.mjs +9 -0
- package/dist/fp/array/zipObject.d.mts +21 -0
- package/dist/fp/array/zipObject.d.ts +21 -0
- package/dist/fp/array/zipObject.js +26 -0
- package/dist/fp/array/zipObject.mjs +26 -0
- package/dist/fp/array/zipWith.d.mts +57 -0
- package/dist/fp/array/zipWith.d.ts +57 -0
- package/dist/fp/array/zipWith.js +9 -0
- package/dist/fp/array/zipWith.mjs +9 -0
- package/dist/fp/index.d.mts +75 -0
- package/dist/fp/index.d.ts +75 -0
- package/dist/fp/index.js +150 -0
- package/dist/fp/index.mjs +77 -0
- package/dist/fp/math/add.d.mts +17 -0
- package/dist/fp/math/add.d.ts +17 -0
- package/dist/fp/math/add.js +21 -0
- package/dist/fp/math/add.mjs +21 -0
- package/dist/fp/math/index.d.mts +2 -0
- package/dist/fp/math/index.d.ts +2 -0
- package/dist/fp/math/index.js +2 -0
- package/dist/fp/math/index.mjs +2 -0
- package/dist/fp/math/multiply.d.mts +17 -0
- package/dist/fp/math/multiply.d.ts +17 -0
- package/dist/fp/math/multiply.js +21 -0
- package/dist/fp/math/multiply.mjs +21 -0
- package/dist/fp/object/index.d.mts +2 -0
- package/dist/fp/object/index.d.ts +2 -0
- package/dist/fp/object/index.js +2 -0
- package/dist/fp/object/index.mjs +2 -0
- package/dist/fp/object/omit.d.mts +18 -0
- package/dist/fp/object/omit.d.ts +18 -0
- package/dist/fp/object/omit.js +23 -0
- package/dist/fp/object/omit.mjs +23 -0
- package/dist/fp/object/pick.d.mts +19 -0
- package/dist/fp/object/pick.d.ts +19 -0
- package/dist/fp/object/pick.js +24 -0
- package/dist/fp/object/pick.mjs +24 -0
- package/dist/fp/pipe.d.mts +235 -0
- package/dist/fp/pipe.d.ts +235 -0
- package/dist/fp/pipe.js +116 -0
- package/dist/fp/pipe.mjs +116 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -0
- package/dist/index.mjs +3 -1
- package/dist/predicate/index.d.mts +2 -1
- package/dist/predicate/index.d.ts +2 -1
- package/dist/predicate/index.js +2 -0
- package/dist/predicate/index.mjs +2 -1
- package/dist/predicate/isIterable.d.mts +26 -0
- package/dist/predicate/isIterable.d.ts +26 -0
- package/dist/predicate/isIterable.js +28 -0
- package/dist/predicate/isIterable.mjs +28 -0
- package/dist/string/trimStart.js +1 -0
- package/dist/string/trimStart.mjs +1 -0
- package/fp.d.ts +1 -0
- package/fp.js +1 -0
- package/package.json +22 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.49.0
|
|
4
|
+
|
|
5
|
+
Released on June 26th, 2026.
|
|
6
|
+
|
|
7
|
+
- Added the `es-toolkit/fp` entrypoint with data-last, pipeable utilities,
|
|
8
|
+
documentation, benchmarks, and bundle-size checks. ([#1781])
|
|
9
|
+
- Added a broad set of array utilities to `es-toolkit/fp`, covering slicing,
|
|
10
|
+
grouping, set operations, ordering, zipping, and collection helpers. ([#1801])
|
|
11
|
+
- Fixed `trimStart` to validate multi-character trim strings correctly before
|
|
12
|
+
it stops trimming. ([#1615])
|
|
13
|
+
- Fixed `compat/pick` to prefer a literal key over a dot-notation path when the
|
|
14
|
+
picked value is `undefined`. ([#1775])
|
|
15
|
+
- Fixed `compat/random` to better match Lodash behavior for coerced bounds and
|
|
16
|
+
floating-point options. ([#1767])
|
|
17
|
+
- Fixed `compat/chunk` to handle `NaN` and `Infinity` size values consistently
|
|
18
|
+
with Lodash. ([#1797])
|
|
19
|
+
- Improved documentation and JSDoc accuracy across array, function, and compat
|
|
20
|
+
references. ([#1785], [#1786], [#1788], [#1790], [#1791], [#1792], [#1793],
|
|
21
|
+
[#1795], [#1800])
|
|
22
|
+
|
|
23
|
+
We sincerely thank @Antoliny0919, @D-Sketon, @eunwoo-levi, and @raon0211 for
|
|
24
|
+
their contributions. We appreciate your great efforts!
|
|
25
|
+
|
|
3
26
|
## Version v1.48.1
|
|
4
27
|
|
|
5
28
|
Released on June 21st, 2026.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/array/chunkBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Splits an array into chunks of consecutive elements that share the same key.
|
|
4
|
+
*
|
|
5
|
+
* Walking left to right, each element's key is derived by `iteratee`. Whenever
|
|
6
|
+
* the key differs from the previous element's key, a new chunk is started;
|
|
7
|
+
* otherwise the element is appended to the current chunk. Keys are compared with
|
|
8
|
+
* `!==` (strict inequality), so equal primitives stay together while distinct
|
|
9
|
+
* object references always start a new chunk.
|
|
10
|
+
*
|
|
11
|
+
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
|
|
12
|
+
* boundary condition, keeping runs of same-keyed elements together.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of elements in the array.
|
|
15
|
+
* @param arr - The array to split into chunks.
|
|
16
|
+
* @param iteratee - A function that derives the comparison key for each element.
|
|
17
|
+
* @returns A two-dimensional array where each sub-array is a run of consecutive
|
|
18
|
+
* elements that produced the same key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Group consecutive equal numbers
|
|
22
|
+
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
|
|
23
|
+
* // Returns: [[1, 1], [2], [3, 3, 3]]
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Group consecutive words by their length
|
|
27
|
+
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
|
|
28
|
+
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
|
|
29
|
+
*/
|
|
30
|
+
declare function chunkBy<T>(arr: readonly T[], iteratee: (value: T) => unknown): T[][];
|
|
31
|
+
//#endregion
|
|
32
|
+
export { chunkBy };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/array/chunkBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Splits an array into chunks of consecutive elements that share the same key.
|
|
4
|
+
*
|
|
5
|
+
* Walking left to right, each element's key is derived by `iteratee`. Whenever
|
|
6
|
+
* the key differs from the previous element's key, a new chunk is started;
|
|
7
|
+
* otherwise the element is appended to the current chunk. Keys are compared with
|
|
8
|
+
* `!==` (strict inequality), so equal primitives stay together while distinct
|
|
9
|
+
* object references always start a new chunk.
|
|
10
|
+
*
|
|
11
|
+
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
|
|
12
|
+
* boundary condition, keeping runs of same-keyed elements together.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of elements in the array.
|
|
15
|
+
* @param arr - The array to split into chunks.
|
|
16
|
+
* @param iteratee - A function that derives the comparison key for each element.
|
|
17
|
+
* @returns A two-dimensional array where each sub-array is a run of consecutive
|
|
18
|
+
* elements that produced the same key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Group consecutive equal numbers
|
|
22
|
+
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
|
|
23
|
+
* // Returns: [[1, 1], [2], [3, 3, 3]]
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Group consecutive words by their length
|
|
27
|
+
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
|
|
28
|
+
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
|
|
29
|
+
*/
|
|
30
|
+
declare function chunkBy<T>(arr: readonly T[], iteratee: (value: T) => unknown): T[][];
|
|
31
|
+
//#endregion
|
|
32
|
+
export { chunkBy };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/array/chunkBy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Splits an array into chunks of consecutive elements that share the same key.
|
|
4
|
+
*
|
|
5
|
+
* Walking left to right, each element's key is derived by `iteratee`. Whenever
|
|
6
|
+
* the key differs from the previous element's key, a new chunk is started;
|
|
7
|
+
* otherwise the element is appended to the current chunk. Keys are compared with
|
|
8
|
+
* `!==` (strict inequality), so equal primitives stay together while distinct
|
|
9
|
+
* object references always start a new chunk.
|
|
10
|
+
*
|
|
11
|
+
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
|
|
12
|
+
* boundary condition, keeping runs of same-keyed elements together.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of elements in the array.
|
|
15
|
+
* @param arr - The array to split into chunks.
|
|
16
|
+
* @param iteratee - A function that derives the comparison key for each element.
|
|
17
|
+
* @returns A two-dimensional array where each sub-array is a run of consecutive
|
|
18
|
+
* elements that produced the same key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Group consecutive equal numbers
|
|
22
|
+
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
|
|
23
|
+
* // Returns: [[1, 1], [2], [3, 3, 3]]
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Group consecutive words by their length
|
|
27
|
+
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
|
|
28
|
+
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
|
|
29
|
+
*/
|
|
30
|
+
function chunkBy(arr, iteratee) {
|
|
31
|
+
const result = [];
|
|
32
|
+
let prevKey;
|
|
33
|
+
for (let i = 0; i < arr.length; i++) {
|
|
34
|
+
const key = iteratee(arr[i]);
|
|
35
|
+
if (i === 0 || key !== prevKey) result.push([arr[i]]);
|
|
36
|
+
else result[result.length - 1].push(arr[i]);
|
|
37
|
+
prevKey = key;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.chunkBy = chunkBy;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/array/chunkBy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Splits an array into chunks of consecutive elements that share the same key.
|
|
4
|
+
*
|
|
5
|
+
* Walking left to right, each element's key is derived by `iteratee`. Whenever
|
|
6
|
+
* the key differs from the previous element's key, a new chunk is started;
|
|
7
|
+
* otherwise the element is appended to the current chunk. Keys are compared with
|
|
8
|
+
* `!==` (strict inequality), so equal primitives stay together while distinct
|
|
9
|
+
* object references always start a new chunk.
|
|
10
|
+
*
|
|
11
|
+
* Unlike {@link chunk}, which splits by a fixed size, `chunkBy` splits by a
|
|
12
|
+
* boundary condition, keeping runs of same-keyed elements together.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of elements in the array.
|
|
15
|
+
* @param arr - The array to split into chunks.
|
|
16
|
+
* @param iteratee - A function that derives the comparison key for each element.
|
|
17
|
+
* @returns A two-dimensional array where each sub-array is a run of consecutive
|
|
18
|
+
* elements that produced the same key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Group consecutive equal numbers
|
|
22
|
+
* chunkBy([1, 1, 2, 3, 3, 3], value => value);
|
|
23
|
+
* // Returns: [[1, 1], [2], [3, 3, 3]]
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Group consecutive words by their length
|
|
27
|
+
* chunkBy(['a', 'b', 'cd', 'ef', 'g'], word => word.length);
|
|
28
|
+
* // Returns: [['a', 'b'], ['cd', 'ef'], ['g']]
|
|
29
|
+
*/
|
|
30
|
+
function chunkBy(arr, iteratee) {
|
|
31
|
+
const result = [];
|
|
32
|
+
let prevKey;
|
|
33
|
+
for (let i = 0; i < arr.length; i++) {
|
|
34
|
+
const key = iteratee(arr[i]);
|
|
35
|
+
if (i === 0 || key !== prevKey) result.push([arr[i]]);
|
|
36
|
+
else result[result.length - 1].push(arr[i]);
|
|
37
|
+
prevKey = key;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { chunkBy };
|
package/dist/array/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { at } from "./at.mjs";
|
|
2
2
|
import { cartesianProduct } from "./cartesianProduct.mjs";
|
|
3
3
|
import { chunk } from "./chunk.mjs";
|
|
4
|
+
import { chunkBy } from "./chunkBy.mjs";
|
|
4
5
|
import { combinations } from "./combinations.mjs";
|
|
5
6
|
import { compact } from "./compact.mjs";
|
|
6
7
|
import { countBy } from "./countBy.mjs";
|
|
@@ -66,4 +67,4 @@ import { xorWith } from "./xorWith.mjs";
|
|
|
66
67
|
import { zip } from "./zip.mjs";
|
|
67
68
|
import { zipObject } from "./zipObject.mjs";
|
|
68
69
|
import { zipWith } from "./zipWith.mjs";
|
|
69
|
-
export { at, cartesianProduct, chunk, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
70
|
+
export { at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
package/dist/array/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { at } from "./at.js";
|
|
2
2
|
import { cartesianProduct } from "./cartesianProduct.js";
|
|
3
3
|
import { chunk } from "./chunk.js";
|
|
4
|
+
import { chunkBy } from "./chunkBy.js";
|
|
4
5
|
import { combinations } from "./combinations.js";
|
|
5
6
|
import { compact } from "./compact.js";
|
|
6
7
|
import { countBy } from "./countBy.js";
|
|
@@ -66,4 +67,4 @@ import { xorWith } from "./xorWith.js";
|
|
|
66
67
|
import { zip } from "./zip.js";
|
|
67
68
|
import { zipObject } from "./zipObject.js";
|
|
68
69
|
import { zipWith } from "./zipWith.js";
|
|
69
|
-
export { at, cartesianProduct, chunk, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
70
|
+
export { at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
package/dist/array/index.js
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_at = require("./at.js");
|
|
3
3
|
const require_cartesianProduct = require("./cartesianProduct.js");
|
|
4
4
|
const require_chunk = require("./chunk.js");
|
|
5
|
+
const require_chunkBy = require("./chunkBy.js");
|
|
5
6
|
const require_combinations = require("./combinations.js");
|
|
6
7
|
const require_compact = require("./compact.js");
|
|
7
8
|
const require_countBy = require("./countBy.js");
|
|
@@ -70,6 +71,7 @@ const require_zipWith = require("./zipWith.js");
|
|
|
70
71
|
exports.at = require_at.at;
|
|
71
72
|
exports.cartesianProduct = require_cartesianProduct.cartesianProduct;
|
|
72
73
|
exports.chunk = require_chunk.chunk;
|
|
74
|
+
exports.chunkBy = require_chunkBy.chunkBy;
|
|
73
75
|
exports.combinations = require_combinations.combinations;
|
|
74
76
|
exports.compact = require_compact.compact;
|
|
75
77
|
exports.countBy = require_countBy.countBy;
|
package/dist/array/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { at } from "./at.mjs";
|
|
2
2
|
import { cartesianProduct } from "./cartesianProduct.mjs";
|
|
3
3
|
import { chunk } from "./chunk.mjs";
|
|
4
|
+
import { chunkBy } from "./chunkBy.mjs";
|
|
4
5
|
import { combinations } from "./combinations.mjs";
|
|
5
6
|
import { compact } from "./compact.mjs";
|
|
6
7
|
import { countBy } from "./countBy.mjs";
|
|
@@ -66,4 +67,4 @@ import { xorWith } from "./xorWith.mjs";
|
|
|
66
67
|
import { zip } from "./zip.mjs";
|
|
67
68
|
import { zipObject } from "./zipObject.mjs";
|
|
68
69
|
import { zipWith } from "./zipWith.mjs";
|
|
69
|
-
export { at, cartesianProduct, chunk, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
70
|
+
export { at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, filterAsync, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, forEachAsync, forEachRight, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, keyBy, last, limitAsync, mapAsync, maxBy, minBy, orderBy, partition, pull, pullAt, reduceAsync, remove, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
package/dist/array/take.d.mts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @param arr - The array to take elements from.
|
|
9
9
|
* @param count - The number of elements to take.
|
|
10
|
-
* @param guard - If truthy, ignores `count` and defaults to 1.
|
|
11
10
|
* @returns A new array containing the first `count` elements from `arr`.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
@@ -21,12 +20,7 @@
|
|
|
21
20
|
* @example
|
|
22
21
|
* // Returns [1, 2, 3]
|
|
23
22
|
* take([1, 2, 3], 5);
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // Returns [[1], [1], [1]]
|
|
27
|
-
* const arr = [1, 2, 3];
|
|
28
|
-
* const result = arr.map((v, i, array) => take(array, i, true));
|
|
29
23
|
*/
|
|
30
|
-
declare function take<T>(arr: readonly T[], count
|
|
24
|
+
declare function take<T>(arr: readonly T[], count: number): T[];
|
|
31
25
|
//#endregion
|
|
32
26
|
export { take };
|
package/dist/array/take.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @param arr - The array to take elements from.
|
|
9
9
|
* @param count - The number of elements to take.
|
|
10
|
-
* @param guard - If truthy, ignores `count` and defaults to 1.
|
|
11
10
|
* @returns A new array containing the first `count` elements from `arr`.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
@@ -21,12 +20,7 @@
|
|
|
21
20
|
* @example
|
|
22
21
|
* // Returns [1, 2, 3]
|
|
23
22
|
* take([1, 2, 3], 5);
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // Returns [[1], [1], [1]]
|
|
27
|
-
* const arr = [1, 2, 3];
|
|
28
|
-
* const result = arr.map((v, i, array) => take(array, i, true));
|
|
29
23
|
*/
|
|
30
|
-
declare function take<T>(arr: readonly T[], count
|
|
24
|
+
declare function take<T>(arr: readonly T[], count: number): T[];
|
|
31
25
|
//#endregion
|
|
32
26
|
export { take };
|
package/dist/array/take.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const require_toInteger = require("../compat/util/toInteger.js");
|
|
2
1
|
//#region src/array/take.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns a new array containing the first `count` elements from the input array `arr`.
|
|
@@ -8,7 +7,6 @@ const require_toInteger = require("../compat/util/toInteger.js");
|
|
|
8
7
|
*
|
|
9
8
|
* @param arr - The array to take elements from.
|
|
10
9
|
* @param count - The number of elements to take.
|
|
11
|
-
* @param guard - If truthy, ignores `count` and defaults to 1.
|
|
12
10
|
* @returns A new array containing the first `count` elements from `arr`.
|
|
13
11
|
*
|
|
14
12
|
* @example
|
|
@@ -22,14 +20,8 @@ const require_toInteger = require("../compat/util/toInteger.js");
|
|
|
22
20
|
* @example
|
|
23
21
|
* // Returns [1, 2, 3]
|
|
24
22
|
* take([1, 2, 3], 5);
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Returns [[1], [1], [1]]
|
|
28
|
-
* const arr = [1, 2, 3];
|
|
29
|
-
* const result = arr.map((v, i, array) => take(array, i, true));
|
|
30
23
|
*/
|
|
31
|
-
function take(arr, count
|
|
32
|
-
count = guard || count === void 0 ? 1 : require_toInteger.toInteger(count);
|
|
24
|
+
function take(arr, count) {
|
|
33
25
|
return arr.slice(0, count);
|
|
34
26
|
}
|
|
35
27
|
//#endregion
|
package/dist/array/take.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { toInteger } from "../compat/util/toInteger.mjs";
|
|
2
1
|
//#region src/array/take.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns a new array containing the first `count` elements from the input array `arr`.
|
|
@@ -8,7 +7,6 @@ import { toInteger } from "../compat/util/toInteger.mjs";
|
|
|
8
7
|
*
|
|
9
8
|
* @param arr - The array to take elements from.
|
|
10
9
|
* @param count - The number of elements to take.
|
|
11
|
-
* @param guard - If truthy, ignores `count` and defaults to 1.
|
|
12
10
|
* @returns A new array containing the first `count` elements from `arr`.
|
|
13
11
|
*
|
|
14
12
|
* @example
|
|
@@ -22,14 +20,8 @@ import { toInteger } from "../compat/util/toInteger.mjs";
|
|
|
22
20
|
* @example
|
|
23
21
|
* // Returns [1, 2, 3]
|
|
24
22
|
* take([1, 2, 3], 5);
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Returns [[1], [1], [1]]
|
|
28
|
-
* const arr = [1, 2, 3];
|
|
29
|
-
* const result = arr.map((v, i, array) => take(array, i, true));
|
|
30
23
|
*/
|
|
31
|
-
function take(arr, count
|
|
32
|
-
count = guard || count === void 0 ? 1 : toInteger(count);
|
|
24
|
+
function take(arr, count) {
|
|
33
25
|
return arr.slice(0, count);
|
|
34
26
|
}
|
|
35
27
|
//#endregion
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @template T - The type of elements in the array.
|
|
7
7
|
* @param arr - The array to take elements from.
|
|
8
|
-
* @param
|
|
8
|
+
* @param count - The number of elements to take.
|
|
9
9
|
* @returns A new array containing the last `count` elements from `arr`.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
* // Returns [1, 2, 3]
|
|
21
21
|
* takeRight([1, 2, 3], 5);
|
|
22
22
|
*/
|
|
23
|
-
declare function takeRight<T>(arr: readonly T[], count
|
|
23
|
+
declare function takeRight<T>(arr: readonly T[], count: number): T[];
|
|
24
24
|
//#endregion
|
|
25
25
|
export { takeRight };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @template T - The type of elements in the array.
|
|
7
7
|
* @param arr - The array to take elements from.
|
|
8
|
-
* @param
|
|
8
|
+
* @param count - The number of elements to take.
|
|
9
9
|
* @returns A new array containing the last `count` elements from `arr`.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
* // Returns [1, 2, 3]
|
|
21
21
|
* takeRight([1, 2, 3], 5);
|
|
22
22
|
*/
|
|
23
|
-
declare function takeRight<T>(arr: readonly T[], count
|
|
23
|
+
declare function takeRight<T>(arr: readonly T[], count: number): T[];
|
|
24
24
|
//#endregion
|
|
25
25
|
export { takeRight };
|
package/dist/array/takeRight.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const require_toInteger = require("../compat/util/toInteger.js");
|
|
2
1
|
//#region src/array/takeRight.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns a new array containing the last `count` elements from the input array `arr`.
|
|
@@ -6,7 +5,7 @@ const require_toInteger = require("../compat/util/toInteger.js");
|
|
|
6
5
|
*
|
|
7
6
|
* @template T - The type of elements in the array.
|
|
8
7
|
* @param arr - The array to take elements from.
|
|
9
|
-
* @param
|
|
8
|
+
* @param count - The number of elements to take.
|
|
10
9
|
* @returns A new array containing the last `count` elements from `arr`.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
@@ -21,8 +20,7 @@ const require_toInteger = require("../compat/util/toInteger.js");
|
|
|
21
20
|
* // Returns [1, 2, 3]
|
|
22
21
|
* takeRight([1, 2, 3], 5);
|
|
23
22
|
*/
|
|
24
|
-
function takeRight(arr, count
|
|
25
|
-
count = guard || count === void 0 ? 1 : require_toInteger.toInteger(count);
|
|
23
|
+
function takeRight(arr, count) {
|
|
26
24
|
if (count <= 0 || arr.length === 0) return [];
|
|
27
25
|
return arr.slice(-count);
|
|
28
26
|
}
|
package/dist/array/takeRight.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { toInteger } from "../compat/util/toInteger.mjs";
|
|
2
1
|
//#region src/array/takeRight.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns a new array containing the last `count` elements from the input array `arr`.
|
|
@@ -6,7 +5,7 @@ import { toInteger } from "../compat/util/toInteger.mjs";
|
|
|
6
5
|
*
|
|
7
6
|
* @template T - The type of elements in the array.
|
|
8
7
|
* @param arr - The array to take elements from.
|
|
9
|
-
* @param
|
|
8
|
+
* @param count - The number of elements to take.
|
|
10
9
|
* @returns A new array containing the last `count` elements from `arr`.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
@@ -21,8 +20,7 @@ import { toInteger } from "../compat/util/toInteger.mjs";
|
|
|
21
20
|
* // Returns [1, 2, 3]
|
|
22
21
|
* takeRight([1, 2, 3], 5);
|
|
23
22
|
*/
|
|
24
|
-
function takeRight(arr, count
|
|
25
|
-
count = guard || count === void 0 ? 1 : toInteger(count);
|
|
23
|
+
function takeRight(arr, count) {
|
|
26
24
|
if (count <= 0 || arr.length === 0) return [];
|
|
27
25
|
return arr.slice(-count);
|
|
28
26
|
}
|
package/dist/array/windowed.d.ts
CHANGED