source: node_modules/es-toolkit/dist/compat/function/partialRight.d.mts@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 31.5 KB
Line 
1import { Toolkit } from '../toolkit.mjs';
2
3type __ = Placeholder | Toolkit;
4/**
5 * Creates a function that invokes the provided function with no arguments.
6 *
7 * @template R The return type of the function
8 * @param {() => R} func The function to partially apply
9 * @returns {() => R} Returns the new partially applied function
10 *
11 * @example
12 * const greet = () => 'Hello!';
13 * const sayHello = partialRight(greet);
14 * sayHello(); // => 'Hello!'
15 */
16declare function partialRight<R>(func: () => R): () => R;
17/**
18 * Creates a function that invokes the provided function with one argument.
19 *
20 * @template T The type of the argument
21 * @template R The return type of the function
22 * @param {(t1: T) => R} func The function to partially apply
23 * @returns {(t1: T) => R} Returns the new partially applied function
24 *
25 * @example
26 * const greet = (name: string) => `Hello ${name}!`;
27 * const greetPerson = partialRight(greet);
28 * greetPerson('Fred'); // => 'Hello Fred!'
29 */
30declare function partialRight<T, R>(func: (t1: T) => R): (t1: T) => R;
31/**
32 * Creates a function that invokes the provided function with one argument pre-filled.
33 *
34 * @template T The type of the argument
35 * @template R The return type of the function
36 * @param {(t1: T) => R} func The function to partially apply
37 * @param {T} arg1 The argument to pre-fill
38 * @returns {() => R} Returns the new partially applied function
39 *
40 * @example
41 * const greet = (name: string) => `Hello ${name}!`;
42 * const greetFred = partialRight(greet, 'Fred');
43 * greetFred(); // => 'Hello Fred!'
44 */
45declare function partialRight<T, R>(func: (t1: T) => R, arg1: T): () => R;
46/**
47 * Creates a function that invokes the provided function with two arguments.
48 *
49 * @template T1 The type of the first argument
50 * @template T2 The type of the second argument
51 * @template R The return type of the function
52 * @param {(t1: T1, t2: T2) => R} func The function to partially apply
53 * @returns {(t1: T1, t2: T2) => R} Returns the new partially applied function
54 *
55 * @example
56 * const greet = (greeting: string, name: string) => `${greeting} ${name}!`;
57 * const greetWithParams = partialRight(greet);
58 * greetWithParams('Hi', 'Fred'); // => 'Hi Fred!'
59 */
60declare function partialRight<T1, T2, R>(func: (t1: T1, t2: T2) => R): (t1: T1, t2: T2) => R;
61/**
62 * Creates a function that invokes the provided function with one argument pre-filled and a placeholder.
63 *
64 * @template T1 The type of the first argument
65 * @template T2 The type of the second argument
66 * @template R The return type of the function
67 * @param {(t1: T1, t2: T2) => R} func The function to partially apply
68 * @param {T1} arg1 The argument to pre-fill
69 * @param {__} plc2 The placeholder for the second argument
70 * @returns {(t2: T2) => R} Returns the new partially applied function
71 *
72 * @example
73 * const greet = (greeting: string, name: string) => `${greeting} ${name}!`;
74 * const hiWithName = partialRight(greet, 'Hi', partialRight.placeholder);
75 * hiWithName('Fred'); // => 'Hi Fred!'
76 */
77declare function partialRight<T1, T2, R>(func: (t1: T1, t2: T2) => R, arg1: T1, plc2: __): (t2: T2) => R;
78/**
79 * Creates a function that invokes the provided function with the second argument pre-filled.
80 *
81 * @template T1 The type of the first argument
82 * @template T2 The type of the second argument
83 * @template R The return type of the function
84 * @param {(t1: T1, t2: T2) => R} func The function to partially apply
85 * @param {T2} arg2 The argument to pre-fill
86 * @returns {(t1: T1) => R} Returns the new partially applied function
87 *
88 * @example
89 * const greet = (greeting: string, name: string) => `${greeting} ${name}!`;
90 * const greetFred = partialRight(greet, 'Fred');
91 * greetFred('Hi'); // => 'Hi Fred!'
92 */
93declare function partialRight<T1, T2, R>(func: (t1: T1, t2: T2) => R, arg2: T2): (t1: T1) => R;
94/**
95 * Creates a function that invokes the provided function with both arguments pre-filled.
96 *
97 * @template T1 The type of the first argument
98 * @template T2 The type of the second argument
99 * @template R The return type of the function
100 * @param {(t1: T1, t2: T2) => R} func The function to partially apply
101 * @param {T1} arg1 The first argument to pre-fill
102 * @param {T2} arg2 The second argument to pre-fill
103 * @returns {() => R} Returns the new partially applied function
104 *
105 * @example
106 * const greet = (greeting: string, name: string) => `${greeting} ${name}!`;
107 * const sayHiToFred = partialRight(greet, 'Hi', 'Fred');
108 * sayHiToFred(); // => 'Hi Fred!'
109 */
110declare function partialRight<T1, T2, R>(func: (t1: T1, t2: T2) => R, arg1: T1, arg2: T2): () => R;
111/**
112 * Creates a function that invokes the provided function with no pre-filled arguments.
113 *
114 * @template T1 The type of the first argument
115 * @template T2 The type of the second argument
116 * @template T3 The type of the third argument
117 * @template R The return type of the function
118 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
119 * @returns {(t1: T1, t2: T2, t3: T3) => R} Returns the new partially applied function
120 *
121 * @example
122 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
123 * const greetWithArgs = partialRight(greet);
124 * greetWithArgs('Hi', 'Fred', '!'); // => 'Hi Fred!'
125 */
126declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R): (t1: T1, t2: T2, t3: T3) => R;
127/**
128 * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest.
129 *
130 * @template T1 The type of the first argument
131 * @template T2 The type of the second argument
132 * @template T3 The type of the third argument
133 * @template R The return type of the function
134 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
135 * @param {T1} arg1 The first argument to pre-fill
136 * @param {__} plc2 The placeholder for the second argument
137 * @param {__} plc3 The placeholder for the third argument
138 * @returns {(t2: T2, t3: T3) => R} Returns the new partially applied function
139 *
140 * @example
141 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
142 * const hiWithNameAndPunc = partialRight(greet, 'Hi', partialRight.placeholder, partialRight.placeholder);
143 * hiWithNameAndPunc('Fred', '!'); // => 'Hi Fred!'
144 */
145declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, plc3: __): (t2: T2, t3: T3) => R;
146/**
147 * Creates a function that invokes the provided function with the second argument pre-filled and a placeholder for the third.
148 *
149 * @template T1 The type of the first argument
150 * @template T2 The type of the second argument
151 * @template T3 The type of the third argument
152 * @template R The return type of the function
153 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
154 * @param {T2} arg2 The second argument to pre-fill
155 * @param {__} plc3 The placeholder for the third argument
156 * @returns {(t1: T1, t3: T3) => R} Returns the new partially applied function
157 *
158 * @example
159 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
160 * const greetFredWithPunc = partialRight(greet, 'Fred', partialRight.placeholder);
161 * greetFredWithPunc('Hi', '!'); // => 'Hi Fred!'
162 */
163declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, plc3: __): (t1: T1, t3: T3) => R;
164/**
165 * Creates a function that invokes the provided function with the first two arguments pre-filled and a placeholder for the third.
166 *
167 * @template T1 The type of the first argument
168 * @template T2 The type of the second argument
169 * @template T3 The type of the third argument
170 * @template R The return type of the function
171 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
172 * @param {T1} arg1 The first argument to pre-fill
173 * @param {T2} arg2 The second argument to pre-fill
174 * @param {__} plc3 The placeholder for the third argument
175 * @returns {(t3: T3) => R} Returns the new partially applied function
176 *
177 * @example
178 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
179 * const hiToFredWithPunc = partialRight(greet, 'Hi', 'Fred', partialRight.placeholder);
180 * hiToFredWithPunc('!'); // => 'Hi Fred!'
181 */
182declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, plc3: __): (t3: T3) => R;
183/**
184 * Creates a function that invokes the provided function with the third argument pre-filled.
185 *
186 * @template T1 The type of the first argument
187 * @template T2 The type of the second argument
188 * @template T3 The type of the third argument
189 * @template R The return type of the function
190 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
191 * @param {T3} arg3 The third argument to pre-fill
192 * @returns {(t1: T1, t2: T2) => R} Returns the new partially applied function
193 *
194 * @example
195 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
196 * const greetWithExclamation = partialRight(greet, '!');
197 * greetWithExclamation('Hi', 'Fred'); // => 'Hi Fred!'
198 */
199declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg3: T3): (t1: T1, t2: T2) => R;
200/**
201 * Creates a function that invokes the provided function with the first and third arguments pre-filled.
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 R The return type of the function
207 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
208 * @param {T1} arg1 The first argument to pre-fill
209 * @param {__} plc2 The placeholder for the second argument
210 * @param {T3} arg3 The third argument to pre-fill
211 * @returns {(t2: T2) => R} Returns the new partially applied function
212 *
213 * @example
214 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
215 * const hiWithNameAndExclamation = partialRight(greet, 'Hi', partialRight.placeholder, '!');
216 * hiWithNameAndExclamation('Fred'); // => 'Hi Fred!'
217 */
218declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, plc2: __, arg3: T3): (t2: T2) => R;
219/**
220 * Creates a function that invokes the provided function with the second and third arguments pre-filled.
221 *
222 * @template T1 The type of the first argument
223 * @template T2 The type of the second argument
224 * @template T3 The type of the third argument
225 * @template R The return type of the function
226 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
227 * @param {T2} arg2 The second argument to pre-fill
228 * @param {T3} arg3 The third argument to pre-fill
229 * @returns {(t1: T1) => R} Returns the new partially applied function
230 *
231 * @example
232 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
233 * const greetFredWithExclamation = partialRight(greet, 'Fred', '!');
234 * greetFredWithExclamation('Hi'); // => 'Hi Fred!'
235 */
236declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg2: T2, arg3: T3): (t1: T1) => R;
237/**
238 * Creates a function that invokes the provided function with all three arguments pre-filled.
239 *
240 * @template T1 The type of the first argument
241 * @template T2 The type of the second argument
242 * @template T3 The type of the third argument
243 * @template R The return type of the function
244 * @param {(t1: T1, t2: T2, t3: T3) => R} func The function to partially apply
245 * @param {T1} arg1 The first argument to pre-fill
246 * @param {T2} arg2 The second argument to pre-fill
247 * @param {T3} arg3 The third argument to pre-fill
248 * @returns {() => R} Returns the new partially applied function
249 *
250 * @example
251 * const greet = (greeting: string, name: string, punctuation: string) => `${greeting} ${name}${punctuation}`;
252 * const sayHiToFredWithExclamation = partialRight(greet, 'Hi', 'Fred', '!');
253 * sayHiToFredWithExclamation(); // => 'Hi Fred!'
254 */
255declare function partialRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R, arg1: T1, arg2: T2, arg3: T3): () => R;
256/**
257 * Creates a function that invokes the provided function with no pre-filled arguments.
258 *
259 * @template T1 The type of the first argument
260 * @template T2 The type of the second argument
261 * @template T3 The type of the third argument
262 * @template T4 The type of the fourth argument
263 * @template R The return type of the function
264 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
265 * @returns {(t1: T1, t2: T2, t3: T3, t4: T4) => R} Returns the new partially applied function
266 *
267 * @example
268 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
269 * `${greeting} ${name}, it's ${time}${punctuation}`;
270 * const formatWithArgs = partialRight(format);
271 * formatWithArgs('Hi', 'Fred', 'morning', '!'); // => 'Hi Fred, it's morning!'
272 */
273declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): (t1: T1, t2: T2, t3: T3, t4: T4) => R;
274/**
275 * Creates a function that invokes the provided function with the first argument pre-filled and placeholders for the rest.
276 *
277 * @template T1 The type of the first argument
278 * @template T2 The type of the second argument
279 * @template T3 The type of the third argument
280 * @template T4 The type of the fourth argument
281 * @template R The return type of the function
282 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
283 * @param {T1} arg1 The first argument to pre-fill
284 * @param {__} plc2 The placeholder for the second argument
285 * @param {__} plc3 The placeholder for the third argument
286 * @param {__} plc4 The placeholder for the fourth argument
287 * @returns {(t2: T2, t3: T3, t4: T4) => R} Returns the new partially applied function
288 *
289 * @example
290 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
291 * `${greeting} ${name}, it's ${time}${punctuation}`;
292 * const hiWithRest = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, partialRight.placeholder);
293 * hiWithRest('Fred', 'morning', '!'); // => 'Hi Fred, it's morning!'
294 */
295declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, plc4: __): (t2: T2, t3: T3, t4: T4) => R;
296/**
297 * Creates a function that invokes the provided function with the second argument pre-filled and placeholders for the rest.
298 *
299 * @template T1 The type of the first argument
300 * @template T2 The type of the second argument
301 * @template T3 The type of the third argument
302 * @template T4 The type of the fourth argument
303 * @template R The return type of the function
304 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
305 * @param {T2} arg2 The second argument to pre-fill
306 * @param {__} plc3 The placeholder for the third argument
307 * @param {__} plc4 The placeholder for the fourth argument
308 * @returns {(t1: T1, t3: T3, t4: T4) => R} Returns the new partially applied function
309 *
310 * @example
311 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
312 * `${greeting} ${name}, it's ${time}${punctuation}`;
313 * const greetFredWithRest = partialRight(format, 'Fred', partialRight.placeholder, partialRight.placeholder);
314 * greetFredWithRest('Hi', 'morning', '!'); // => 'Hi Fred, it's morning!'
315 */
316declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, plc4: __): (t1: T1, t3: T3, t4: T4) => R;
317/**
318 * Creates a function that invokes the provided function with the first two arguments pre-filled and placeholders for the rest.
319 *
320 * @template T1 The type of the first argument
321 * @template T2 The type of the second argument
322 * @template T3 The type of the third argument
323 * @template T4 The type of the fourth argument
324 * @template R The return type of the function
325 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
326 * @param {T1} arg1 The first argument to pre-fill
327 * @param {T2} arg2 The second argument to pre-fill
328 * @param {__} plc3 The placeholder for the third argument
329 * @param {__} plc4 The placeholder for the fourth argument
330 * @returns {(t3: T3, t4: T4) => R} Returns the new partially applied function
331 *
332 * @example
333 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
334 * `${greeting} ${name}, it's ${time}${punctuation}`;
335 * const hiToFredWithRest = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, partialRight.placeholder);
336 * hiToFredWithRest('morning', '!'); // => 'Hi Fred, it's morning!'
337 */
338declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, plc4: __): (t3: T3, t4: T4) => R;
339/**
340 * Creates a function that invokes the provided function with the third argument pre-filled and a placeholder for the fourth.
341 *
342 * @template T1 The type of the first argument
343 * @template T2 The type of the second argument
344 * @template T3 The type of the third argument
345 * @template T4 The type of the fourth argument
346 * @template R The return type of the function
347 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
348 * @param {T3} arg3 The third argument to pre-fill
349 * @param {__} plc4 The placeholder for the fourth argument
350 * @returns {(t1: T1, t2: T2, t4: T4) => R} Returns the new partially applied function
351 *
352 * @example
353 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
354 * `${greeting} ${name}, it's ${time}${punctuation}`;
355 * const atMorningWithPunc = partialRight(format, 'morning', partialRight.placeholder);
356 * atMorningWithPunc('Hi', 'Fred', '!'); // => 'Hi Fred, it's morning!'
357 */
358declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, plc4: __): (t1: T1, t2: T2, t4: T4) => R;
359/**
360 * Creates a function that invokes the provided function with the first and third arguments pre-filled and a placeholder for the fourth.
361 *
362 * @template T1 The type of the first argument
363 * @template T2 The type of the second argument
364 * @template T3 The type of the third argument
365 * @template T4 The type of the fourth argument
366 * @template R The return type of the function
367 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
368 * @param {T1} arg1 The first argument to pre-fill
369 * @param {__} plc2 The placeholder for the second argument
370 * @param {T3} arg3 The third argument to pre-fill
371 * @param {__} plc4 The placeholder for the fourth argument
372 * @returns {(t2: T2, t4: T4) => R} Returns the new partially applied function
373 *
374 * @example
375 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
376 * `${greeting} ${name}, it's ${time}${punctuation}`;
377 * const hiAtMorningWithNameAndPunc = partialRight(format, 'Hi', partialRight.placeholder, 'morning', partialRight.placeholder);
378 * hiAtMorningWithNameAndPunc('Fred', '!'); // => 'Hi Fred, it's morning!'
379 */
380declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, plc4: __): (t2: T2, t4: T4) => R;
381/**
382 * Creates a function that invokes the provided function with the second and third arguments pre-filled and a placeholder for the fourth.
383 *
384 * @template T1 The type of the first argument
385 * @template T2 The type of the second argument
386 * @template T3 The type of the third argument
387 * @template T4 The type of the fourth argument
388 * @template R The return type of the function
389 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
390 * @param {T2} arg2 The second argument to pre-fill
391 * @param {T3} arg3 The third argument to pre-fill
392 * @param {__} plc4 The placeholder for the fourth argument
393 * @returns {(t1: T1, t4: T4) => R} Returns the new partially applied function
394 *
395 * @example
396 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
397 * `${greeting} ${name}, it's ${time}${punctuation}`;
398 * const greetFredAtMorningWithPunc = partialRight(format, 'Fred', 'morning', partialRight.placeholder);
399 * greetFredAtMorningWithPunc('Hi', '!'); // => 'Hi Fred, it's morning!'
400 */
401declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, plc4: __): (t1: T1, t4: T4) => R;
402/**
403 * Creates a function that invokes the provided function with the first three arguments pre-filled and a placeholder for the fourth.
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 {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
411 * @param {T1} arg1 The first argument to pre-fill
412 * @param {T2} arg2 The second argument to pre-fill
413 * @param {T3} arg3 The third argument to pre-fill
414 * @param {__} plc4 The placeholder for the fourth argument
415 * @returns {(t4: T4) => R} Returns the new partially applied function
416 *
417 * @example
418 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
419 * `${greeting} ${name}, it's ${time}${punctuation}`;
420 * const hiToFredAtMorningWithPunc = partialRight(format, 'Hi', 'Fred', 'morning', partialRight.placeholder);
421 * hiToFredAtMorningWithPunc('!'); // => 'Hi Fred, it's morning!'
422 */
423declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, plc4: __): (t4: T4) => R;
424/**
425 * Creates a function that invokes the provided function with the fourth argument pre-filled.
426 *
427 * @template T1 The type of the first argument
428 * @template T2 The type of the second argument
429 * @template T3 The type of the third argument
430 * @template T4 The type of the fourth argument
431 * @template R The return type of the function
432 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
433 * @param {T4} arg4 The fourth argument to pre-fill
434 * @returns {(t1: T1, t2: T2, t3: T3) => R} Returns the new partially applied function
435 *
436 * @example
437 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
438 * `${greeting} ${name}, it's ${time}${punctuation}`;
439 * const withExclamation = partialRight(format, '!');
440 * withExclamation('Hi', 'Fred', 'morning'); // => 'Hi Fred, it's morning!'
441 */
442declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg4: T4): (t1: T1, t2: T2, t3: T3) => R;
443/**
444 * Creates a function that invokes the provided function with the first and fourth arguments pre-filled.
445 *
446 * @template T1 The type of the first argument
447 * @template T2 The type of the second argument
448 * @template T3 The type of the third argument
449 * @template T4 The type of the fourth argument
450 * @template R The return type of the function
451 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
452 * @param {T1} arg1 The first argument to pre-fill
453 * @param {__} plc2 The placeholder for the second argument
454 * @param {__} plc3 The placeholder for the third argument
455 * @param {T4} arg4 The fourth argument to pre-fill
456 * @returns {(t2: T2, t3: T3) => R} Returns the new partially applied function
457 *
458 * @example
459 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
460 * `${greeting} ${name}, it's ${time}${punctuation}`;
461 * const hiWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, partialRight.placeholder, '!');
462 * hiWithExclamation('Fred', 'morning'); // => 'Hi Fred, it's morning!'
463 */
464declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, plc3: __, arg4: T4): (t2: T2, t3: T3) => R;
465/**
466 * Creates a function that invokes the provided function with the second and fourth arguments pre-filled and a placeholder for the third.
467 *
468 * @template T1 The type of the first argument
469 * @template T2 The type of the second argument
470 * @template T3 The type of the third argument
471 * @template T4 The type of the fourth argument
472 * @template R The return type of the function
473 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
474 * @param {T2} arg2 The second argument to pre-fill
475 * @param {__} plc3 The placeholder for the third argument
476 * @param {T4} arg4 The fourth argument to pre-fill
477 * @returns {(t1: T1, t3: T3) => R} Returns the new partially applied function
478 *
479 * @example
480 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
481 * `${greeting} ${name}, it's ${time}${punctuation}`;
482 * const greetFredWithTime = partialRight(format, 'Fred', partialRight.placeholder, '!');
483 * greetFredWithTime('Hi', 'morning'); // => 'Hi Fred, it's morning!'
484 */
485declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, plc3: __, arg4: T4): (t1: T1, t3: T3) => R;
486/**
487 * Creates a function that invokes the provided function with the first, second and fourth arguments pre-filled and a placeholder for the third.
488 *
489 * @template T1 The type of the first argument
490 * @template T2 The type of the second argument
491 * @template T3 The type of the third argument
492 * @template T4 The type of the fourth argument
493 * @template R The return type of the function
494 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
495 * @param {T1} arg1 The first argument to pre-fill
496 * @param {T2} arg2 The second argument to pre-fill
497 * @param {__} plc3 The placeholder for the third argument
498 * @param {T4} arg4 The fourth argument to pre-fill
499 * @returns {(t3: T3) => R} Returns the new partially applied function
500 *
501 * @example
502 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
503 * `${greeting} ${name}, it's ${time}${punctuation}`;
504 * const hiToFredWithTime = partialRight(format, 'Hi', 'Fred', partialRight.placeholder, '!');
505 * hiToFredWithTime('morning'); // => 'Hi Fred, it's morning!'
506 */
507declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, plc3: __, arg4: T4): (t3: T3) => R;
508/**
509 * Creates a function that invokes the provided function with the third and fourth arguments pre-filled.
510 *
511 * @template T1 The type of the first argument
512 * @template T2 The type of the second argument
513 * @template T3 The type of the third argument
514 * @template T4 The type of the fourth argument
515 * @template R The return type of the function
516 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
517 * @param {T3} arg3 The third argument to pre-fill
518 * @param {T4} arg4 The fourth argument to pre-fill
519 * @returns {(t1: T1, t2: T2) => R} Returns the new partially applied function
520 *
521 * @example
522 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
523 * `${greeting} ${name}, it's ${time}${punctuation}`;
524 * const inMorningWithExclamation = partialRight(format, 'morning', '!');
525 * inMorningWithExclamation('Hi', 'Fred'); // => 'Hi Fred, it's morning!'
526 */
527declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg3: T3, arg4: T4): (t1: T1, t2: T2) => R;
528/**
529 * Creates a function that invokes the provided function with the first, third and fourth arguments pre-filled.
530 *
531 * @template T1 The type of the first argument
532 * @template T2 The type of the second argument
533 * @template T3 The type of the third argument
534 * @template T4 The type of the fourth argument
535 * @template R The return type of the function
536 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
537 * @param {T1} arg1 The first argument to pre-fill
538 * @param {__} plc2 The placeholder for the second argument
539 * @param {T3} arg3 The third argument to pre-fill
540 * @param {T4} arg4 The fourth argument to pre-fill
541 * @returns {(t2: T2) => R} Returns the new partially applied function
542 *
543 * @example
544 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
545 * `${greeting} ${name}, it's ${time}${punctuation}`;
546 * const hiInMorningWithExclamation = partialRight(format, 'Hi', partialRight.placeholder, 'morning', '!');
547 * hiInMorningWithExclamation('Fred'); // => 'Hi Fred, it's morning!'
548 */
549declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, plc2: __, arg3: T3, arg4: T4): (t2: T2) => R;
550/**
551 * Creates a function that invokes the provided function with the second, third and fourth arguments pre-filled.
552 *
553 * @template T1 The type of the first argument
554 * @template T2 The type of the second argument
555 * @template T3 The type of the third argument
556 * @template T4 The type of the fourth argument
557 * @template R The return type of the function
558 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
559 * @param {T2} arg2 The second argument to pre-fill
560 * @param {T3} arg3 The third argument to pre-fill
561 * @param {T4} arg4 The fourth argument to pre-fill
562 * @returns {(t1: T1) => R} Returns the new partially applied function
563 *
564 * @example
565 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
566 * `${greeting} ${name}, it's ${time}${punctuation}`;
567 * const greetFredInMorningWithExclamation = partialRight(format, 'Fred', 'morning', '!');
568 * greetFredInMorningWithExclamation('Hi'); // => 'Hi Fred, it's morning!'
569 */
570declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg2: T2, arg3: T3, arg4: T4): (t1: T1) => R;
571/**
572 * Creates a function that invokes the provided function with all arguments pre-filled.
573 *
574 * @template T1 The type of the first argument
575 * @template T2 The type of the second argument
576 * @template T3 The type of the third argument
577 * @template T4 The type of the fourth argument
578 * @template R The return type of the function
579 * @param {(t1: T1, t2: T2, t3: T3, t4: T4) => R} func The function to partially apply
580 * @param {T1} arg1 The first argument to pre-fill
581 * @param {T2} arg2 The second argument to pre-fill
582 * @param {T3} arg3 The third argument to pre-fill
583 * @param {T4} arg4 The fourth argument to pre-fill
584 * @returns {() => R} Returns the new partially applied function
585 *
586 * @example
587 * const format = (greeting: string, name: string, time: string, punctuation: string) =>
588 * `${greeting} ${name}, it's ${time}${punctuation}`;
589 * const sayHiToFredInMorningWithExclamation = partialRight(format, 'Hi', 'Fred', 'morning', '!');
590 * sayHiToFredInMorningWithExclamation(); // => 'Hi Fred, it's morning!'
591 */
592declare function partialRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R, arg1: T1, arg2: T2, arg3: T3, arg4: T4): () => R;
593/**
594 * Creates a function that invokes the provided function with partially applied arguments appended to the arguments it receives.
595 * The partialRight.placeholder value can be used as a placeholder for partially applied arguments.
596 *
597 * @template F The type of the function to partially apply
598 * @param {F} func The function to partially apply arguments to
599 * @param {...any[]} args The arguments to be partially applied
600 * @returns {(...args: any[]) => ReturnType<F>} Returns the new partially applied function
601 *
602 * @example
603 * function greet(greeting: string, name: string) {
604 * return greeting + ' ' + name;
605 * }
606 *
607 * const greetFred = partialRight(greet, 'Fred');
608 * greetFred('Hi'); // => 'Hi Fred'
609 *
610 * // Using placeholders
611 * const sayHelloTo = partialRight(greet, 'Hello', partialRight.placeholder);
612 * sayHelloTo('Fred'); // => 'Hello Fred'
613 */
614declare function partialRight(func: (...args: any[]) => any, ...args: any[]): (...args: any[]) => any;
615declare namespace partialRight {
616 var placeholder: Placeholder;
617}
618type Placeholder = symbol | (((value: any) => any) & {
619 partialRight: typeof partialRight;
620});
621
622export { partialRight };
Note: See TracBrowser for help on using the repository browser.