es-toolkit 1.22.0-dev.697 → 1.22.0-dev.698

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.
@@ -56,6 +56,7 @@ export { MemoizeCache, memoize } from '../function/memoize.mjs';
56
56
  export { unary } from '../function/unary.mjs';
57
57
  export { partial } from '../function/partial.mjs';
58
58
  export { partialRight } from '../function/partialRight.mjs';
59
+ export { curryRight } from '../function/curryRight.mjs';
59
60
  export { flow } from '../function/flow.mjs';
60
61
  export { flowRight } from '../function/flowRight.mjs';
61
62
  export { mean } from '../math/mean.mjs';
@@ -56,6 +56,7 @@ export { MemoizeCache, memoize } from '../function/memoize.js';
56
56
  export { unary } from '../function/unary.js';
57
57
  export { partial } from '../function/partial.js';
58
58
  export { partialRight } from '../function/partialRight.js';
59
+ export { curryRight } from '../function/curryRight.js';
59
60
  export { flow } from '../function/flow.js';
60
61
  export { flowRight } from '../function/flowRight.js';
61
62
  export { mean } from '../math/mean.js';
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const zipWith = require('../_chunk/zipWith-EOU_KZ.js');
6
6
  const promise_index = require('../_chunk/index-BGZDR9.js');
7
- const flowRight = require('../_chunk/flowRight-BzdOZX.js');
7
+ const flowRight = require('../_chunk/flowRight-DD5Qyk.js');
8
8
  const range = require('../_chunk/range-BXlMmn.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
10
  const toMerged = require('../_chunk/toMerged-DD-s3X.js');
@@ -1847,6 +1847,7 @@ exports.timeout = promise_index.timeout;
1847
1847
  exports.withTimeout = promise_index.withTimeout;
1848
1848
  exports.after = flowRight.after;
1849
1849
  exports.before = flowRight.before;
1850
+ exports.curryRight = flowRight.curryRight;
1850
1851
  exports.flow = flowRight.flow;
1851
1852
  exports.flowRight = flowRight.flowRight;
1852
1853
  exports.memoize = flowRight.memoize;
@@ -56,6 +56,7 @@ export { memoize } from '../function/memoize.mjs';
56
56
  export { unary } from '../function/unary.mjs';
57
57
  export { partial } from '../function/partial.mjs';
58
58
  export { partialRight } from '../function/partialRight.mjs';
59
+ export { curryRight } from '../function/curryRight.mjs';
59
60
  export { flow } from '../function/flow.mjs';
60
61
  export { flowRight } from '../function/flowRight.mjs';
61
62
  export { mean } from '../math/mean.mjs';
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
3
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
4
+ *
5
+ * Unlike `curry`, this function curries the function from right to left.
6
+ *
7
+ * @param {() => R} func - The function to curry.
8
+ * @returns {() => R} A curried function.
9
+ *
10
+ * @example
11
+ * function noArgFunc() {
12
+ * return 42;
13
+ * }
14
+ * const curriedNoArgFunc = curryRight(noArgFunc);
15
+ * console.log(curriedNoArgFunc()); // 42
16
+ */
17
+ declare function curryRight<R>(func: () => R): () => R;
18
+ /**
19
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
20
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
21
+ *
22
+ * Unlike `curry`, this function curries the function from right to left.
23
+ *
24
+ * @param {(p: P) => R} func - The function to curry.
25
+ * @returns {(p: P) => R} A curried function.
26
+ *
27
+ * @example
28
+ * function oneArgFunc(a: number) {
29
+ * return a * 2;
30
+ * }
31
+ * const curriedOneArgFunc = curryRight(oneArgFunc);
32
+ * console.log(curriedOneArgFunc(5)); // 10
33
+ */
34
+ declare function curryRight<P, R>(func: (p: P) => R): (p: P) => R;
35
+ /**
36
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
37
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
38
+ *
39
+ * Unlike `curry`, this function curries the function from right to left.
40
+ *
41
+ * @param {(p1: P1, p2: P2) => R} func - The function to curry.
42
+ * @returns {(p1: P2) => (p2: P1) => R} A curried function.
43
+ *
44
+ * @example
45
+ * function twoArgFunc(a: number, b: number) {
46
+ * return [a, b];
47
+ * }
48
+ * const curriedTwoArgFunc = curryRight(twoArgFunc);
49
+ * const func = curriedTwoArgFunc(1);
50
+ * console.log(func(2)); // [2, 1]
51
+ */
52
+ declare function curryRight<P1, P2, R>(func: (p1: P1, p2: P2) => R): (p1: P2) => (p2: P1) => R;
53
+ /**
54
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
55
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
56
+ *
57
+ * Unlike `curry`, this function curries the function from right to left.
58
+ *
59
+ * @param {(p1: P1, p2: P2, p3: P3) => R} func - The function to curry.
60
+ * @returns {(p1: P3) => (p2: P2) => (p3: P1) => R} A curried function.
61
+ *
62
+ * @example
63
+ * function threeArgFunc(a: number, b: number, c: number) {
64
+ * return [a, b, c];
65
+ * }
66
+ * const curriedThreeArgFunc = curryRight(threeArgFunc);
67
+ * const func = curriedThreeArgFunc(1);
68
+ * const func2 = func(2);
69
+ * console.log(func2(3)); // [3, 2, 1]
70
+ */
71
+ declare function curryRight<P1, P2, P3, R>(func: (p1: P1, p2: P2, p3: P3) => R): (p1: P3) => (p2: P2) => (p3: P1) => R;
72
+ /**
73
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
74
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
75
+ *
76
+ * Unlike `curry`, this function curries the function from right to left.
77
+ *
78
+ * @param {(p1: P1, p2: P2, p3: P3, p4: P4) => R} func - The function to curry.
79
+ * @returns {(p1: P4) => (p2: P3) => (p3: P2) => (p4: P1) => R} A curried function.
80
+ *
81
+ * @example
82
+ * function fourArgFunc(a: number, b: number, c: number, d: number) {
83
+ * return [a, b, c, d];
84
+ * }
85
+ * const curriedFourArgFunc = curryRight(fourArgFunc);
86
+ * const func = curriedFourArgFunc(1);
87
+ * const func2 = func(2);
88
+ * const func3 = func2(3);
89
+ * console.log(func3(4)); // [4, 3, 2, 1]
90
+ */
91
+ declare function curryRight<P1, P2, P3, P4, R>(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p1: P4) => (p2: P3) => (p3: P2) => (p4: P1) => R;
92
+ /**
93
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
94
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
95
+ *
96
+ * Unlike `curry`, this function curries the function from right to left.
97
+ *
98
+ * @param {(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R} func - The function to curry.
99
+ * @returns {(p1: P5) => (p2: P4) => (p3: P3) => (p4: P2) => (p5: P1) => R} A curried function.
100
+ *
101
+ * @example
102
+ * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) {
103
+ * return [a, b, c, d, e];
104
+ * }
105
+ * const curriedFiveArgFunc = curryRight(fiveArgFunc);
106
+ * const func = curriedFiveArgFunc(1);
107
+ * const func2 = func(2);
108
+ * const func3 = func2(3);
109
+ * const func4 = func3(4);
110
+ * console.log(func4(5)); // [5, 4, 3, 2, 1]
111
+ */
112
+ declare function curryRight<P1, P2, P3, P4, P5, R>(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p1: P5) => (p2: P4) => (p3: P3) => (p4: P2) => (p5: P1) => R;
113
+ /**
114
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
115
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
116
+ *
117
+ * Unlike `curry`, this function curries the function from right to left.
118
+ *
119
+ * @param {(...args: any[]) => any} func - The function to curry.
120
+ * @returns {(...args: any[]) => any} A curried function.
121
+ *
122
+ * @example
123
+ * function sum(a: number, b: number, c: number) {
124
+ * return a + b + c;
125
+ * }
126
+ *
127
+ * const curriedSum = curryRight(sum);
128
+ *
129
+ * // The parameter `c` should be given the value `10`.
130
+ * const add10 = curriedSum(10);
131
+ *
132
+ * // The parameter `b` should be given the value `15`.
133
+ * const add25 = add10(15);
134
+ *
135
+ * // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value.
136
+ * const result = add25(5);
137
+ */
138
+ declare function curryRight(func: (...args: any[]) => any): (...args: any[]) => any;
139
+
140
+ export { curryRight };
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
3
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
4
+ *
5
+ * Unlike `curry`, this function curries the function from right to left.
6
+ *
7
+ * @param {() => R} func - The function to curry.
8
+ * @returns {() => R} A curried function.
9
+ *
10
+ * @example
11
+ * function noArgFunc() {
12
+ * return 42;
13
+ * }
14
+ * const curriedNoArgFunc = curryRight(noArgFunc);
15
+ * console.log(curriedNoArgFunc()); // 42
16
+ */
17
+ declare function curryRight<R>(func: () => R): () => R;
18
+ /**
19
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
20
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
21
+ *
22
+ * Unlike `curry`, this function curries the function from right to left.
23
+ *
24
+ * @param {(p: P) => R} func - The function to curry.
25
+ * @returns {(p: P) => R} A curried function.
26
+ *
27
+ * @example
28
+ * function oneArgFunc(a: number) {
29
+ * return a * 2;
30
+ * }
31
+ * const curriedOneArgFunc = curryRight(oneArgFunc);
32
+ * console.log(curriedOneArgFunc(5)); // 10
33
+ */
34
+ declare function curryRight<P, R>(func: (p: P) => R): (p: P) => R;
35
+ /**
36
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
37
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
38
+ *
39
+ * Unlike `curry`, this function curries the function from right to left.
40
+ *
41
+ * @param {(p1: P1, p2: P2) => R} func - The function to curry.
42
+ * @returns {(p1: P2) => (p2: P1) => R} A curried function.
43
+ *
44
+ * @example
45
+ * function twoArgFunc(a: number, b: number) {
46
+ * return [a, b];
47
+ * }
48
+ * const curriedTwoArgFunc = curryRight(twoArgFunc);
49
+ * const func = curriedTwoArgFunc(1);
50
+ * console.log(func(2)); // [2, 1]
51
+ */
52
+ declare function curryRight<P1, P2, R>(func: (p1: P1, p2: P2) => R): (p1: P2) => (p2: P1) => R;
53
+ /**
54
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
55
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
56
+ *
57
+ * Unlike `curry`, this function curries the function from right to left.
58
+ *
59
+ * @param {(p1: P1, p2: P2, p3: P3) => R} func - The function to curry.
60
+ * @returns {(p1: P3) => (p2: P2) => (p3: P1) => R} A curried function.
61
+ *
62
+ * @example
63
+ * function threeArgFunc(a: number, b: number, c: number) {
64
+ * return [a, b, c];
65
+ * }
66
+ * const curriedThreeArgFunc = curryRight(threeArgFunc);
67
+ * const func = curriedThreeArgFunc(1);
68
+ * const func2 = func(2);
69
+ * console.log(func2(3)); // [3, 2, 1]
70
+ */
71
+ declare function curryRight<P1, P2, P3, R>(func: (p1: P1, p2: P2, p3: P3) => R): (p1: P3) => (p2: P2) => (p3: P1) => R;
72
+ /**
73
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
74
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
75
+ *
76
+ * Unlike `curry`, this function curries the function from right to left.
77
+ *
78
+ * @param {(p1: P1, p2: P2, p3: P3, p4: P4) => R} func - The function to curry.
79
+ * @returns {(p1: P4) => (p2: P3) => (p3: P2) => (p4: P1) => R} A curried function.
80
+ *
81
+ * @example
82
+ * function fourArgFunc(a: number, b: number, c: number, d: number) {
83
+ * return [a, b, c, d];
84
+ * }
85
+ * const curriedFourArgFunc = curryRight(fourArgFunc);
86
+ * const func = curriedFourArgFunc(1);
87
+ * const func2 = func(2);
88
+ * const func3 = func2(3);
89
+ * console.log(func3(4)); // [4, 3, 2, 1]
90
+ */
91
+ declare function curryRight<P1, P2, P3, P4, R>(func: (p1: P1, p2: P2, p3: P3, p4: P4) => R): (p1: P4) => (p2: P3) => (p3: P2) => (p4: P1) => R;
92
+ /**
93
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
94
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
95
+ *
96
+ * Unlike `curry`, this function curries the function from right to left.
97
+ *
98
+ * @param {(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R} func - The function to curry.
99
+ * @returns {(p1: P5) => (p2: P4) => (p3: P3) => (p4: P2) => (p5: P1) => R} A curried function.
100
+ *
101
+ * @example
102
+ * function fiveArgFunc(a: number, b: number, c: number, d: number, e: number) {
103
+ * return [a, b, c, d, e];
104
+ * }
105
+ * const curriedFiveArgFunc = curryRight(fiveArgFunc);
106
+ * const func = curriedFiveArgFunc(1);
107
+ * const func2 = func(2);
108
+ * const func3 = func2(3);
109
+ * const func4 = func3(4);
110
+ * console.log(func4(5)); // [5, 4, 3, 2, 1]
111
+ */
112
+ declare function curryRight<P1, P2, P3, P4, P5, R>(func: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => R): (p1: P5) => (p2: P4) => (p3: P3) => (p4: P2) => (p5: P1) => R;
113
+ /**
114
+ * Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument.
115
+ * This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments.
116
+ *
117
+ * Unlike `curry`, this function curries the function from right to left.
118
+ *
119
+ * @param {(...args: any[]) => any} func - The function to curry.
120
+ * @returns {(...args: any[]) => any} A curried function.
121
+ *
122
+ * @example
123
+ * function sum(a: number, b: number, c: number) {
124
+ * return a + b + c;
125
+ * }
126
+ *
127
+ * const curriedSum = curryRight(sum);
128
+ *
129
+ * // The parameter `c` should be given the value `10`.
130
+ * const add10 = curriedSum(10);
131
+ *
132
+ * // The parameter `b` should be given the value `15`.
133
+ * const add25 = add10(15);
134
+ *
135
+ * // The parameter `a` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value.
136
+ * const result = add25(5);
137
+ */
138
+ declare function curryRight(func: (...args: any[]) => any): (...args: any[]) => any;
139
+
140
+ export { curryRight };
@@ -0,0 +1,21 @@
1
+ function curryRight(func) {
2
+ if (func.length === 0 || func.length === 1) {
3
+ return func;
4
+ }
5
+ return function (arg) {
6
+ return makeCurryRight(func, func.length, [arg]);
7
+ };
8
+ }
9
+ function makeCurryRight(origin, argsLength, args) {
10
+ if (args.length === argsLength) {
11
+ return origin(...args);
12
+ }
13
+ else {
14
+ const next = function (arg) {
15
+ return makeCurryRight(origin, argsLength, [arg, ...args]);
16
+ };
17
+ return next;
18
+ }
19
+ }
20
+
21
+ export { curryRight };
@@ -12,6 +12,7 @@ export { partial } from './partial.mjs';
12
12
  export { partialRight } from './partialRight.mjs';
13
13
  export { rest } from './rest.mjs';
14
14
  export { curry } from './curry.mjs';
15
+ export { curryRight } from './curryRight.mjs';
15
16
  export { spread } from './spread.mjs';
16
17
  export { flow } from './flow.mjs';
17
18
  export { flowRight } from './flowRight.mjs';
@@ -12,6 +12,7 @@ export { partial } from './partial.js';
12
12
  export { partialRight } from './partialRight.js';
13
13
  export { rest } from './rest.js';
14
14
  export { curry } from './curry.js';
15
+ export { curryRight } from './curryRight.js';
15
16
  export { spread } from './spread.js';
16
17
  export { flow } from './flow.js';
17
18
  export { flowRight } from './flowRight.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const flowRight = require('../_chunk/flowRight-BzdOZX.js');
5
+ const flowRight = require('../_chunk/flowRight-DD5Qyk.js');
6
6
 
7
7
  function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] } = {}) {
8
8
  let pendingAt = null;
@@ -54,6 +54,7 @@ function spread(func) {
54
54
  exports.after = flowRight.after;
55
55
  exports.ary = flowRight.ary;
56
56
  exports.before = flowRight.before;
57
+ exports.curryRight = flowRight.curryRight;
57
58
  exports.debounce = flowRight.debounce;
58
59
  exports.flow = flowRight.flow;
59
60
  exports.flowRight = flowRight.flowRight;
@@ -12,6 +12,7 @@ export { partial } from './partial.mjs';
12
12
  export { partialRight } from './partialRight.mjs';
13
13
  export { rest } from './rest.mjs';
14
14
  export { curry } from './curry.mjs';
15
+ export { curryRight } from './curryRight.mjs';
15
16
  export { spread } from './spread.mjs';
16
17
  export { flow } from './flow.mjs';
17
18
  export { flowRight } from './flowRight.mjs';
package/dist/index.d.mts CHANGED
@@ -70,6 +70,7 @@ export { partial } from './function/partial.mjs';
70
70
  export { partialRight } from './function/partialRight.mjs';
71
71
  export { rest } from './function/rest.mjs';
72
72
  export { curry } from './function/curry.mjs';
73
+ export { curryRight } from './function/curryRight.mjs';
73
74
  export { spread } from './function/spread.mjs';
74
75
  export { flow } from './function/flow.mjs';
75
76
  export { flowRight } from './function/flowRight.mjs';
package/dist/index.d.ts CHANGED
@@ -70,6 +70,7 @@ export { partial } from './function/partial.js';
70
70
  export { partialRight } from './function/partialRight.js';
71
71
  export { rest } from './function/rest.js';
72
72
  export { curry } from './function/curry.js';
73
+ export { curryRight } from './function/curryRight.js';
73
74
  export { spread } from './function/spread.js';
74
75
  export { flow } from './function/flow.js';
75
76
  export { flowRight } from './function/flowRight.js';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const zipWith = require('./_chunk/zipWith-EOU_KZ.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const promise_index = require('./_chunk/index-BGZDR9.js');
8
- const flowRight = require('./_chunk/flowRight-BzdOZX.js');
8
+ const flowRight = require('./_chunk/flowRight-DD5Qyk.js');
9
9
  const function_index = require('./function/index.js');
10
10
  const range = require('./_chunk/range-BXlMmn.js');
11
11
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
@@ -84,6 +84,7 @@ exports.withTimeout = promise_index.withTimeout;
84
84
  exports.after = flowRight.after;
85
85
  exports.ary = flowRight.ary;
86
86
  exports.before = flowRight.before;
87
+ exports.curryRight = flowRight.curryRight;
87
88
  exports.debounce = flowRight.debounce;
88
89
  exports.flow = flowRight.flow;
89
90
  exports.flowRight = flowRight.flowRight;
package/dist/index.mjs CHANGED
@@ -70,6 +70,7 @@ export { partial } from './function/partial.mjs';
70
70
  export { partialRight } from './function/partialRight.mjs';
71
71
  export { rest } from './function/rest.mjs';
72
72
  export { curry } from './function/curry.mjs';
73
+ export { curryRight } from './function/curryRight.mjs';
73
74
  export { spread } from './function/spread.mjs';
74
75
  export { flow } from './function/flow.mjs';
75
76
  export { flowRight } from './function/flowRight.mjs';
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.22.0-dev.697+ded56755",
4
+ "version": "1.22.0-dev.698+20426dfd",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {