es-toolkit 1.49.0-dev.1904 → 1.49.0-dev.1906

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.
@@ -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 };
@@ -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;
@@ -0,0 +1,50 @@
1
+ import { pipe } from "./pipe.mjs";
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 = 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
+ export { flow };
@@ -67,9 +67,10 @@ import { xorWith } from "./array/xorWith.mjs";
67
67
  import { zip } from "./array/zip.mjs";
68
68
  import { zipObject } from "./array/zipObject.mjs";
69
69
  import { zipWith } from "./array/zipWith.mjs";
70
+ import { flow } from "./flow.mjs";
70
71
  import { add } from "./math/add.mjs";
71
72
  import { multiply } from "./math/multiply.mjs";
72
73
  import { omit } from "./object/omit.mjs";
73
74
  import { pick } from "./object/pick.mjs";
74
75
  import { pipe } from "./pipe.mjs";
75
- export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
76
+ export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
@@ -67,9 +67,10 @@ import { xorWith } from "./array/xorWith.js";
67
67
  import { zip } from "./array/zip.js";
68
68
  import { zipObject } from "./array/zipObject.js";
69
69
  import { zipWith } from "./array/zipWith.js";
70
+ import { flow } from "./flow.js";
70
71
  import { add } from "./math/add.js";
71
72
  import { multiply } from "./math/multiply.js";
72
73
  import { omit } from "./object/omit.js";
73
74
  import { pick } from "./object/pick.js";
74
75
  import { pipe } from "./pipe.js";
75
- export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
76
+ export { WindowedOptions, add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
package/dist/fp/index.js CHANGED
@@ -68,13 +68,14 @@ const require_zip = require("./array/zip.js");
68
68
  const require_zipObject = require("./array/zipObject.js");
69
69
  const require_zipWith = require("./array/zipWith.js");
70
70
  require("./array/index.js");
71
+ const require_pipe = require("./pipe.js");
72
+ const require_flow = require("./flow.js");
71
73
  const require_add = require("./math/add.js");
72
74
  const require_multiply = require("./math/multiply.js");
73
75
  require("./math/index.js");
74
76
  const require_omit = require("./object/omit.js");
75
77
  const require_pick = require("./object/pick.js");
76
78
  require("./object/index.js");
77
- const require_pipe = require("./pipe.js");
78
79
  exports.add = require_add.add;
79
80
  exports.at = require_at.at;
80
81
  exports.cartesianProduct = require_cartesianProduct.cartesianProduct;
@@ -99,6 +100,7 @@ exports.flatMap = require_flatMap.flatMap;
99
100
  exports.flatMapDeep = require_flatMapDeep.flatMapDeep;
100
101
  exports.flatten = require_flatten.flatten;
101
102
  exports.flattenDeep = require_flattenDeep.flattenDeep;
103
+ exports.flow = require_flow.flow;
102
104
  exports.forEach = require_forEach.forEach;
103
105
  exports.groupBy = require_groupBy.groupBy;
104
106
  exports.head = require_head.head;
package/dist/fp/index.mjs CHANGED
@@ -67,11 +67,12 @@ import { zip } from "./array/zip.mjs";
67
67
  import { zipObject } from "./array/zipObject.mjs";
68
68
  import { zipWith } from "./array/zipWith.mjs";
69
69
  import "./array/index.mjs";
70
+ import { pipe } from "./pipe.mjs";
71
+ import { flow } from "./flow.mjs";
70
72
  import { add } from "./math/add.mjs";
71
73
  import { multiply } from "./math/multiply.mjs";
72
74
  import "./math/index.mjs";
73
75
  import { omit } from "./object/omit.mjs";
74
76
  import { pick } from "./object/pick.mjs";
75
77
  import "./object/index.mjs";
76
- import { pipe } from "./pipe.mjs";
77
- export { add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
78
+ export { add, at, cartesianProduct, chunk, chunkBy, combinations, compact, countBy, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, flatMap, flatMapDeep, flatten, flattenDeep, flow, forEach, groupBy, head, initial, intersection, intersectionBy, intersectionWith, isSubset, isSubsetWith, join, keyBy, last, length, map, maxBy, minBy, multiply, omit, orderBy, partition, pick, pipe, reverse, sample, sampleSize, shuffle, sortBy, tail, take, takeRight, takeRightWhile, takeWhile, toFilled, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, windowed, without, xor, xorBy, xorWith, zip, zipObject, zipWith };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.49.0-dev.1904+105ceb47",
3
+ "version": "1.49.0-dev.1906+60a8d3ec",
4
4
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
5
5
  "homepage": "https://es-toolkit.dev",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",