es-toolkit 1.21.0-dev.680 → 1.21.0-dev.681
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.
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Reverses the order of arguments for a given function.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
4
|
+
* @template F - The type of the function being flipped.
|
|
5
|
+
* @param {F} func - The function whose arguments will be reversed.
|
|
6
|
+
* @returns {(...args: Reversed<Parameters<F>>) => ReturnType<F>} A new function that takes the
|
|
7
|
+
* reversed arguments and returns the result of calling `func`.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
|
-
* function fn(a:
|
|
10
|
+
* function fn(a: string, b: string, c: string, d: string) {
|
|
9
11
|
* return [a, b, c, d];
|
|
10
12
|
* }
|
|
11
13
|
*
|
|
12
14
|
* const flipped = flip(fn);
|
|
13
15
|
* flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a']
|
|
14
16
|
*/
|
|
15
|
-
declare function flip<F extends (...args: any[]) => any>(func: F): (...args:
|
|
16
|
-
type
|
|
17
|
+
declare function flip<F extends (...args: any[]) => any>(func: F): (...args: Reversed<Parameters<F>>) => ReturnType<F>;
|
|
18
|
+
type Reversed<T extends any[]> = T extends [infer First, ...infer Rest] ? [...Reversed<Rest>, First] : [];
|
|
17
19
|
|
|
18
20
|
export { flip };
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Reverses the order of arguments for a given function.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
4
|
+
* @template F - The type of the function being flipped.
|
|
5
|
+
* @param {F} func - The function whose arguments will be reversed.
|
|
6
|
+
* @returns {(...args: Reversed<Parameters<F>>) => ReturnType<F>} A new function that takes the
|
|
7
|
+
* reversed arguments and returns the result of calling `func`.
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
|
-
* function fn(a:
|
|
10
|
+
* function fn(a: string, b: string, c: string, d: string) {
|
|
9
11
|
* return [a, b, c, d];
|
|
10
12
|
* }
|
|
11
13
|
*
|
|
12
14
|
* const flipped = flip(fn);
|
|
13
15
|
* flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a']
|
|
14
16
|
*/
|
|
15
|
-
declare function flip<F extends (...args: any[]) => any>(func: F): (...args:
|
|
16
|
-
type
|
|
17
|
+
declare function flip<F extends (...args: any[]) => any>(func: F): (...args: Reversed<Parameters<F>>) => ReturnType<F>;
|
|
18
|
+
type Reversed<T extends any[]> = T extends [infer First, ...infer Rest] ? [...Reversed<Rest>, First] : [];
|
|
17
19
|
|
|
18
20
|
export { flip };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.21.0-dev.
|
|
4
|
+
"version": "1.21.0-dev.681+7eed956e",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|