es-toolkit 1.49.0 → 1.50.0-dev.1975
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 +46 -0
- package/dist/array/partition.d.mts +5 -4
- package/dist/array/partition.d.ts +5 -4
- package/dist/array/unzipWith.js +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/browser.global.js +3 -3
- package/dist/compat/_internal/ListIterateeCustom.d.mts +3 -2
- package/dist/compat/_internal/ListIterateeCustom.d.ts +3 -2
- package/dist/compat/_internal/assignValue.js +2 -3
- package/dist/compat/_internal/assignValue.mjs +2 -3
- package/dist/compat/_internal/createPadding.js +14 -0
- package/dist/compat/_internal/createPadding.mjs +13 -0
- package/dist/compat/_internal/isDeepKey.js +14 -1
- package/dist/compat/_internal/isDeepKey.mjs +14 -1
- package/dist/compat/_internal/isIterateeCall.js +2 -3
- package/dist/compat/_internal/isIterateeCall.mjs +2 -3
- package/dist/compat/_internal/regexMultiByte.js +11 -0
- package/dist/compat/_internal/regexMultiByte.mjs +11 -0
- package/dist/compat/array/every.js +5 -24
- package/dist/compat/array/every.mjs +5 -24
- package/dist/compat/array/filter.d.mts +7 -3
- package/dist/compat/array/filter.d.ts +7 -3
- package/dist/compat/array/filter.js +11 -11
- package/dist/compat/array/filter.mjs +11 -11
- package/dist/compat/array/find.d.mts +10 -6
- package/dist/compat/array/find.d.ts +10 -6
- package/dist/compat/array/find.js +1 -1
- package/dist/compat/array/find.mjs +1 -1
- package/dist/compat/array/findIndex.d.mts +0 -1
- package/dist/compat/array/findIndex.d.ts +0 -1
- package/dist/compat/array/findIndex.js +2 -1
- package/dist/compat/array/findIndex.mjs +2 -1
- package/dist/compat/array/findLast.d.mts +1 -1
- package/dist/compat/array/findLast.d.ts +1 -1
- package/dist/compat/array/findLast.js +12 -12
- package/dist/compat/array/findLast.mjs +12 -12
- package/dist/compat/array/findLastIndex.js +1 -0
- package/dist/compat/array/findLastIndex.mjs +1 -0
- package/dist/compat/array/flatMap.js +3 -2
- package/dist/compat/array/flatMap.mjs +3 -2
- package/dist/compat/array/flatMapDepth.js +2 -2
- package/dist/compat/array/flatMapDepth.mjs +2 -2
- package/dist/compat/array/flatten.d.mts +4 -5
- package/dist/compat/array/flatten.d.ts +4 -5
- package/dist/compat/array/flatten.js +14 -15
- package/dist/compat/array/flatten.mjs +14 -15
- package/dist/compat/array/flattenDeep.d.mts +1 -1
- package/dist/compat/array/flattenDeep.d.ts +1 -1
- package/dist/compat/array/flattenDeep.js +2 -2
- package/dist/compat/array/flattenDeep.mjs +2 -2
- package/dist/compat/array/flattenDepth.js +18 -2
- package/dist/compat/array/flattenDepth.mjs +18 -2
- package/dist/compat/array/groupBy.js +5 -4
- package/dist/compat/array/groupBy.mjs +4 -3
- package/dist/compat/array/includes.js +8 -3
- package/dist/compat/array/includes.mjs +8 -3
- package/dist/compat/array/intersectionBy.js +12 -5
- package/dist/compat/array/intersectionBy.mjs +12 -5
- package/dist/compat/array/intersectionWith.js +2 -3
- package/dist/compat/array/intersectionWith.mjs +2 -3
- package/dist/compat/array/invokeMap.js +3 -7
- package/dist/compat/array/invokeMap.mjs +3 -4
- package/dist/compat/array/lastIndexOf.js +3 -2
- package/dist/compat/array/lastIndexOf.mjs +3 -2
- package/dist/compat/array/nth.js +2 -2
- package/dist/compat/array/nth.mjs +2 -2
- package/dist/compat/array/pullAllWith.js +2 -3
- package/dist/compat/array/pullAllWith.mjs +2 -3
- package/dist/compat/array/size.js +2 -0
- package/dist/compat/array/size.mjs +2 -0
- package/dist/compat/array/sortedIndexOf.js +2 -3
- package/dist/compat/array/sortedIndexOf.mjs +2 -3
- package/dist/compat/array/sortedLastIndexOf.js +2 -3
- package/dist/compat/array/sortedLastIndexOf.mjs +2 -3
- package/dist/compat/compat.d.mts +4 -3
- package/dist/compat/compat.d.ts +4 -3
- package/dist/compat/compat.js +10 -11
- package/dist/compat/compat.mjs +10 -11
- package/dist/compat/index.d.mts +4 -3
- package/dist/compat/index.d.ts +4 -3
- package/dist/compat/index.js +10 -9
- package/dist/compat/index.mjs +10 -9
- package/dist/compat/math/inRange.d.mts +5 -2
- package/dist/compat/math/inRange.d.ts +5 -2
- package/dist/compat/math/inRange.js +14 -11
- package/dist/compat/math/inRange.mjs +14 -11
- package/dist/compat/math/maxBy.d.mts +1 -1
- package/dist/compat/math/maxBy.d.ts +1 -1
- package/dist/compat/math/maxBy.js +18 -4
- package/dist/compat/math/maxBy.mjs +18 -4
- package/dist/compat/math/minBy.d.mts +1 -1
- package/dist/compat/math/minBy.d.ts +1 -1
- package/dist/compat/math/minBy.js +18 -4
- package/dist/compat/math/minBy.mjs +18 -4
- package/dist/compat/object/assign.js +2 -3
- package/dist/compat/object/assign.mjs +2 -3
- package/dist/compat/object/assignIn.js +2 -3
- package/dist/compat/object/assignIn.mjs +2 -3
- package/dist/compat/object/assignInWith.js +2 -3
- package/dist/compat/object/assignInWith.mjs +2 -3
- package/dist/compat/object/assignWith.js +2 -3
- package/dist/compat/object/assignWith.mjs +2 -3
- package/dist/compat/object/create.js +1 -1
- package/dist/compat/object/create.mjs +1 -1
- package/dist/compat/object/defaults.js +2 -3
- package/dist/compat/object/defaults.mjs +2 -3
- package/dist/compat/object/has.js +1 -1
- package/dist/compat/object/has.mjs +1 -1
- package/dist/compat/object/hasIn.js +1 -1
- package/dist/compat/object/hasIn.mjs +1 -1
- package/dist/compat/object/unset.js +1 -1
- package/dist/compat/object/unset.mjs +1 -1
- package/dist/compat/object/values.js +5 -1
- package/dist/compat/object/values.mjs +5 -1
- package/dist/compat/predicate/isMatchWith.js +4 -5
- package/dist/compat/predicate/isMatchWith.mjs +4 -5
- package/dist/compat/string/camelCase.js +6 -2
- package/dist/compat/string/camelCase.mjs +6 -2
- package/dist/compat/string/kebabCase.js +2 -2
- package/dist/compat/string/kebabCase.mjs +2 -2
- package/dist/compat/string/lowerCase.js +2 -2
- package/dist/compat/string/lowerCase.mjs +2 -2
- package/dist/compat/string/pad.js +10 -3
- package/dist/compat/string/pad.mjs +10 -3
- package/dist/compat/string/padEnd.js +7 -1
- package/dist/compat/string/padEnd.mjs +7 -1
- package/dist/compat/string/padStart.js +7 -1
- package/dist/compat/string/padStart.mjs +7 -1
- package/dist/compat/string/snakeCase.js +2 -2
- package/dist/compat/string/snakeCase.mjs +2 -2
- package/dist/compat/string/startCase.js +1 -1
- package/dist/compat/string/startCase.mjs +1 -1
- package/dist/compat/string/template.d.mts +1 -1
- package/dist/compat/string/template.d.ts +1 -1
- package/dist/compat/string/templateSettings.d.mts +18 -1
- package/dist/compat/string/templateSettings.d.ts +18 -1
- package/dist/compat/string/templateSettings.js +4 -1
- package/dist/compat/string/templateSettings.mjs +5 -1
- package/dist/compat/string/truncate.js +2 -9
- package/dist/compat/string/truncate.mjs +1 -8
- package/dist/compat/string/upperCase.js +2 -2
- package/dist/compat/string/upperCase.mjs +2 -2
- package/dist/compat/util/eq.d.mts +17 -1
- package/dist/compat/util/eq.d.ts +17 -1
- package/dist/compat/util/eq.js +19 -1
- package/dist/compat/util/eq.mjs +19 -1
- package/dist/compat/util/toArray.js +2 -1
- package/dist/compat/util/toArray.mjs +2 -1
- package/dist/fp/flow.d.mts +213 -0
- package/dist/fp/flow.d.ts +213 -0
- package/dist/fp/flow.js +50 -0
- package/dist/fp/flow.mjs +50 -0
- package/dist/fp/index.d.mts +2 -1
- package/dist/fp/index.d.ts +2 -1
- package/dist/fp/index.js +3 -1
- package/dist/fp/index.mjs +3 -2
- package/dist/fp/pipe.js +8 -12
- package/dist/fp/pipe.mjs +8 -12
- package/dist/map/hasValue.js +2 -2
- package/dist/map/hasValue.mjs +2 -2
- package/dist/predicate/isEqualWith.js +2 -3
- package/dist/predicate/isEqualWith.mjs +2 -3
- package/dist/string/deburr.js +1 -1
- package/dist/string/deburr.mjs +1 -1
- package/dist/types/DeepPartial.d.mts +21 -0
- package/dist/types/DeepPartial.d.ts +21 -0
- package/dist/types/DeepReadonly.d.mts +22 -0
- package/dist/types/DeepReadonly.d.ts +22 -0
- package/dist/types/NonEmptyArray.d.mts +14 -0
- package/dist/types/NonEmptyArray.d.ts +14 -0
- package/dist/types/Simplify.d.mts +18 -0
- package/dist/types/Simplify.d.ts +18 -0
- package/dist/types/ValueOf.d.mts +14 -0
- package/dist/types/ValueOf.d.ts +14 -0
- package/dist/types/Writable.d.mts +15 -0
- package/dist/types/Writable.d.ts +15 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +23 -7
- package/types.d.ts +1 -0
- package/dist/_internal/isEqualsSameValueZero.d.mts +0 -17
- package/dist/_internal/isEqualsSameValueZero.d.ts +0 -17
- package/dist/_internal/isEqualsSameValueZero.js +0 -19
- package/dist/_internal/isEqualsSameValueZero.mjs +0 -19
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { isObject } from "../predicate/isObject.mjs";
|
|
2
|
+
import { regexMultiByte } from "../_internal/regexMultiByte.mjs";
|
|
2
3
|
//#region src/compat/string/truncate.ts
|
|
3
4
|
/**
|
|
4
|
-
* Used to compose unicode character classes.
|
|
5
|
-
* @link https://github.com/lodash/lodash/blob/4.17.21-es/_hasUnicode.js
|
|
6
|
-
*
|
|
7
|
-
* Used to detect strings with zero-width joiners or code points from the astral planes.
|
|
8
|
-
* @link http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/
|
|
9
|
-
*/
|
|
10
|
-
const regexMultiByte = /[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;
|
|
11
|
-
/**
|
|
12
5
|
* This regex might more completely detect unicode, but it is slower and this project
|
|
13
6
|
* desires to mimic the behavior of lodash.
|
|
14
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_upperCase = require("../../string/upperCase.js");
|
|
2
1
|
const require_deburr = require("./deburr.js");
|
|
2
|
+
const require_words = require("./words.js");
|
|
3
3
|
const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
4
4
|
//#region src/compat/string/upperCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ const require_normalizeForCase = require("../_internal/normalizeForCase.js");
|
|
|
17
17
|
* const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
|
|
18
18
|
*/
|
|
19
19
|
function upperCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toUpperCase()).join(" ");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.upperCase = upperCase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { upperCase as upperCase$1 } from "../../string/upperCase.mjs";
|
|
2
1
|
import { deburr } from "./deburr.mjs";
|
|
2
|
+
import { words } from "./words.mjs";
|
|
3
3
|
import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
4
4
|
//#region src/compat/string/upperCase.ts
|
|
5
5
|
/**
|
|
@@ -17,7 +17,7 @@ import { normalizeForCase } from "../_internal/normalizeForCase.mjs";
|
|
|
17
17
|
* const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
|
|
18
18
|
*/
|
|
19
19
|
function upperCase(str) {
|
|
20
|
-
return
|
|
20
|
+
return words(normalizeForCase(deburr(str))).map((word) => word.toUpperCase()).join(" ");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { upperCase };
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/compat/util/eq.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
|
|
4
|
+
*
|
|
5
|
+
* @param value The value to compare.
|
|
6
|
+
* @param other The other value to compare.
|
|
7
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* eq(1, 1); // true
|
|
11
|
+
* eq(0, -0); // true
|
|
12
|
+
* eq(NaN, NaN); // true
|
|
13
|
+
* eq('a', Object('a')); // false
|
|
14
|
+
*/
|
|
15
|
+
declare function eq(value: any, other: any): boolean;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { eq };
|
package/dist/compat/util/eq.d.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/compat/util/eq.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
|
|
4
|
+
*
|
|
5
|
+
* @param value The value to compare.
|
|
6
|
+
* @param other The other value to compare.
|
|
7
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* eq(1, 1); // true
|
|
11
|
+
* eq(0, -0); // true
|
|
12
|
+
* eq(NaN, NaN); // true
|
|
13
|
+
* eq('a', Object('a')); // false
|
|
14
|
+
*/
|
|
15
|
+
declare function eq(value: any, other: any): boolean;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { eq };
|
package/dist/compat/util/eq.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/compat/util/eq.ts
|
|
2
|
+
/**
|
|
3
|
+
* Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
|
|
4
|
+
*
|
|
5
|
+
* @param value The value to compare.
|
|
6
|
+
* @param other The other value to compare.
|
|
7
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* eq(1, 1); // true
|
|
11
|
+
* eq(0, -0); // true
|
|
12
|
+
* eq(NaN, NaN); // true
|
|
13
|
+
* eq('a', Object('a')); // false
|
|
14
|
+
*/
|
|
15
|
+
function eq(value, other) {
|
|
16
|
+
return value === other || Number.isNaN(value) && Number.isNaN(other);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.eq = eq;
|
package/dist/compat/util/eq.mjs
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/compat/util/eq.ts
|
|
2
|
+
/**
|
|
3
|
+
* Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
|
|
4
|
+
*
|
|
5
|
+
* @param value The value to compare.
|
|
6
|
+
* @param other The other value to compare.
|
|
7
|
+
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* eq(1, 1); // true
|
|
11
|
+
* eq(0, -0); // true
|
|
12
|
+
* eq(NaN, NaN); // true
|
|
13
|
+
* eq('a', Object('a')); // false
|
|
14
|
+
*/
|
|
15
|
+
function eq(value, other) {
|
|
16
|
+
return value === other || Number.isNaN(value) && Number.isNaN(other);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { eq };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
2
2
|
const require_isMap = require("../predicate/isMap.js");
|
|
3
|
+
const require_isSet = require("../predicate/isSet.js");
|
|
3
4
|
//#region src/compat/util/toArray.ts
|
|
4
5
|
/**
|
|
5
6
|
* Converts a value to an array.
|
|
@@ -15,7 +16,7 @@ const require_isMap = require("../predicate/isMap.js");
|
|
|
15
16
|
*/
|
|
16
17
|
function toArray(value) {
|
|
17
18
|
if (value == null) return [];
|
|
18
|
-
if (require_isArrayLike.isArrayLike(value) || require_isMap.isMap(value)) return Array.from(value);
|
|
19
|
+
if (require_isArrayLike.isArrayLike(value) || require_isMap.isMap(value) || require_isSet.isSet(value)) return Array.from(value);
|
|
19
20
|
if (typeof value === "object") return Object.values(value);
|
|
20
21
|
return [];
|
|
21
22
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
2
2
|
import { isMap } from "../predicate/isMap.mjs";
|
|
3
|
+
import { isSet } from "../predicate/isSet.mjs";
|
|
3
4
|
//#region src/compat/util/toArray.ts
|
|
4
5
|
/**
|
|
5
6
|
* Converts a value to an array.
|
|
@@ -15,7 +16,7 @@ import { isMap } from "../predicate/isMap.mjs";
|
|
|
15
16
|
*/
|
|
16
17
|
function toArray(value) {
|
|
17
18
|
if (value == null) return [];
|
|
18
|
-
if (isArrayLike(value) || isMap(value)) return Array.from(value);
|
|
19
|
+
if (isArrayLike(value) || isMap(value) || isSet(value)) return Array.from(value);
|
|
19
20
|
if (typeof value === "object") return Object.values(value);
|
|
20
21
|
return [];
|
|
21
22
|
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
//#region src/fp/flow.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a reusable function from a single function.
|
|
4
|
+
*
|
|
5
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
6
|
+
* @returns A function with the same parameters as `fn1` that returns its result.
|
|
7
|
+
*/
|
|
8
|
+
declare function flow<A extends any[], R1>(fn1: (...args: A) => R1): (...args: A) => R1;
|
|
9
|
+
/**
|
|
10
|
+
* Composes `fn1` and `fn2` left-to-right into a single reusable function.
|
|
11
|
+
*
|
|
12
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
13
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
14
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn2`.
|
|
15
|
+
*/
|
|
16
|
+
declare function flow<A extends any[], R1, R2>(fn1: (...args: A) => R1, fn2: (input: R1) => R2): (...args: A) => R2;
|
|
17
|
+
/**
|
|
18
|
+
* Composes `fn1` through `fn3` left-to-right into a single reusable function.
|
|
19
|
+
*
|
|
20
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
21
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
22
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
23
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn3`.
|
|
24
|
+
*/
|
|
25
|
+
declare function flow<A extends any[], R1, R2, R3>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3): (...args: A) => R3;
|
|
26
|
+
/**
|
|
27
|
+
* Composes `fn1` through `fn4` left-to-right into a single reusable function.
|
|
28
|
+
*
|
|
29
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
30
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
31
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
32
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
33
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn4`.
|
|
34
|
+
*/
|
|
35
|
+
declare function flow<A extends any[], R1, R2, R3, R4>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4): (...args: A) => R4;
|
|
36
|
+
/**
|
|
37
|
+
* Composes `fn1` through `fn5` left-to-right into a single reusable function.
|
|
38
|
+
*
|
|
39
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
40
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
41
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
42
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
43
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
44
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn5`.
|
|
45
|
+
*/
|
|
46
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5): (...args: A) => R5;
|
|
47
|
+
/**
|
|
48
|
+
* Composes `fn1` through `fn6` left-to-right into a single reusable function.
|
|
49
|
+
*
|
|
50
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
51
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
52
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
53
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
54
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
55
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
56
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn6`.
|
|
57
|
+
*/
|
|
58
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6): (...args: A) => R6;
|
|
59
|
+
/**
|
|
60
|
+
* Composes `fn1` through `fn7` left-to-right into a single reusable function.
|
|
61
|
+
*
|
|
62
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
63
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
64
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
65
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
66
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
67
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
68
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
69
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn7`.
|
|
70
|
+
*/
|
|
71
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7): (...args: A) => R7;
|
|
72
|
+
/**
|
|
73
|
+
* Composes `fn1` through `fn8` left-to-right into a single reusable function.
|
|
74
|
+
*
|
|
75
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
76
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
77
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
78
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
79
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
80
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
81
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
82
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
83
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn8`.
|
|
84
|
+
*/
|
|
85
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8): (...args: A) => R8;
|
|
86
|
+
/**
|
|
87
|
+
* Composes `fn1` through `fn9` left-to-right into a single reusable function.
|
|
88
|
+
*
|
|
89
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
90
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
91
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
92
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
93
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
94
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
95
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
96
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
97
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
98
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn9`.
|
|
99
|
+
*/
|
|
100
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9): (...args: A) => R9;
|
|
101
|
+
/**
|
|
102
|
+
* Composes `fn1` through `fn10` left-to-right into a single reusable function.
|
|
103
|
+
*
|
|
104
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
105
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
106
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
107
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
108
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
109
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
110
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
111
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
112
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
113
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
114
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn10`.
|
|
115
|
+
*/
|
|
116
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10): (...args: A) => R10;
|
|
117
|
+
/**
|
|
118
|
+
* Composes `fn1` through `fn11` left-to-right into a single reusable function.
|
|
119
|
+
*
|
|
120
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
121
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
122
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
123
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
124
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
125
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
126
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
127
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
128
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
129
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
130
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
131
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn11`.
|
|
132
|
+
*/
|
|
133
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11): (...args: A) => R11;
|
|
134
|
+
/**
|
|
135
|
+
* Composes `fn1` through `fn12` left-to-right into a single reusable function.
|
|
136
|
+
*
|
|
137
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
138
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
139
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
140
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
141
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
142
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
143
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
144
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
145
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
146
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
147
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
148
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
149
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn12`.
|
|
150
|
+
*/
|
|
151
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12): (...args: A) => R12;
|
|
152
|
+
/**
|
|
153
|
+
* Composes `fn1` through `fn13` left-to-right into a single reusable function.
|
|
154
|
+
*
|
|
155
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
156
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
157
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
158
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
159
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
160
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
161
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
162
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
163
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
164
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
165
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
166
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
167
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
168
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn13`.
|
|
169
|
+
*/
|
|
170
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13): (...args: A) => R13;
|
|
171
|
+
/**
|
|
172
|
+
* Composes `fn1` through `fn14` left-to-right into a single reusable function.
|
|
173
|
+
*
|
|
174
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
175
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
176
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
177
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
178
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
179
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
180
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
181
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
182
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
183
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
184
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
185
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
186
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
187
|
+
* @param fn14 - Applied to the result of `fn13`.
|
|
188
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn14`.
|
|
189
|
+
*/
|
|
190
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14): (...args: A) => R14;
|
|
191
|
+
/**
|
|
192
|
+
* Composes `fn1` through `fn15` left-to-right into a single reusable function.
|
|
193
|
+
*
|
|
194
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
195
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
196
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
197
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
198
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
199
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
200
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
201
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
202
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
203
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
204
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
205
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
206
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
207
|
+
* @param fn14 - Applied to the result of `fn13`.
|
|
208
|
+
* @param fn15 - Applied to the result of `fn14`.
|
|
209
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn15`.
|
|
210
|
+
*/
|
|
211
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14, fn15: (input: R14) => R15): (...args: A) => R15;
|
|
212
|
+
//#endregion
|
|
213
|
+
export { flow };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
//#region src/fp/flow.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a reusable function from a single function.
|
|
4
|
+
*
|
|
5
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
6
|
+
* @returns A function with the same parameters as `fn1` that returns its result.
|
|
7
|
+
*/
|
|
8
|
+
declare function flow<A extends any[], R1>(fn1: (...args: A) => R1): (...args: A) => R1;
|
|
9
|
+
/**
|
|
10
|
+
* Composes `fn1` and `fn2` left-to-right into a single reusable function.
|
|
11
|
+
*
|
|
12
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
13
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
14
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn2`.
|
|
15
|
+
*/
|
|
16
|
+
declare function flow<A extends any[], R1, R2>(fn1: (...args: A) => R1, fn2: (input: R1) => R2): (...args: A) => R2;
|
|
17
|
+
/**
|
|
18
|
+
* Composes `fn1` through `fn3` left-to-right into a single reusable function.
|
|
19
|
+
*
|
|
20
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
21
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
22
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
23
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn3`.
|
|
24
|
+
*/
|
|
25
|
+
declare function flow<A extends any[], R1, R2, R3>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3): (...args: A) => R3;
|
|
26
|
+
/**
|
|
27
|
+
* Composes `fn1` through `fn4` left-to-right into a single reusable function.
|
|
28
|
+
*
|
|
29
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
30
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
31
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
32
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
33
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn4`.
|
|
34
|
+
*/
|
|
35
|
+
declare function flow<A extends any[], R1, R2, R3, R4>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4): (...args: A) => R4;
|
|
36
|
+
/**
|
|
37
|
+
* Composes `fn1` through `fn5` left-to-right into a single reusable function.
|
|
38
|
+
*
|
|
39
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
40
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
41
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
42
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
43
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
44
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn5`.
|
|
45
|
+
*/
|
|
46
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5): (...args: A) => R5;
|
|
47
|
+
/**
|
|
48
|
+
* Composes `fn1` through `fn6` left-to-right into a single reusable function.
|
|
49
|
+
*
|
|
50
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
51
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
52
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
53
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
54
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
55
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
56
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn6`.
|
|
57
|
+
*/
|
|
58
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6): (...args: A) => R6;
|
|
59
|
+
/**
|
|
60
|
+
* Composes `fn1` through `fn7` left-to-right into a single reusable function.
|
|
61
|
+
*
|
|
62
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
63
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
64
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
65
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
66
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
67
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
68
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
69
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn7`.
|
|
70
|
+
*/
|
|
71
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7): (...args: A) => R7;
|
|
72
|
+
/**
|
|
73
|
+
* Composes `fn1` through `fn8` left-to-right into a single reusable function.
|
|
74
|
+
*
|
|
75
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
76
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
77
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
78
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
79
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
80
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
81
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
82
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
83
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn8`.
|
|
84
|
+
*/
|
|
85
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8): (...args: A) => R8;
|
|
86
|
+
/**
|
|
87
|
+
* Composes `fn1` through `fn9` left-to-right into a single reusable function.
|
|
88
|
+
*
|
|
89
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
90
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
91
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
92
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
93
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
94
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
95
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
96
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
97
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
98
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn9`.
|
|
99
|
+
*/
|
|
100
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9): (...args: A) => R9;
|
|
101
|
+
/**
|
|
102
|
+
* Composes `fn1` through `fn10` left-to-right into a single reusable function.
|
|
103
|
+
*
|
|
104
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
105
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
106
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
107
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
108
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
109
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
110
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
111
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
112
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
113
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
114
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn10`.
|
|
115
|
+
*/
|
|
116
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10): (...args: A) => R10;
|
|
117
|
+
/**
|
|
118
|
+
* Composes `fn1` through `fn11` left-to-right into a single reusable function.
|
|
119
|
+
*
|
|
120
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
121
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
122
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
123
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
124
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
125
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
126
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
127
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
128
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
129
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
130
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
131
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn11`.
|
|
132
|
+
*/
|
|
133
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11): (...args: A) => R11;
|
|
134
|
+
/**
|
|
135
|
+
* Composes `fn1` through `fn12` left-to-right into a single reusable function.
|
|
136
|
+
*
|
|
137
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
138
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
139
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
140
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
141
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
142
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
143
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
144
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
145
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
146
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
147
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
148
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
149
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn12`.
|
|
150
|
+
*/
|
|
151
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12): (...args: A) => R12;
|
|
152
|
+
/**
|
|
153
|
+
* Composes `fn1` through `fn13` left-to-right into a single reusable function.
|
|
154
|
+
*
|
|
155
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
156
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
157
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
158
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
159
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
160
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
161
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
162
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
163
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
164
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
165
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
166
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
167
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
168
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn13`.
|
|
169
|
+
*/
|
|
170
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13): (...args: A) => R13;
|
|
171
|
+
/**
|
|
172
|
+
* Composes `fn1` through `fn14` left-to-right into a single reusable function.
|
|
173
|
+
*
|
|
174
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
175
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
176
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
177
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
178
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
179
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
180
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
181
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
182
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
183
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
184
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
185
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
186
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
187
|
+
* @param fn14 - Applied to the result of `fn13`.
|
|
188
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn14`.
|
|
189
|
+
*/
|
|
190
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14): (...args: A) => R14;
|
|
191
|
+
/**
|
|
192
|
+
* Composes `fn1` through `fn15` left-to-right into a single reusable function.
|
|
193
|
+
*
|
|
194
|
+
* @param fn1 - The first function, which may take any number of arguments.
|
|
195
|
+
* @param fn2 - Applied to the result of `fn1`.
|
|
196
|
+
* @param fn3 - Applied to the result of `fn2`.
|
|
197
|
+
* @param fn4 - Applied to the result of `fn3`.
|
|
198
|
+
* @param fn5 - Applied to the result of `fn4`.
|
|
199
|
+
* @param fn6 - Applied to the result of `fn5`.
|
|
200
|
+
* @param fn7 - Applied to the result of `fn6`.
|
|
201
|
+
* @param fn8 - Applied to the result of `fn7`.
|
|
202
|
+
* @param fn9 - Applied to the result of `fn8`.
|
|
203
|
+
* @param fn10 - Applied to the result of `fn9`.
|
|
204
|
+
* @param fn11 - Applied to the result of `fn10`.
|
|
205
|
+
* @param fn12 - Applied to the result of `fn11`.
|
|
206
|
+
* @param fn13 - Applied to the result of `fn12`.
|
|
207
|
+
* @param fn14 - Applied to the result of `fn13`.
|
|
208
|
+
* @param fn15 - Applied to the result of `fn14`.
|
|
209
|
+
* @returns A function with the same parameters as `fn1` that returns the result of `fn15`.
|
|
210
|
+
*/
|
|
211
|
+
declare function flow<A extends any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(fn1: (...args: A) => R1, fn2: (input: R1) => R2, fn3: (input: R2) => R3, fn4: (input: R3) => R4, fn5: (input: R4) => R5, fn6: (input: R5) => R6, fn7: (input: R6) => R7, fn8: (input: R7) => R8, fn9: (input: R8) => R9, fn10: (input: R9) => R10, fn11: (input: R10) => R11, fn12: (input: R11) => R12, fn13: (input: R12) => R13, fn14: (input: R13) => R14, fn15: (input: R14) => R15): (...args: A) => R15;
|
|
212
|
+
//#endregion
|
|
213
|
+
export { flow };
|
package/dist/fp/flow.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const require_pipe = require("./pipe.js");
|
|
2
|
+
//#region src/fp/flow.ts
|
|
3
|
+
/**
|
|
4
|
+
* Performs left-to-right function composition, returning a **reusable function**
|
|
5
|
+
* instead of running immediately. The first function may take any number of
|
|
6
|
+
* arguments; every later function is unary and receives the previous result.
|
|
7
|
+
*
|
|
8
|
+
* `flow` is the deferred sibling of {@link pipe}: where `pipe(value, ...fns)`
|
|
9
|
+
* threads a concrete value through the functions right away, `flow(...fns)`
|
|
10
|
+
* builds a function you can call later (and reuse) with the data. Internally it
|
|
11
|
+
* delegates to `pipe`, so lazy-capable functions (`map`, `filter`, `take`, …)
|
|
12
|
+
* are fused exactly the same way and benefit from early termination.
|
|
13
|
+
*
|
|
14
|
+
* @param functions - The functions to compose. The first may be variadic; the
|
|
15
|
+
* rest are unary, each receiving the previous function's output.
|
|
16
|
+
* @returns A function that, when called, applies every function left-to-right.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { flow } from 'es-toolkit/fp';
|
|
20
|
+
*
|
|
21
|
+
* const addThenSquare = flow(
|
|
22
|
+
* (x: number, y: number) => x + y,
|
|
23
|
+
* n => n * n
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* addThenSquare(1, 2); // => 9
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* import { flow, map, filter, take } from 'es-toolkit/fp';
|
|
30
|
+
*
|
|
31
|
+
* // A reusable lazy pipeline. Only the first two even squares are computed.
|
|
32
|
+
* const firstTwoEvenSquares = flow(
|
|
33
|
+
* map((x: number) => x * x),
|
|
34
|
+
* filter(x => x % 2 === 0),
|
|
35
|
+
* take(2)
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* firstTwoEvenSquares([1, 2, 3, 4, 5, 6, 7, 8]); // => [4, 16]
|
|
39
|
+
*/
|
|
40
|
+
function flow(...functions) {
|
|
41
|
+
const run = require_pipe.pipe;
|
|
42
|
+
return function(...args) {
|
|
43
|
+
if (functions.length === 0) return args[0];
|
|
44
|
+
if (args.length <= 1) return run(args[0], ...functions);
|
|
45
|
+
const [first, ...rest] = functions;
|
|
46
|
+
return run(first.apply(this, args), ...rest);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.flow = flow;
|