es-toolkit 1.27.0-dev.905 → 1.27.0-dev.907
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/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +6 -6
- package/dist/compat/index.mjs +1 -1
- package/dist/function/partial.d.mts +532 -14
- package/dist/function/partial.d.ts +532 -14
- package/dist/function/partialRight.d.mts +610 -15
- package/dist/function/partialRight.d.ts +610 -15
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -222,8 +222,8 @@ export { words } from './string/words.mjs';
|
|
|
222
222
|
export { constant } from './util/constant.mjs';
|
|
223
223
|
export { defaultTo } from './util/defaultTo.mjs';
|
|
224
224
|
export { eq } from './util/eq.mjs';
|
|
225
|
-
export { gte } from './util/gte.mjs';
|
|
226
225
|
export { gt } from './util/gt.mjs';
|
|
226
|
+
export { gte } from './util/gte.mjs';
|
|
227
227
|
export { iteratee } from './util/iteratee.mjs';
|
|
228
228
|
export { times } from './util/times.mjs';
|
|
229
229
|
export { toArray } from './util/toArray.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -222,8 +222,8 @@ export { words } from './string/words.js';
|
|
|
222
222
|
export { constant } from './util/constant.js';
|
|
223
223
|
export { defaultTo } from './util/defaultTo.js';
|
|
224
224
|
export { eq } from './util/eq.js';
|
|
225
|
-
export { gte } from './util/gte.js';
|
|
226
225
|
export { gt } from './util/gt.js';
|
|
226
|
+
export { gte } from './util/gte.js';
|
|
227
227
|
export { iteratee } from './util/iteratee.js';
|
|
228
228
|
export { times } from './util/times.js';
|
|
229
229
|
export { toArray } from './util/toArray.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2628,18 +2628,18 @@ function defaultTo(value, defaultValue) {
|
|
|
2628
2628
|
return value;
|
|
2629
2629
|
}
|
|
2630
2630
|
|
|
2631
|
-
function
|
|
2631
|
+
function gt(value, other) {
|
|
2632
2632
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
2633
|
-
return value
|
|
2633
|
+
return value > other;
|
|
2634
2634
|
}
|
|
2635
|
-
return toNumber(value)
|
|
2635
|
+
return toNumber(value) > toNumber(other);
|
|
2636
2636
|
}
|
|
2637
2637
|
|
|
2638
|
-
function
|
|
2638
|
+
function gte(value, other) {
|
|
2639
2639
|
if (typeof value === 'string' && typeof other === 'string') {
|
|
2640
|
-
return value
|
|
2640
|
+
return value >= other;
|
|
2641
2641
|
}
|
|
2642
|
-
return toNumber(value)
|
|
2642
|
+
return toNumber(value) >= toNumber(other);
|
|
2643
2643
|
}
|
|
2644
2644
|
|
|
2645
2645
|
function toArray(value) {
|
package/dist/compat/index.mjs
CHANGED
|
@@ -221,8 +221,8 @@ export { upperCase } from './string/upperCase.mjs';
|
|
|
221
221
|
export { words } from './string/words.mjs';
|
|
222
222
|
export { constant } from './util/constant.mjs';
|
|
223
223
|
export { defaultTo } from './util/defaultTo.mjs';
|
|
224
|
-
export { gte } from './util/gte.mjs';
|
|
225
224
|
export { gt } from './util/gt.mjs';
|
|
225
|
+
export { gte } from './util/gte.mjs';
|
|
226
226
|
export { iteratee } from './util/iteratee.mjs';
|
|
227
227
|
export { times } from './util/times.mjs';
|
|
228
228
|
export { toArray } from './util/toArray.mjs';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type Placeholder = typeof partialPlaceholder;
|
|
1
2
|
/**
|
|
2
3
|
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
3
4
|
*
|
|
@@ -5,24 +6,541 @@
|
|
|
5
6
|
*
|
|
6
7
|
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
7
8
|
*
|
|
8
|
-
* @template
|
|
9
|
-
* @
|
|
10
|
-
* @param {
|
|
11
|
-
* @
|
|
9
|
+
* @template T1 The type of the first argument.
|
|
10
|
+
* @template R The return type of the function.
|
|
11
|
+
* @param {function(arg1: T1): R} func The function to partially apply.
|
|
12
|
+
* @param {T1} arg1 The first argument to apply.
|
|
13
|
+
* @returns {function(): R} A new function that takes no arguments and returns the result of the original function.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const addOne = (x: number) => x + 1;
|
|
17
|
+
* const addOneToFive = partial(addOne, 5);
|
|
18
|
+
* console.log(addOneToFive()); // => 6
|
|
19
|
+
*/
|
|
20
|
+
declare function partial<T1, R>(func: (arg1: T1) => R, arg1: T1): () => R;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
23
|
+
*
|
|
24
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
25
|
+
*
|
|
26
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
27
|
+
*
|
|
28
|
+
* @template T1 The type of the first argument.
|
|
29
|
+
* @template T2 The type of the second argument.
|
|
30
|
+
* @template R The return type of the function.
|
|
31
|
+
* @param {function(arg1: T1, arg2: T2): R} func The function to partially apply.
|
|
32
|
+
* @param {T1} arg1 The first argument to apply.
|
|
33
|
+
* @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const multiply = (x: number, y: number) => x * y;
|
|
37
|
+
* const double = partial(multiply, 2);
|
|
38
|
+
* console.log(double(5)); // => 10
|
|
39
|
+
*/
|
|
40
|
+
declare function partial<T1, T2, R>(func: (arg1: T1, arg2: T2) => R, arg1: T1): (arg2: T2) => R;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
43
|
+
*
|
|
44
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
45
|
+
*
|
|
46
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
47
|
+
*
|
|
48
|
+
* @template T1 The type of the first argument.
|
|
49
|
+
* @template T2 The type of the second argument.
|
|
50
|
+
* @template R The return type of the function.
|
|
51
|
+
* @param {function(arg1: T1, arg2: T2): R} func The function to partially apply.
|
|
52
|
+
* @param {Placeholder} placeholder The placeholder for the first argument.
|
|
53
|
+
* @param {T2} arg2 The second argument to apply.
|
|
54
|
+
* @returns {function(arg1: T1): R} A new function that takes the first argument and returns the result of the original function.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|
58
|
+
* const greetWithHello = partial(greet, partial.placeholder, 'John');
|
|
59
|
+
* console.log(greetWithHello('Hello')); // => 'Hello, John!'
|
|
60
|
+
*/
|
|
61
|
+
declare function partial<T1, T2, R>(func: (arg1: T1, arg2: T2) => R, placeholder: Placeholder, arg2: T2): (arg1: T1) => R;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
64
|
+
*
|
|
65
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
66
|
+
*
|
|
67
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
68
|
+
*
|
|
69
|
+
* @template T1 The type of the first argument.
|
|
70
|
+
* @template T2 The type of the second argument.
|
|
71
|
+
* @template T3 The type of the third argument.
|
|
72
|
+
* @template R The return type of the function.
|
|
73
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|
74
|
+
* @param {T1} arg1 The first argument to apply.
|
|
75
|
+
* @returns {function(arg2: T2, arg3: T3): R} A new function that takes the second and third arguments and returns the result of the original function.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const sumThree = (a: number, b: number, c: number) => a + b + c;
|
|
79
|
+
* const addFive = partial(sumThree, 5);
|
|
80
|
+
* console.log(addFive(3, 2)); // => 10
|
|
81
|
+
*/
|
|
82
|
+
declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1): (arg2: T2, arg3: T3) => R;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
85
|
+
*
|
|
86
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
87
|
+
*
|
|
88
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
89
|
+
*
|
|
90
|
+
* @template T1 The type of the first argument.
|
|
91
|
+
* @template T2 The type of the second argument.
|
|
92
|
+
* @template T3 The type of the third argument.
|
|
93
|
+
* @template R The return type of the function.
|
|
94
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|
95
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
96
|
+
* @param {T2} arg2 The second argument to apply.
|
|
97
|
+
* @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|
101
|
+
* const greetWithPlaceholder = partial(greet, partial.placeholder, 'John');
|
|
102
|
+
* console.log(greetWithPlaceholder('Hello')); // => 'Hello, John!'
|
|
103
|
+
*/
|
|
104
|
+
declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: T2): (arg1: T1, arg3: T3) => R;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
107
|
+
*
|
|
108
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
109
|
+
*
|
|
110
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
111
|
+
*
|
|
112
|
+
* @template T1 The type of the first argument.
|
|
113
|
+
* @template T2 The type of the second argument.
|
|
114
|
+
* @template T3 The type of the third argument.
|
|
115
|
+
* @template R The return type of the function.
|
|
116
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|
117
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
118
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
119
|
+
* @param {T3} arg3 The third argument to apply.
|
|
120
|
+
* @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const multiply = (x: number, y: number, z: number) => x * y * z;
|
|
124
|
+
* const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2);
|
|
125
|
+
* console.log(multiplyWithPlaceholders(3, 4)); // => 24
|
|
126
|
+
*/
|
|
127
|
+
declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3): (arg1: T1, arg2: T2) => R;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
130
|
+
*
|
|
131
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
132
|
+
*
|
|
133
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
134
|
+
*
|
|
135
|
+
* @template T1 The type of the first argument.
|
|
136
|
+
* @template T2 The type of the second argument.
|
|
137
|
+
* @template T3 The type of the third argument.
|
|
138
|
+
* @template R The return type of the function.
|
|
139
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|
140
|
+
* @param {T1} arg1 The first argument to apply.
|
|
141
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
142
|
+
* @param {T3} arg3 The third argument to apply.
|
|
143
|
+
* @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|
147
|
+
* const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder);
|
|
148
|
+
* console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|
149
|
+
*/
|
|
150
|
+
declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2) => R;
|
|
151
|
+
/**
|
|
152
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
153
|
+
*
|
|
154
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
155
|
+
*
|
|
156
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
157
|
+
*
|
|
158
|
+
* @template T1 The type of the first argument.
|
|
159
|
+
* @template T2 The type of the second argument.
|
|
160
|
+
* @template T3 The type of the third argument.
|
|
161
|
+
* @template R The return type of the function.
|
|
162
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|
163
|
+
* @param {Placeholder} arg1 The first argument to apply.
|
|
164
|
+
* @param {T2} arg2 The placeholder for the second argument.
|
|
165
|
+
* @param {T3} arg3 The third argument to apply.
|
|
166
|
+
* @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|
170
|
+
* const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder);
|
|
171
|
+
* console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|
172
|
+
*/
|
|
173
|
+
declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, plc1: Placeholder, arg2: T2, arg3: T3): (arg1: T1) => R;
|
|
174
|
+
/**
|
|
175
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
176
|
+
*
|
|
177
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
178
|
+
*
|
|
179
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
180
|
+
*
|
|
181
|
+
* @template T1 The type of the first argument.
|
|
182
|
+
* @template T2 The type of the second argument.
|
|
183
|
+
* @template T3 The type of the third argument.
|
|
184
|
+
* @template T4 The type of the fourth argument.
|
|
185
|
+
* @template R The return type of the function.
|
|
186
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
187
|
+
* @param {T1} arg1 The first argument to apply.
|
|
188
|
+
* @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|
192
|
+
* const double = partial(multiply, 2);
|
|
193
|
+
* console.log(double(5, 4, 3)); // => 120
|
|
194
|
+
*/
|
|
195
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1): (arg2: T2, arg3: T3, arg4: T4) => R;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
198
|
+
*
|
|
199
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
200
|
+
*
|
|
201
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
202
|
+
*
|
|
203
|
+
* @template T1 The type of the first argument.
|
|
204
|
+
* @template T2 The type of the second argument.
|
|
205
|
+
* @template T3 The type of the third argument.
|
|
206
|
+
* @template T4 The type of the fourth argument.
|
|
207
|
+
* @template R The return type of the function.
|
|
208
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
209
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
210
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
211
|
+
* @param {T3} arg3 The third argument to apply.
|
|
212
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
213
|
+
* @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|
217
|
+
* const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3);
|
|
218
|
+
* console.log(multiplyWithPlaceholders(4, 5)); // => 120
|
|
219
|
+
*/
|
|
220
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R;
|
|
221
|
+
/**
|
|
222
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
223
|
+
*
|
|
224
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
225
|
+
*
|
|
226
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
227
|
+
*
|
|
228
|
+
* @template T1 The type of the first argument.
|
|
229
|
+
* @template T2 The type of the second argument.
|
|
230
|
+
* @template T3 The type of the third argument.
|
|
231
|
+
* @template T4 The type of the fourth argument.
|
|
232
|
+
* @template R The return type of the function.
|
|
233
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
234
|
+
* @param {T1} arg1 The first argument to apply.
|
|
235
|
+
* @param {T2} arg2 The second argument to apply.
|
|
236
|
+
* @returns {function(arg3: T3, arg4: T4): R} A new function that takes the third and fourth arguments and returns the result of the original function.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d;
|
|
240
|
+
* const addOneAndTwo = partial(sumFour, 1, 2);
|
|
241
|
+
* console.log(addOneAndTwo(3, 4)); // => 10
|
|
242
|
+
*/
|
|
243
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2): (arg3: T3, arg4: T4) => R;
|
|
244
|
+
/**
|
|
245
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
246
|
+
*
|
|
247
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
248
|
+
*
|
|
249
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
250
|
+
*
|
|
251
|
+
* @template T1 The type of the first argument.
|
|
252
|
+
* @template T2 The type of the second argument.
|
|
253
|
+
* @template T3 The type of the third argument.
|
|
254
|
+
* @template T4 The type of the fourth argument.
|
|
255
|
+
* @template R The return type of the function.
|
|
256
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
257
|
+
* @param {T1} arg1 The first argument to apply.
|
|
258
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
259
|
+
* @param {T3} arg3 The third argument to apply.
|
|
260
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
261
|
+
* @returns {function(arg2: T2, arg4: T4): R} A new function that takes the second and fourth arguments and returns the result of the original function.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|
265
|
+
* const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder, '!');
|
|
266
|
+
* console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|
267
|
+
*/
|
|
268
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2, arg4: T4) => R;
|
|
269
|
+
/**
|
|
270
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
271
|
+
*
|
|
272
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
273
|
+
*
|
|
274
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
275
|
+
*
|
|
276
|
+
* @template T1 The type of the first argument.
|
|
277
|
+
* @template T2 The type of the second argument.
|
|
278
|
+
* @template T3 The type of the third argument.
|
|
279
|
+
* @template T4 The type of the fourth argument.
|
|
280
|
+
* @template R The return type of the function.
|
|
281
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
282
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
283
|
+
* @param {T2} arg2 The second argument to apply.
|
|
284
|
+
* @param {T3} arg3 The third argument to apply.
|
|
285
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
286
|
+
* @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|
12
287
|
*
|
|
13
288
|
* @example
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
289
|
+
* const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|
290
|
+
* const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3);
|
|
291
|
+
* console.log(multiplyWithPlaceholder(4)); // => 24
|
|
292
|
+
*/
|
|
293
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3): (arg1: T1, arg4: T4) => R;
|
|
294
|
+
/**
|
|
295
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
296
|
+
*
|
|
297
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
298
|
+
*
|
|
299
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
300
|
+
*
|
|
301
|
+
* @template T1 The type of the first argument.
|
|
302
|
+
* @template T2 The type of the second argument.
|
|
303
|
+
* @template T3 The type of the third argument.
|
|
304
|
+
* @template T4 The type of the fourth argument.
|
|
305
|
+
* @template R The return type of the function.
|
|
306
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
307
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
308
|
+
* @param {T2} arg2 The second argument to apply.
|
|
309
|
+
* @param {Placeholder} arg3 The placeholder for the third argument.
|
|
310
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
311
|
+
* @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|
312
|
+
*/
|
|
313
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: T3) => R;
|
|
314
|
+
/**
|
|
315
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
316
|
+
*
|
|
317
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
318
|
+
*
|
|
319
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
320
|
+
*
|
|
321
|
+
* @template T1 The type of the first argument.
|
|
322
|
+
* @template T2 The type of the second argument.
|
|
323
|
+
* @template T3 The type of the third argument.
|
|
324
|
+
* @template T4 The type of the fourth argument.
|
|
325
|
+
* @template R The return type of the function.
|
|
326
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
327
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
328
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
329
|
+
* @param {T3} arg3 The third argument to apply.
|
|
330
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
331
|
+
* @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|
335
|
+
* const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3);
|
|
336
|
+
* console.log(multiplyWithPlaceholders(4, 5)); // => 120
|
|
337
|
+
*/
|
|
338
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R;
|
|
339
|
+
/**
|
|
340
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
341
|
+
*
|
|
342
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
17
343
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
344
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
345
|
+
*
|
|
346
|
+
* @template T1 The type of the first argument.
|
|
347
|
+
* @template T2 The type of the second argument.
|
|
348
|
+
* @template T3 The type of the third argument.
|
|
349
|
+
* @template T4 The type of the fourth argument.
|
|
350
|
+
* @template R The return type of the function.
|
|
351
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
352
|
+
* @param {T1} arg1 The first argument to apply.
|
|
353
|
+
* @param {T2} arg2 The second argument to apply.
|
|
354
|
+
* @param {T3} arg3 The third argument to apply.
|
|
355
|
+
* @returns {function(arg4: T4): R} A new function that takes the fourth argument and returns the result of the original function.
|
|
356
|
+
*/
|
|
357
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3): (arg4: T4) => R;
|
|
358
|
+
/**
|
|
359
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
360
|
+
*
|
|
361
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
362
|
+
*
|
|
363
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
364
|
+
*
|
|
365
|
+
* @template T1 The type of the first argument.
|
|
366
|
+
* @template T2 The type of the second argument.
|
|
367
|
+
* @template T3 The type of the third argument.
|
|
368
|
+
* @template T4 The type of the fourth argument.
|
|
369
|
+
* @template R The return type of the function.
|
|
370
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
371
|
+
* @param {T1} arg1 The first argument to apply.
|
|
372
|
+
* @param {T2} arg2 The second argument to apply.
|
|
373
|
+
* @param {Placeholder} arg3 The placeholder for the third argument.
|
|
374
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
375
|
+
* @returns {function(arg3: T3): R} A new function that takes the third argument and returns the result of the original function.
|
|
376
|
+
*/
|
|
377
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: T3) => R;
|
|
378
|
+
/**
|
|
379
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
380
|
+
*
|
|
381
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
382
|
+
*
|
|
383
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
384
|
+
*
|
|
385
|
+
* @template T1 The type of the first argument.
|
|
386
|
+
* @template T2 The type of the second argument.
|
|
387
|
+
* @template T3 The type of the third argument.
|
|
388
|
+
* @template T4 The type of the fourth argument.
|
|
389
|
+
* @template R The return type of the function.
|
|
390
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
391
|
+
* @param {T1} arg1 The first argument to apply.
|
|
392
|
+
* @param {Placeholder} arg2 The placeholder for the second argument.
|
|
393
|
+
* @param {T3} arg3 The third argument to apply.
|
|
394
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
395
|
+
* @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|
396
|
+
*/
|
|
397
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: T2) => R;
|
|
398
|
+
/**
|
|
399
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
400
|
+
*
|
|
401
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
402
|
+
*
|
|
403
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
404
|
+
*
|
|
405
|
+
* @template T1 The type of the first argument.
|
|
406
|
+
* @template T2 The type of the second argument.
|
|
407
|
+
* @template T3 The type of the third argument.
|
|
408
|
+
* @template T4 The type of the fourth argument.
|
|
409
|
+
* @template R The return type of the function.
|
|
410
|
+
* @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|
411
|
+
* @param {Placeholder} arg1 The placeholder for the first argument.
|
|
412
|
+
* @param {T2} arg2 The second argument to apply.
|
|
413
|
+
* @param {T3} arg3 The third argument to apply.
|
|
414
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
415
|
+
* @returns {function(arg1: T1): R} A new function that takes the first argument and returns the result of the original function.
|
|
416
|
+
*/
|
|
417
|
+
declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3, arg4: T4): (arg1: T1) => R;
|
|
418
|
+
/**
|
|
419
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
21
420
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
421
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
422
|
+
*
|
|
423
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
424
|
+
*
|
|
425
|
+
* @template TS The types of the arguments.
|
|
426
|
+
* @template R The return type of the function.
|
|
427
|
+
* @param {function(...args: TS): R} func The function to partially apply.
|
|
428
|
+
* @returns {function(...args: TS): R} A new function that takes the same arguments as the original function.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0);
|
|
432
|
+
* const addFive = partial(add, 5);
|
|
433
|
+
* console.log(addFive(1, 2, 3)); // => 11
|
|
434
|
+
*/
|
|
435
|
+
declare function partial<TS extends any[], R>(func: (...args: TS) => R): (...args: TS) => R;
|
|
436
|
+
/**
|
|
437
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
438
|
+
*
|
|
439
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
440
|
+
*
|
|
441
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
442
|
+
*
|
|
443
|
+
* @template TS The types of the arguments.
|
|
444
|
+
* @template T1 The type of the first argument.
|
|
445
|
+
* @template R The return type of the function.
|
|
446
|
+
* @param {function(arg1: T1, ...args: TS): R} func The function to partially apply.
|
|
447
|
+
* @param {T1} arg1 The first argument to apply.
|
|
448
|
+
* @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* const greet = (greeting: string, ...names: string[]) => `${greeting}, ${names.join(', ')}!`;
|
|
452
|
+
* const greetHello = partial(greet, 'Hello');
|
|
453
|
+
* console.log(greetHello('Alice', 'Bob')); // => 'Hello, Alice, Bob!'
|
|
454
|
+
*/
|
|
455
|
+
declare function partial<TS extends any[], T1, R>(func: (arg1: T1, ...args: TS) => R, arg1: T1): (...args: TS) => R;
|
|
456
|
+
/**
|
|
457
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
458
|
+
*
|
|
459
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
460
|
+
*
|
|
461
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
462
|
+
*
|
|
463
|
+
* @template TS The types of the arguments.
|
|
464
|
+
* @template T1 The type of the first argument.
|
|
465
|
+
* @template T2 The type of the second argument.
|
|
466
|
+
* @template R The return type of the function.
|
|
467
|
+
* @param {function(arg1: T1, arg2: T2, ...args: TS): R} func The function to partially apply.
|
|
468
|
+
* @param {T1} arg1 The first argument to apply.
|
|
469
|
+
* @param {T2} arg2 The second argument to apply.
|
|
470
|
+
* @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|
474
|
+
* const greetWithHello = partial(greet, 'Hello', '!');
|
|
475
|
+
* console.log(greetWithHello('John')); // => 'Hello, John!'
|
|
476
|
+
*/
|
|
477
|
+
declare function partial<TS extends any[], T1, T2, R>(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: TS) => R;
|
|
478
|
+
/**
|
|
479
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
480
|
+
*
|
|
481
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
482
|
+
*
|
|
483
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
484
|
+
*
|
|
485
|
+
* @template TS The types of the arguments.
|
|
486
|
+
* @template T1 The type of the first argument.
|
|
487
|
+
* @template T2 The type of the second argument.
|
|
488
|
+
* @template T3 The type of the third argument.
|
|
489
|
+
* @template R The return type of the function.
|
|
490
|
+
* @param {function(t1: T1, arg2: T2, arg3: T3, ...args: TS): R} func The function to partially apply.
|
|
491
|
+
* @param {T1} t1 The first argument to apply.
|
|
492
|
+
* @param {T2} arg2 The second argument to apply.
|
|
493
|
+
* @param {T3} arg3 The third argument to apply.
|
|
494
|
+
* @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|
498
|
+
* const greetWithHello = partial(greet, 'Hello', 'John', '!');
|
|
499
|
+
* console.log(greetWithHello()); // => 'Hello, John!'
|
|
500
|
+
*/
|
|
501
|
+
declare function partial<TS extends any[], T1, T2, T3, R>(func: (t1: T1, arg2: T2, arg3: T3, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3): (...args: TS) => R;
|
|
502
|
+
/**
|
|
503
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
504
|
+
*
|
|
505
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
506
|
+
*
|
|
507
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
508
|
+
*
|
|
509
|
+
* @template TS The types of the arguments.
|
|
510
|
+
* @template T1 The type of the first argument.
|
|
511
|
+
* @template T2 The type of the second argument.
|
|
512
|
+
* @template T3 The type of the third argument.
|
|
513
|
+
* @template T4 The type of the fourth argument.
|
|
514
|
+
* @template R The return type of the function.
|
|
515
|
+
* @param {function(t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS): R} func The function to partially apply.
|
|
516
|
+
* @param {T1} t1 The first argument to apply.
|
|
517
|
+
* @param {T2} arg2 The second argument to apply.
|
|
518
|
+
* @param {T3} arg3 The third argument to apply.
|
|
519
|
+
* @param {T4} arg4 The fourth argument to apply.
|
|
520
|
+
* @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|
524
|
+
* const greetWithHello = partial(greet, 'Hello', 'John', '!');
|
|
525
|
+
* console.log(greetWithHello()); // => 'Hello, John!'
|
|
526
|
+
*/
|
|
527
|
+
declare function partial<TS extends any[], T1, T2, T3, T4, R>(func: (t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3, arg4: T4): (...args: TS) => R;
|
|
528
|
+
/**
|
|
529
|
+
* Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|
530
|
+
*
|
|
531
|
+
* The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|
532
|
+
*
|
|
533
|
+
* Note: This method doesn't set the `length` property of partially applied functions.
|
|
534
|
+
*
|
|
535
|
+
* @template F The type of the function to partially apply.
|
|
536
|
+
* @param {F} func The function to partially apply.
|
|
537
|
+
* @param {...any[]} partialArgs The arguments to be partially applied.
|
|
538
|
+
* @returns {function(...args: any[]): ReturnType<F>} A new function that takes the remaining arguments and returns the result of the original function.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0);
|
|
542
|
+
* const addFive = partial(add, 5);
|
|
543
|
+
* console.log(addFive(1, 2, 3)); // => 11
|
|
26
544
|
*/
|
|
27
545
|
declare function partial<F extends (...args: any[]) => any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType<F>;
|
|
28
546
|
declare namespace partial {
|