source: node_modules/es-toolkit/dist/function/flowRight.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: 6.6 KB
RevLine 
[a762898]1/**
2 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
3 *
4 * The `this` context of the returned function is also passed to the functions provided as parameters.
5 *
6 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
7 *
8 * @param {() => R} f The function to invoke.
9 * @returns {() => R} Returns the new composite function.
10 *
11 * @example
12 * function noArgFunc() {
13 * return 42;
14 * }
15 * const combined = flowRight(noArgFunc);
16 * console.log(combined()); // 42
17 */
18declare function flowRight<R>(f: () => R): () => R;
19/**
20 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
21 *
22 * The `this` context of the returned function is also passed to the functions provided as parameters.
23 *
24 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
25 *
26 * @param {(...args: A) => R} f1 The function to invoke.
27 * @returns {(...args: A) => R} Returns the new composite function.
28 *
29 * @example
30 * function oneArgFunc(a: number) {
31 * return a * 2;
32 * }
33 * const combined = flowRight(oneArgFunc);
34 * console.log(combined(5)); // 10
35 */
36declare function flowRight<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
37/**
38 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
39 *
40 * The `this` context of the returned function is also passed to the functions provided as parameters.
41 *
42 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
43 *
44 * @param {(a: R1) => R2} f2 The function to invoke.
45 * @param {(...args: A) => R1} f1 The function to invoke.
46 * @returns {(...args: A) => R2} Returns the new composite function.
47 *
48 * @example
49 * const add = (x: number, y: number) => x + y;
50 * const square = (n: number) => n * n;
51 *
52 * const combined = flowRight(square, add);
53 * console.log(combined(1, 2)); // 9
54 */
55declare function flowRight<A extends any[], R1, R2>(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;
56/**
57 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
58 *
59 * The `this` context of the returned function is also passed to the functions provided as parameters.
60 *
61 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
62 *
63 * @param {(a: R2) => R3} f3 The function to invoke.
64 * @param {(a: R1) => R2} f2 The function to invoke.
65 * @param {(...args: A) => R1} f1 The function to invoke.
66 * @returns {(...args: A) => R3} Returns the new composite function.
67 *
68 * @example
69 * const add = (x: number, y: number) => x + y;
70 * const square = (n: number) => n * n;
71 * const double = (n: number) => n * 2;
72 *
73 * const combined = flowRight(double, square, add);
74 * console.log(combined(1, 2)); // 18
75 */
76declare function flowRight<A extends any[], R1, R2, R3>(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R3;
77/**
78 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
79 *
80 * The `this` context of the returned function is also passed to the functions provided as parameters.
81 *
82 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
83 *
84 * @param {(a: R3) => R4} f4 The function to invoke.
85 * @param {(a: R2) => R3} f3 The function to invoke.
86 * @param {(a: R1) => R2} f2 The function to invoke.
87 * @param {(...args: A) => R1} f1 The function to invoke.
88 * @returns {(...args: A) => R4} Returns the new composite function.
89 *
90 * @example
91 * const add = (x: number, y: number) => x + y;
92 * const square = (n: number) => n * n;
93 * const double = (n: number) => n * 2;
94 * const toStr = (n: number) => n.toString();
95 *
96 * const combined = flowRight(toStr, double, square, add);
97 * console.log(combined(1, 2)); // '18'
98 */
99declare function flowRight<A extends any[], R1, R2, R3, R4>(f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R4;
100/**
101 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
102 *
103 * The `this` context of the returned function is also passed to the functions provided as parameters.
104 *
105 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
106 *
107 * @param {(a: R4) => R5} f5 The function to invoke.
108 * @param {(a: R3) => R4} f4 The function to invoke.
109 * @param {(a: R2) => R3} f3 The function to invoke.
110 * @param {(a: R1) => R2} f2 The function to invoke.
111 * @param {(...args: A) => R1} f1 The function to invoke.
112 * @returns {(...args: A) => R5} Returns the new composite function.
113 *
114 * @example
115 * const add = (x: number, y: number) => x + y;
116 * const square = (n: number) => n * n;
117 * const double = (n: number) => n * 2;
118 * const toStr = (n: number) => n.toString();
119 * const split = (s: string) => s.split('');
120 *
121 * const combined = flowRight(split, toStr, double, square, add);
122 * console.log(combined(1, 2)); // ['1', '8']
123 */
124declare function flowRight<A extends any[], R1, R2, R3, R4, R5>(f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R5;
125/**
126 * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
127 *
128 * The `this` context of the returned function is also passed to the functions provided as parameters.
129 *
130 * This method is like `flow` except that it creates a function that invokes the given functions from right to left.
131 *
132 * @param {(...args: any[]) => any} funcs The functions to invoke.
133 * @returns {(...args: any[]) => any} Returns the new composite function.
134 *
135 * @example
136 * const add = (x: number, y: number) => x + y;
137 * const square = (n: number) => n * n;
138 *
139 * const combined = flowRight(square, add);
140 * console.log(combined(1, 2)); // 9
141 */
142declare function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
143
144export { flowRight };
Note: See TracBrowser for help on using the repository browser.