es-toolkit 1.48.1-dev.1889 → 1.48.1-dev.1894
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/drop.js +1 -1
- package/dist/compat/array/drop.mjs +1 -1
- package/dist/compat/array/dropRight.js +1 -1
- package/dist/compat/array/dropRight.mjs +1 -1
- 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/subtract.js +1 -1
- package/dist/compat/math/subtract.mjs +1 -1
- package/dist/compat/object/omitBy.js +1 -1
- package/dist/compat/object/omitBy.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/fp.d.ts +1 -0
- package/fp.js +1 -0
- package/package.json +22 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/fp/array/xor.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that returns the symmetric difference with secondArray.
|
|
4
|
+
*
|
|
5
|
+
* The result contains values that appear in exactly one of the arrays, matching the main
|
|
6
|
+
* {@link xor} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the arrays.
|
|
9
|
+
* @param secondArray - Values to compare with the piped array.
|
|
10
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { pipe, xor } from 'es-toolkit/fp';
|
|
14
|
+
*
|
|
15
|
+
* pipe([1, 2], xor([2, 3]));
|
|
16
|
+
* // => [1, 3]
|
|
17
|
+
*/
|
|
18
|
+
declare function xor<T>(secondArray: readonly T[]): (array: readonly T[]) => T[];
|
|
19
|
+
//#endregion
|
|
20
|
+
export { xor };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_xor = require("../../array/xor.js");
|
|
2
|
+
//#region src/fp/array/xor.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference with secondArray.
|
|
5
|
+
*
|
|
6
|
+
* The result contains values that appear in exactly one of the arrays, matching the main
|
|
7
|
+
* {@link xor} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, xor } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2], xor([2, 3]));
|
|
17
|
+
* // => [1, 3]
|
|
18
|
+
*/
|
|
19
|
+
function xor(secondArray) {
|
|
20
|
+
return function(array) {
|
|
21
|
+
return require_xor.xor(array, secondArray);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.xor = xor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { xor as xor$1 } from "../../array/xor.mjs";
|
|
2
|
+
//#region src/fp/array/xor.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference with secondArray.
|
|
5
|
+
*
|
|
6
|
+
* The result contains values that appear in exactly one of the arrays, matching the main
|
|
7
|
+
* {@link xor} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, xor } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe([1, 2], xor([2, 3]));
|
|
17
|
+
* // => [1, 3]
|
|
18
|
+
*/
|
|
19
|
+
function xor(secondArray) {
|
|
20
|
+
return function(array) {
|
|
21
|
+
return xor$1(array, secondArray);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { xor };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/fp/array/xorBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that returns the symmetric difference by mapped identity.
|
|
4
|
+
*
|
|
5
|
+
* The mapper is used to decide which values appear in exactly one array, matching the main
|
|
6
|
+
* {@link xorBy} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the arrays.
|
|
9
|
+
* @template U - The type of comparison keys returned by the mapper.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @param mapper - Called for values from both arrays to produce comparison keys.
|
|
12
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, xorBy } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id));
|
|
18
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
19
|
+
*/
|
|
20
|
+
declare function xorBy<T, U>(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { xorBy };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/fp/array/xorBy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that returns the symmetric difference by mapped identity.
|
|
4
|
+
*
|
|
5
|
+
* The mapper is used to decide which values appear in exactly one array, matching the main
|
|
6
|
+
* {@link xorBy} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the arrays.
|
|
9
|
+
* @template U - The type of comparison keys returned by the mapper.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @param mapper - Called for values from both arrays to produce comparison keys.
|
|
12
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, xorBy } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id));
|
|
18
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
19
|
+
*/
|
|
20
|
+
declare function xorBy<T, U>(secondArray: readonly T[], mapper: (item: T) => U): (array: readonly T[]) => T[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { xorBy };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_xorBy = require("../../array/xorBy.js");
|
|
2
|
+
//#region src/fp/array/xorBy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference by mapped identity.
|
|
5
|
+
*
|
|
6
|
+
* The mapper is used to decide which values appear in exactly one array, matching the main
|
|
7
|
+
* {@link xorBy} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @template U - The type of comparison keys returned by the mapper.
|
|
11
|
+
* @param secondArray - Values to compare with the piped array.
|
|
12
|
+
* @param mapper - Called for values from both arrays to produce comparison keys.
|
|
13
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { pipe, xorBy } from 'es-toolkit/fp';
|
|
17
|
+
*
|
|
18
|
+
* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id));
|
|
19
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
20
|
+
*/
|
|
21
|
+
function xorBy(secondArray, mapper) {
|
|
22
|
+
return function(array) {
|
|
23
|
+
return require_xorBy.xorBy(array, secondArray, mapper);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.xorBy = xorBy;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { xorBy as xorBy$1 } from "../../array/xorBy.mjs";
|
|
2
|
+
//#region src/fp/array/xorBy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference by mapped identity.
|
|
5
|
+
*
|
|
6
|
+
* The mapper is used to decide which values appear in exactly one array, matching the main
|
|
7
|
+
* {@link xorBy} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @template U - The type of comparison keys returned by the mapper.
|
|
11
|
+
* @param secondArray - Values to compare with the piped array.
|
|
12
|
+
* @param mapper - Called for values from both arrays to produce comparison keys.
|
|
13
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { pipe, xorBy } from 'es-toolkit/fp';
|
|
17
|
+
*
|
|
18
|
+
* pipe([{ id: 1 }, { id: 2 }], xorBy([{ id: 2 }, { id: 3 }], item => item.id));
|
|
19
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
20
|
+
*/
|
|
21
|
+
function xorBy(secondArray, mapper) {
|
|
22
|
+
return function(array) {
|
|
23
|
+
return xorBy$1(array, secondArray, mapper);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { xorBy };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/array/xorWith.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that returns the symmetric difference using a custom equality function.
|
|
4
|
+
*
|
|
5
|
+
* The equality function decides whether two values represent the same item, matching the
|
|
6
|
+
* main {@link xorWith} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the arrays.
|
|
9
|
+
* @param secondArray - Values to compare with the piped array.
|
|
10
|
+
* @param areItemsEqual - Returns true when two values are equal.
|
|
11
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, xorWith } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id));
|
|
17
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
18
|
+
*/
|
|
19
|
+
declare function xorWith<T>(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { xorWith };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/array/xorWith.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that returns the symmetric difference using a custom equality function.
|
|
4
|
+
*
|
|
5
|
+
* The equality function decides whether two values represent the same item, matching the
|
|
6
|
+
* main {@link xorWith} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the arrays.
|
|
9
|
+
* @param secondArray - Values to compare with the piped array.
|
|
10
|
+
* @param areItemsEqual - Returns true when two values are equal.
|
|
11
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, xorWith } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id));
|
|
17
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
18
|
+
*/
|
|
19
|
+
declare function xorWith<T>(secondArray: readonly T[], areItemsEqual: (item: T, other: T) => boolean): (array: readonly T[]) => T[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { xorWith };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_xorWith = require("../../array/xorWith.js");
|
|
2
|
+
//#region src/fp/array/xorWith.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference using a custom equality function.
|
|
5
|
+
*
|
|
6
|
+
* The equality function decides whether two values represent the same item, matching the
|
|
7
|
+
* main {@link xorWith} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @param areItemsEqual - Returns true when two values are equal.
|
|
12
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, xorWith } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id));
|
|
18
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
19
|
+
*/
|
|
20
|
+
function xorWith(secondArray, areItemsEqual) {
|
|
21
|
+
return function(array) {
|
|
22
|
+
return require_xorWith.xorWith(array, secondArray, areItemsEqual);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.xorWith = xorWith;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { xorWith as xorWith$1 } from "../../array/xorWith.mjs";
|
|
2
|
+
//#region src/fp/array/xorWith.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that returns the symmetric difference using a custom equality function.
|
|
5
|
+
*
|
|
6
|
+
* The equality function decides whether two values represent the same item, matching the
|
|
7
|
+
* main {@link xorWith} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of elements in the arrays.
|
|
10
|
+
* @param secondArray - Values to compare with the piped array.
|
|
11
|
+
* @param areItemsEqual - Returns true when two values are equal.
|
|
12
|
+
* @returns A function that maps a readonly array to its symmetric difference.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, xorWith } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe([{ id: 1 }, { id: 2 }], xorWith([{ id: 2 }, { id: 3 }], (a, b) => a.id === b.id));
|
|
18
|
+
* // => [{ id: 1 }, { id: 3 }]
|
|
19
|
+
*/
|
|
20
|
+
function xorWith(secondArray, areItemsEqual) {
|
|
21
|
+
return function(array) {
|
|
22
|
+
return xorWith$1(array, secondArray, areItemsEqual);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { xorWith };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/fp/array/zip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that wraps each element of the piped array in a one-item tuple.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the piped array.
|
|
6
|
+
* @returns A function that maps the piped array to one-item tuples.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { pipe, zip } from 'es-toolkit/fp';
|
|
10
|
+
*
|
|
11
|
+
* pipe([1, 2], zip());
|
|
12
|
+
* // => [[1], [2]]
|
|
13
|
+
*/
|
|
14
|
+
declare function zip<T>(): (array: readonly T[]) => Array<[T]>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a function that zips the piped array with one configured array.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of elements in the piped array.
|
|
19
|
+
* @template U - The type of elements in the configured array.
|
|
20
|
+
* @param arr2 - The second array to zip.
|
|
21
|
+
* @returns A function that maps the piped array to two-item tuples.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* pipe([1, 2], zip(['a', 'b']));
|
|
25
|
+
* // => [[1, 'a'], [2, 'b']]
|
|
26
|
+
*/
|
|
27
|
+
declare function zip<T, U>(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a function that zips the piped array with two configured arrays.
|
|
30
|
+
*
|
|
31
|
+
* @template T - The type of elements in the piped array.
|
|
32
|
+
* @template U - The type of elements in the second array.
|
|
33
|
+
* @template V - The type of elements in the third array.
|
|
34
|
+
* @param arr2 - The second array to zip.
|
|
35
|
+
* @param arr3 - The third array to zip.
|
|
36
|
+
* @returns A function that maps the piped array to three-item tuples.
|
|
37
|
+
*/
|
|
38
|
+
declare function zip<T, U, V>(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a function that zips the piped array with three configured arrays.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type of elements in the piped array.
|
|
43
|
+
* @template U - The type of elements in the second array.
|
|
44
|
+
* @template V - The type of elements in the third array.
|
|
45
|
+
* @template W - The type of elements in the fourth array.
|
|
46
|
+
* @param arr2 - The second array to zip.
|
|
47
|
+
* @param arr3 - The third array to zip.
|
|
48
|
+
* @param arr4 - The fourth array to zip.
|
|
49
|
+
* @returns A function that maps the piped array to four-item tuples.
|
|
50
|
+
*/
|
|
51
|
+
declare function zip<T, U, V, W>(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a function that zips the piped array with any number of configured arrays.
|
|
54
|
+
*
|
|
55
|
+
* @template T - The shared element type of the arrays.
|
|
56
|
+
* @param arrs - Additional arrays to zip.
|
|
57
|
+
* @returns A function that maps the piped array to grouped rows.
|
|
58
|
+
*/
|
|
59
|
+
declare function zip<T>(...arrs: Array<readonly T[]>): (array: readonly T[]) => T[][];
|
|
60
|
+
//#endregion
|
|
61
|
+
export { zip };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/fp/array/zip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that wraps each element of the piped array in a one-item tuple.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the piped array.
|
|
6
|
+
* @returns A function that maps the piped array to one-item tuples.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { pipe, zip } from 'es-toolkit/fp';
|
|
10
|
+
*
|
|
11
|
+
* pipe([1, 2], zip());
|
|
12
|
+
* // => [[1], [2]]
|
|
13
|
+
*/
|
|
14
|
+
declare function zip<T>(): (array: readonly T[]) => Array<[T]>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a function that zips the piped array with one configured array.
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of elements in the piped array.
|
|
19
|
+
* @template U - The type of elements in the configured array.
|
|
20
|
+
* @param arr2 - The second array to zip.
|
|
21
|
+
* @returns A function that maps the piped array to two-item tuples.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* pipe([1, 2], zip(['a', 'b']));
|
|
25
|
+
* // => [[1, 'a'], [2, 'b']]
|
|
26
|
+
*/
|
|
27
|
+
declare function zip<T, U>(arr2: readonly U[]): (array: readonly T[]) => Array<[T, U]>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a function that zips the piped array with two configured arrays.
|
|
30
|
+
*
|
|
31
|
+
* @template T - The type of elements in the piped array.
|
|
32
|
+
* @template U - The type of elements in the second array.
|
|
33
|
+
* @template V - The type of elements in the third array.
|
|
34
|
+
* @param arr2 - The second array to zip.
|
|
35
|
+
* @param arr3 - The third array to zip.
|
|
36
|
+
* @returns A function that maps the piped array to three-item tuples.
|
|
37
|
+
*/
|
|
38
|
+
declare function zip<T, U, V>(arr2: readonly U[], arr3: readonly V[]): (array: readonly T[]) => Array<[T, U, V]>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a function that zips the piped array with three configured arrays.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type of elements in the piped array.
|
|
43
|
+
* @template U - The type of elements in the second array.
|
|
44
|
+
* @template V - The type of elements in the third array.
|
|
45
|
+
* @template W - The type of elements in the fourth array.
|
|
46
|
+
* @param arr2 - The second array to zip.
|
|
47
|
+
* @param arr3 - The third array to zip.
|
|
48
|
+
* @param arr4 - The fourth array to zip.
|
|
49
|
+
* @returns A function that maps the piped array to four-item tuples.
|
|
50
|
+
*/
|
|
51
|
+
declare function zip<T, U, V, W>(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): (array: readonly T[]) => Array<[T, U, V, W]>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a function that zips the piped array with any number of configured arrays.
|
|
54
|
+
*
|
|
55
|
+
* @template T - The shared element type of the arrays.
|
|
56
|
+
* @param arrs - Additional arrays to zip.
|
|
57
|
+
* @returns A function that maps the piped array to grouped rows.
|
|
58
|
+
*/
|
|
59
|
+
declare function zip<T>(...arrs: Array<readonly T[]>): (array: readonly T[]) => T[][];
|
|
60
|
+
//#endregion
|
|
61
|
+
export { zip };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/array/zipObject.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that builds an object from the piped keys and configured values.
|
|
4
|
+
*
|
|
5
|
+
* Keys are read from the piped array and paired with values by index, matching the main
|
|
6
|
+
* {@link zipObject} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template P - The property-key type from the piped keys.
|
|
9
|
+
* @template V - The type of configured values.
|
|
10
|
+
* @param values - Values assigned to the piped keys by index.
|
|
11
|
+
* @returns A function that maps keys to an object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, zipObject } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe(['a', 'b'] as const, zipObject([1, 2]));
|
|
17
|
+
* // => { a: 1, b: 2 }
|
|
18
|
+
*/
|
|
19
|
+
declare function zipObject<P extends PropertyKey, V>(values: readonly V[]): (keys: readonly P[]) => Record<P, V>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { zipObject };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fp/array/zipObject.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that builds an object from the piped keys and configured values.
|
|
4
|
+
*
|
|
5
|
+
* Keys are read from the piped array and paired with values by index, matching the main
|
|
6
|
+
* {@link zipObject} behavior.
|
|
7
|
+
*
|
|
8
|
+
* @template P - The property-key type from the piped keys.
|
|
9
|
+
* @template V - The type of configured values.
|
|
10
|
+
* @param values - Values assigned to the piped keys by index.
|
|
11
|
+
* @returns A function that maps keys to an object.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { pipe, zipObject } from 'es-toolkit/fp';
|
|
15
|
+
*
|
|
16
|
+
* pipe(['a', 'b'] as const, zipObject([1, 2]));
|
|
17
|
+
* // => { a: 1, b: 2 }
|
|
18
|
+
*/
|
|
19
|
+
declare function zipObject<P extends PropertyKey, V>(values: readonly V[]): (keys: readonly P[]) => Record<P, V>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { zipObject };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_zipObject = require("../../array/zipObject.js");
|
|
2
|
+
//#region src/fp/array/zipObject.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that builds an object from the piped keys and configured values.
|
|
5
|
+
*
|
|
6
|
+
* Keys are read from the piped array and paired with values by index, matching the main
|
|
7
|
+
* {@link zipObject} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template P - The property-key type from the piped keys.
|
|
10
|
+
* @template V - The type of configured values.
|
|
11
|
+
* @param values - Values assigned to the piped keys by index.
|
|
12
|
+
* @returns A function that maps keys to an object.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, zipObject } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe(['a', 'b'] as const, zipObject([1, 2]));
|
|
18
|
+
* // => { a: 1, b: 2 }
|
|
19
|
+
*/
|
|
20
|
+
function zipObject(values) {
|
|
21
|
+
return function(keys) {
|
|
22
|
+
return require_zipObject.zipObject(keys, values);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.zipObject = zipObject;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { zipObject as zipObject$1 } from "../../array/zipObject.mjs";
|
|
2
|
+
//#region src/fp/array/zipObject.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that builds an object from the piped keys and configured values.
|
|
5
|
+
*
|
|
6
|
+
* Keys are read from the piped array and paired with values by index, matching the main
|
|
7
|
+
* {@link zipObject} behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template P - The property-key type from the piped keys.
|
|
10
|
+
* @template V - The type of configured values.
|
|
11
|
+
* @param values - Values assigned to the piped keys by index.
|
|
12
|
+
* @returns A function that maps keys to an object.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { pipe, zipObject } from 'es-toolkit/fp';
|
|
16
|
+
*
|
|
17
|
+
* pipe(['a', 'b'] as const, zipObject([1, 2]));
|
|
18
|
+
* // => { a: 1, b: 2 }
|
|
19
|
+
*/
|
|
20
|
+
function zipObject(values) {
|
|
21
|
+
return function(keys) {
|
|
22
|
+
return zipObject$1(keys, values);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { zipObject };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/fp/array/zipWith.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that maps each value in the piped array with its index.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the piped array.
|
|
6
|
+
* @template R - The type returned by the combiner.
|
|
7
|
+
* @param combine - Called with each value and index.
|
|
8
|
+
* @returns A function that maps the piped array to combined values.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { pipe, zipWith } from 'es-toolkit/fp';
|
|
12
|
+
*
|
|
13
|
+
* pipe([1, 2], zipWith((value, index) => value + index));
|
|
14
|
+
* // => [1, 3]
|
|
15
|
+
*/
|
|
16
|
+
declare function zipWith<T, R>(combine: (item: T, index: number) => R): (array: readonly T[]) => R[];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a function that zips the piped array with one configured array and combines each group.
|
|
19
|
+
*
|
|
20
|
+
* @template T - The type of elements in the piped array.
|
|
21
|
+
* @template U - The type of elements in the configured array.
|
|
22
|
+
* @template R - The type returned by the combiner.
|
|
23
|
+
* @param arr2 - The second array to zip.
|
|
24
|
+
* @param combine - Called with a value from each array and the index.
|
|
25
|
+
* @returns A function that maps the piped array to combined values.
|
|
26
|
+
*/
|
|
27
|
+
declare function zipWith<T, U, R>(arr2: readonly U[], combine: (item1: T, item2: U, index: number) => R): (array: readonly T[]) => R[];
|
|
28
|
+
/**
|
|
29
|
+
* Creates a function that zips the piped array with two configured arrays and combines each group.
|
|
30
|
+
*
|
|
31
|
+
* @template T - The type of elements in the piped array.
|
|
32
|
+
* @template U - The type of elements in the second array.
|
|
33
|
+
* @template V - The type of elements in the third array.
|
|
34
|
+
* @template R - The type returned by the combiner.
|
|
35
|
+
* @param arr2 - The second array to zip.
|
|
36
|
+
* @param arr3 - The third array to zip.
|
|
37
|
+
* @param combine - Called with a value from each array and the index.
|
|
38
|
+
* @returns A function that maps the piped array to combined values.
|
|
39
|
+
*/
|
|
40
|
+
declare function zipWith<T, U, V, R>(arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V, index: number) => R): (array: readonly T[]) => R[];
|
|
41
|
+
/**
|
|
42
|
+
* Creates a function that zips the piped array with three configured arrays and combines each group.
|
|
43
|
+
*
|
|
44
|
+
* @template T - The type of elements in the piped array.
|
|
45
|
+
* @template U - The type of elements in the second array.
|
|
46
|
+
* @template V - The type of elements in the third array.
|
|
47
|
+
* @template W - The type of elements in the fourth array.
|
|
48
|
+
* @template R - The type returned by the combiner.
|
|
49
|
+
* @param arr2 - The second array to zip.
|
|
50
|
+
* @param arr3 - The third array to zip.
|
|
51
|
+
* @param arr4 - The fourth array to zip.
|
|
52
|
+
* @param combine - Called with a value from each array and the index.
|
|
53
|
+
* @returns A function that maps the piped array to combined values.
|
|
54
|
+
*/
|
|
55
|
+
declare function zipWith<T, U, V, W, R>(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W, index: number) => R): (array: readonly T[]) => R[];
|
|
56
|
+
//#endregion
|
|
57
|
+
export { zipWith };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/fp/array/zipWith.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that maps each value in the piped array with its index.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the piped array.
|
|
6
|
+
* @template R - The type returned by the combiner.
|
|
7
|
+
* @param combine - Called with each value and index.
|
|
8
|
+
* @returns A function that maps the piped array to combined values.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { pipe, zipWith } from 'es-toolkit/fp';
|
|
12
|
+
*
|
|
13
|
+
* pipe([1, 2], zipWith((value, index) => value + index));
|
|
14
|
+
* // => [1, 3]
|
|
15
|
+
*/
|
|
16
|
+
declare function zipWith<T, R>(combine: (item: T, index: number) => R): (array: readonly T[]) => R[];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a function that zips the piped array with one configured array and combines each group.
|
|
19
|
+
*
|
|
20
|
+
* @template T - The type of elements in the piped array.
|
|
21
|
+
* @template U - The type of elements in the configured array.
|
|
22
|
+
* @template R - The type returned by the combiner.
|
|
23
|
+
* @param arr2 - The second array to zip.
|
|
24
|
+
* @param combine - Called with a value from each array and the index.
|
|
25
|
+
* @returns A function that maps the piped array to combined values.
|
|
26
|
+
*/
|
|
27
|
+
declare function zipWith<T, U, R>(arr2: readonly U[], combine: (item1: T, item2: U, index: number) => R): (array: readonly T[]) => R[];
|
|
28
|
+
/**
|
|
29
|
+
* Creates a function that zips the piped array with two configured arrays and combines each group.
|
|
30
|
+
*
|
|
31
|
+
* @template T - The type of elements in the piped array.
|
|
32
|
+
* @template U - The type of elements in the second array.
|
|
33
|
+
* @template V - The type of elements in the third array.
|
|
34
|
+
* @template R - The type returned by the combiner.
|
|
35
|
+
* @param arr2 - The second array to zip.
|
|
36
|
+
* @param arr3 - The third array to zip.
|
|
37
|
+
* @param combine - Called with a value from each array and the index.
|
|
38
|
+
* @returns A function that maps the piped array to combined values.
|
|
39
|
+
*/
|
|
40
|
+
declare function zipWith<T, U, V, R>(arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V, index: number) => R): (array: readonly T[]) => R[];
|
|
41
|
+
/**
|
|
42
|
+
* Creates a function that zips the piped array with three configured arrays and combines each group.
|
|
43
|
+
*
|
|
44
|
+
* @template T - The type of elements in the piped array.
|
|
45
|
+
* @template U - The type of elements in the second array.
|
|
46
|
+
* @template V - The type of elements in the third array.
|
|
47
|
+
* @template W - The type of elements in the fourth array.
|
|
48
|
+
* @template R - The type returned by the combiner.
|
|
49
|
+
* @param arr2 - The second array to zip.
|
|
50
|
+
* @param arr3 - The third array to zip.
|
|
51
|
+
* @param arr4 - The fourth array to zip.
|
|
52
|
+
* @param combine - Called with a value from each array and the index.
|
|
53
|
+
* @returns A function that maps the piped array to combined values.
|
|
54
|
+
*/
|
|
55
|
+
declare function zipWith<T, U, V, W, R>(arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W, index: number) => R): (array: readonly T[]) => R[];
|
|
56
|
+
//#endregion
|
|
57
|
+
export { zipWith };
|