es-toolkit 1.17.0-dev.509 → 1.17.0-dev.511
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/_chunk/{initial-Ci2bn_.js → initial-L_KfII.js} +5 -0
- package/dist/_chunk/rest-Bzm2XK.js +182 -0
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +2 -1
- package/dist/array/index.mjs +1 -0
- package/dist/array/join.d.mts +20 -0
- package/dist/array/join.d.ts +20 -0
- package/dist/array/join.mjs +5 -0
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/function/spread.d.mts +42 -6
- package/dist/compat/function/spread.d.ts +42 -6
- package/dist/compat/function/spread.mjs +12 -7
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +29 -21
- package/dist/compat/index.mjs +1 -0
- package/dist/function/index.js +21 -191
- package/dist/function/spread.d.mts +14 -6
- package/dist/function/spread.d.ts +14 -6
- package/dist/function/spread.mjs +3 -8
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -14
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creates a function that
|
|
2
|
+
* Creates a new function that spreads elements of an array argument into individual arguments
|
|
3
|
+
* for the original function. The array argument is positioned based on the `argsIndex` parameter.
|
|
3
4
|
*
|
|
4
|
-
* @template F
|
|
5
|
-
* @param {F} func The function to
|
|
6
|
-
* @param {number}
|
|
7
|
-
*
|
|
5
|
+
* @template F - A function type with any number of parameters and any return type.
|
|
6
|
+
* @param {F} func - The function to be transformed. It can be any function with any number of arguments.
|
|
7
|
+
* @param {number} [argsIndex=0] - The index where the array argument is positioned among the other arguments.
|
|
8
|
+
* If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer.
|
|
9
|
+
* @returns {(...args: any[]) => ReturnType<F>} - A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`,
|
|
10
|
+
* and returns the result of calling the original function with those arguments.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* function add(a, b) {
|
|
14
|
+
* return a + b;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const spreadAdd = spread(add);
|
|
18
|
+
* console.log(spreadAdd([1, 2])); // Output: 3
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Example function to spread arguments over
|
|
22
|
+
* function add(a, b) {
|
|
23
|
+
* return a + b;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Create a new function that uses `spread` to combine arguments
|
|
27
|
+
* const spreadAdd = spread(add, 1);
|
|
28
|
+
*
|
|
29
|
+
* // Calling `spreadAdd` with an array as the second argument
|
|
30
|
+
* console.log(spreadAdd(1, [2])); // Output: 3
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Function with default arguments
|
|
34
|
+
* function greet(name, greeting = 'Hello') {
|
|
35
|
+
* return `${greeting}, ${name}!`;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // Create a new function that uses `spread` to position the argument array at index 0
|
|
39
|
+
* const spreadGreet = spread(greet, 0);
|
|
40
|
+
*
|
|
41
|
+
* // Calling `spreadGreet` with an array of arguments
|
|
42
|
+
* console.log(spreadGreet(['Alice'])); // Output: Hello, Alice!
|
|
43
|
+
* console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob!
|
|
8
44
|
*/
|
|
9
|
-
declare function spread<F extends (...args: any[]) => any>(func: F,
|
|
45
|
+
declare function spread<F extends (...args: any[]) => any>(func: F, argsIndex?: number): (...args: any[]) => ReturnType<F>;
|
|
10
46
|
|
|
11
47
|
export { spread };
|
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creates a function that
|
|
2
|
+
* Creates a new function that spreads elements of an array argument into individual arguments
|
|
3
|
+
* for the original function. The array argument is positioned based on the `argsIndex` parameter.
|
|
3
4
|
*
|
|
4
|
-
* @template F
|
|
5
|
-
* @param {F} func The function to
|
|
6
|
-
* @param {number}
|
|
7
|
-
*
|
|
5
|
+
* @template F - A function type with any number of parameters and any return type.
|
|
6
|
+
* @param {F} func - The function to be transformed. It can be any function with any number of arguments.
|
|
7
|
+
* @param {number} [argsIndex=0] - The index where the array argument is positioned among the other arguments.
|
|
8
|
+
* If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer.
|
|
9
|
+
* @returns {(...args: any[]) => ReturnType<F>} - A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`,
|
|
10
|
+
* and returns the result of calling the original function with those arguments.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* function add(a, b) {
|
|
14
|
+
* return a + b;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* const spreadAdd = spread(add);
|
|
18
|
+
* console.log(spreadAdd([1, 2])); // Output: 3
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Example function to spread arguments over
|
|
22
|
+
* function add(a, b) {
|
|
23
|
+
* return a + b;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Create a new function that uses `spread` to combine arguments
|
|
27
|
+
* const spreadAdd = spread(add, 1);
|
|
28
|
+
*
|
|
29
|
+
* // Calling `spreadAdd` with an array as the second argument
|
|
30
|
+
* console.log(spreadAdd(1, [2])); // Output: 3
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Function with default arguments
|
|
34
|
+
* function greet(name, greeting = 'Hello') {
|
|
35
|
+
* return `${greeting}, ${name}!`;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // Create a new function that uses `spread` to position the argument array at index 0
|
|
39
|
+
* const spreadGreet = spread(greet, 0);
|
|
40
|
+
*
|
|
41
|
+
* // Calling `spreadGreet` with an array of arguments
|
|
42
|
+
* console.log(spreadGreet(['Alice'])); // Output: Hello, Alice!
|
|
43
|
+
* console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob!
|
|
8
44
|
*/
|
|
9
|
-
declare function spread<F extends (...args: any[]) => any>(func: F,
|
|
45
|
+
declare function spread<F extends (...args: any[]) => any>(func: F, argsIndex?: number): (...args: any[]) => ReturnType<F>;
|
|
10
46
|
|
|
11
47
|
export { spread };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (Number.isNaN(startIndex) || startIndex < 0) {
|
|
6
|
-
startIndex = 0;
|
|
1
|
+
function spread(func, argsIndex = 0) {
|
|
2
|
+
argsIndex = Number.parseInt(argsIndex, 10);
|
|
3
|
+
if (Number.isNaN(argsIndex) || argsIndex < 0) {
|
|
4
|
+
argsIndex = 0;
|
|
7
5
|
}
|
|
8
|
-
return
|
|
6
|
+
return function (...args) {
|
|
7
|
+
const array = args[argsIndex];
|
|
8
|
+
const params = args.slice(0, argsIndex);
|
|
9
|
+
if (array) {
|
|
10
|
+
params.push(...array);
|
|
11
|
+
}
|
|
12
|
+
return func.apply(this, params);
|
|
13
|
+
};
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export { spread };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ export { groupBy } from '../array/groupBy.mjs';
|
|
|
13
13
|
export { intersection } from '../array/intersection.mjs';
|
|
14
14
|
export { intersectionBy } from '../array/intersectionBy.mjs';
|
|
15
15
|
export { intersectionWith } from '../array/intersectionWith.mjs';
|
|
16
|
+
export { join } from '../array/join.mjs';
|
|
16
17
|
export { keyBy } from '../array/keyBy.mjs';
|
|
17
18
|
export { maxBy } from '../array/maxBy.mjs';
|
|
18
19
|
export { minBy } from '../array/minBy.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { groupBy } from '../array/groupBy.js';
|
|
|
13
13
|
export { intersection } from '../array/intersection.js';
|
|
14
14
|
export { intersectionBy } from '../array/intersectionBy.js';
|
|
15
15
|
export { intersectionWith } from '../array/intersectionWith.js';
|
|
16
|
+
export { join } from '../array/join.js';
|
|
16
17
|
export { keyBy } from '../array/keyBy.js';
|
|
17
18
|
export { maxBy } from '../array/maxBy.js';
|
|
18
19
|
export { minBy } from '../array/minBy.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const initial = require('../_chunk/initial-
|
|
5
|
+
const initial = require('../_chunk/initial-L_KfII.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
|
-
const
|
|
7
|
+
const rest$1 = require('../_chunk/rest-Bzm2XK.js');
|
|
8
8
|
const math_index = require('../math/index.js');
|
|
9
9
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
10
10
|
const toMerged = require('../_chunk/toMerged-BGwYW5.js');
|
|
@@ -574,7 +574,7 @@ function ary(func, n = func.length, guard) {
|
|
|
574
574
|
if (Number.isNaN(n) || n < 0) {
|
|
575
575
|
n = 0;
|
|
576
576
|
}
|
|
577
|
-
return
|
|
577
|
+
return rest$1.ary(func, n);
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
function bind(func, thisObj, ...partialArgs) {
|
|
@@ -608,15 +608,22 @@ function rest(func, start = func.length - 1) {
|
|
|
608
608
|
if (Number.isNaN(start) || start < 0) {
|
|
609
609
|
start = func.length - 1;
|
|
610
610
|
}
|
|
611
|
-
return
|
|
611
|
+
return rest$1.rest(func, start);
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
function spread(func,
|
|
615
|
-
|
|
616
|
-
if (Number.isNaN(
|
|
617
|
-
|
|
614
|
+
function spread(func, argsIndex = 0) {
|
|
615
|
+
argsIndex = Number.parseInt(argsIndex, 10);
|
|
616
|
+
if (Number.isNaN(argsIndex) || argsIndex < 0) {
|
|
617
|
+
argsIndex = 0;
|
|
618
618
|
}
|
|
619
|
-
return
|
|
619
|
+
return function (...args) {
|
|
620
|
+
const array = args[argsIndex];
|
|
621
|
+
const params = args.slice(0, argsIndex);
|
|
622
|
+
if (array) {
|
|
623
|
+
params.push(...array);
|
|
624
|
+
}
|
|
625
|
+
return func.apply(this, params);
|
|
626
|
+
};
|
|
620
627
|
}
|
|
621
628
|
|
|
622
629
|
function identity(x) {
|
|
@@ -750,7 +757,7 @@ function mergeWithDeep(target, source, merge, stack) {
|
|
|
750
757
|
}
|
|
751
758
|
|
|
752
759
|
function merge(object, ...sources) {
|
|
753
|
-
return mergeWith(object, ...sources,
|
|
760
|
+
return mergeWith(object, ...sources, rest$1.noop);
|
|
754
761
|
}
|
|
755
762
|
|
|
756
763
|
function isArray(value) {
|
|
@@ -844,6 +851,7 @@ exports.intersection = initial.intersection;
|
|
|
844
851
|
exports.intersectionBy = initial.intersectionBy;
|
|
845
852
|
exports.intersectionWith = initial.intersectionWith;
|
|
846
853
|
exports.isSubset = initial.isSubset;
|
|
854
|
+
exports.join = initial.join;
|
|
847
855
|
exports.keyBy = initial.keyBy;
|
|
848
856
|
exports.last = initial.last;
|
|
849
857
|
exports.maxBy = initial.maxBy;
|
|
@@ -880,17 +888,17 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
880
888
|
exports.delay = promise_index.delay;
|
|
881
889
|
exports.timeout = promise_index.timeout;
|
|
882
890
|
exports.withTimeout = promise_index.withTimeout;
|
|
883
|
-
exports.after =
|
|
884
|
-
exports.before =
|
|
885
|
-
exports.debounce =
|
|
886
|
-
exports.memoize =
|
|
887
|
-
exports.negate =
|
|
888
|
-
exports.noop =
|
|
889
|
-
exports.once =
|
|
890
|
-
exports.partial =
|
|
891
|
-
exports.partialRight =
|
|
892
|
-
exports.throttle =
|
|
893
|
-
exports.unary =
|
|
891
|
+
exports.after = rest$1.after;
|
|
892
|
+
exports.before = rest$1.before;
|
|
893
|
+
exports.debounce = rest$1.debounce;
|
|
894
|
+
exports.memoize = rest$1.memoize;
|
|
895
|
+
exports.negate = rest$1.negate;
|
|
896
|
+
exports.noop = rest$1.noop;
|
|
897
|
+
exports.once = rest$1.once;
|
|
898
|
+
exports.partial = rest$1.partial;
|
|
899
|
+
exports.partialRight = rest$1.partialRight;
|
|
900
|
+
exports.throttle = rest$1.throttle;
|
|
901
|
+
exports.unary = rest$1.unary;
|
|
894
902
|
exports.clamp = math_index.clamp;
|
|
895
903
|
exports.inRange = math_index.inRange;
|
|
896
904
|
exports.mean = math_index.mean;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ export { groupBy } from '../array/groupBy.mjs';
|
|
|
13
13
|
export { intersection } from '../array/intersection.mjs';
|
|
14
14
|
export { intersectionBy } from '../array/intersectionBy.mjs';
|
|
15
15
|
export { intersectionWith } from '../array/intersectionWith.mjs';
|
|
16
|
+
export { join } from '../array/join.mjs';
|
|
16
17
|
export { keyBy } from '../array/keyBy.mjs';
|
|
17
18
|
export { maxBy } from '../array/maxBy.mjs';
|
|
18
19
|
export { minBy } from '../array/minBy.mjs';
|
package/dist/function/index.js
CHANGED
|
@@ -2,195 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function debounce(func, debounceMs, { signal } = {}) {
|
|
32
|
-
let timeoutId = null;
|
|
33
|
-
const debounced = function (...args) {
|
|
34
|
-
if (timeoutId !== null) {
|
|
35
|
-
clearTimeout(timeoutId);
|
|
36
|
-
}
|
|
37
|
-
if (signal?.aborted) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
timeoutId = setTimeout(() => {
|
|
41
|
-
func(...args);
|
|
42
|
-
timeoutId = null;
|
|
43
|
-
}, debounceMs);
|
|
44
|
-
};
|
|
45
|
-
const onAbort = function () {
|
|
46
|
-
debounced.cancel();
|
|
47
|
-
};
|
|
48
|
-
debounced.cancel = function () {
|
|
49
|
-
if (timeoutId !== null) {
|
|
50
|
-
clearTimeout(timeoutId);
|
|
51
|
-
timeoutId = null;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
signal?.addEventListener('abort', onAbort, { once: true });
|
|
55
|
-
return debounced;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function noop() { }
|
|
59
|
-
|
|
60
|
-
function once(func) {
|
|
61
|
-
let called = false;
|
|
62
|
-
let cache;
|
|
63
|
-
return function () {
|
|
64
|
-
if (called) {
|
|
65
|
-
return cache;
|
|
66
|
-
}
|
|
67
|
-
const result = func();
|
|
68
|
-
called = true;
|
|
69
|
-
cache = result;
|
|
70
|
-
return result;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function throttle(func, throttleMs) {
|
|
75
|
-
let lastCallTime;
|
|
76
|
-
const throttledFunction = function (...args) {
|
|
77
|
-
const now = Date.now();
|
|
78
|
-
if (lastCallTime == null || now - lastCallTime >= throttleMs) {
|
|
79
|
-
lastCallTime = now;
|
|
80
|
-
func(...args);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
return throttledFunction;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function negate(func) {
|
|
87
|
-
return ((...args) => !func(...args));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function memoize(fn, options = {}) {
|
|
91
|
-
const { cache = new Map(), getCacheKey } = options;
|
|
92
|
-
const memoizedFn = function (arg) {
|
|
93
|
-
const key = getCacheKey ? getCacheKey(arg) : arg;
|
|
94
|
-
if (cache.has(key)) {
|
|
95
|
-
return cache.get(key);
|
|
96
|
-
}
|
|
97
|
-
const result = fn.call(this, arg);
|
|
98
|
-
cache.set(key, result);
|
|
99
|
-
return result;
|
|
100
|
-
};
|
|
101
|
-
memoizedFn.cache = cache;
|
|
102
|
-
return memoizedFn;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function ary(func, n) {
|
|
106
|
-
return function (...args) {
|
|
107
|
-
return func.apply(this, args.slice(0, n));
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function unary(func) {
|
|
112
|
-
return ary(func, 1);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function partial(func, ...partialArgs) {
|
|
116
|
-
return function (...providedArgs) {
|
|
117
|
-
const args = [];
|
|
118
|
-
let startIndex = 0;
|
|
119
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
120
|
-
const arg = partialArgs[i];
|
|
121
|
-
if (arg === partial.placeholder) {
|
|
122
|
-
args.push(providedArgs[startIndex++]);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
args.push(arg);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
129
|
-
args.push(providedArgs[i]);
|
|
130
|
-
}
|
|
131
|
-
return func.apply(this, args);
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const partialPlaceholder = Symbol('partial.placeholder');
|
|
135
|
-
partial.placeholder = partialPlaceholder;
|
|
136
|
-
|
|
137
|
-
function partialRight(func, ...partialArgs) {
|
|
138
|
-
return function (...providedArgs) {
|
|
139
|
-
const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
|
|
140
|
-
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
141
|
-
const args = [];
|
|
142
|
-
let providedIndex = 0;
|
|
143
|
-
for (let i = 0; i < rangeLength; i++) {
|
|
144
|
-
args.push(providedArgs[providedIndex++]);
|
|
145
|
-
}
|
|
146
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
147
|
-
const arg = partialArgs[i];
|
|
148
|
-
if (arg === partialRight.placeholder) {
|
|
149
|
-
args.push(providedArgs[providedIndex++]);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
args.push(arg);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return func.apply(this, args);
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
const partialRightPlaceholder = Symbol('partialRight.placeholder');
|
|
159
|
-
partialRight.placeholder = partialRightPlaceholder;
|
|
160
|
-
|
|
161
|
-
function rest(func, startIndex = func.length - 1) {
|
|
162
|
-
return function (...args) {
|
|
163
|
-
const rest = args.slice(startIndex);
|
|
164
|
-
const params = args.slice(0, startIndex);
|
|
165
|
-
while (params.length < startIndex) {
|
|
166
|
-
params.push(undefined);
|
|
167
|
-
}
|
|
168
|
-
return func.apply(this, [...params, rest]);
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function spread(func, startIndex = 0) {
|
|
173
|
-
return function (...args) {
|
|
174
|
-
const array = args[startIndex];
|
|
175
|
-
const params = args.slice(0, startIndex);
|
|
176
|
-
if (array) {
|
|
177
|
-
params.push(...array);
|
|
178
|
-
}
|
|
179
|
-
return func.apply(this, params);
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
exports.after = after;
|
|
184
|
-
exports.ary = ary;
|
|
185
|
-
exports.before = before;
|
|
186
|
-
exports.debounce = debounce;
|
|
187
|
-
exports.memoize = memoize;
|
|
188
|
-
exports.negate = negate;
|
|
189
|
-
exports.noop = noop;
|
|
190
|
-
exports.once = once;
|
|
191
|
-
exports.partial = partial;
|
|
192
|
-
exports.partialRight = partialRight;
|
|
193
|
-
exports.rest = rest;
|
|
5
|
+
const rest = require('../_chunk/rest-Bzm2XK.js');
|
|
6
|
+
|
|
7
|
+
function spread(func) {
|
|
8
|
+
return function (argsArr) {
|
|
9
|
+
return func.apply(this, argsArr);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.after = rest.after;
|
|
14
|
+
exports.ary = rest.ary;
|
|
15
|
+
exports.before = rest.before;
|
|
16
|
+
exports.debounce = rest.debounce;
|
|
17
|
+
exports.memoize = rest.memoize;
|
|
18
|
+
exports.negate = rest.negate;
|
|
19
|
+
exports.noop = rest.noop;
|
|
20
|
+
exports.once = rest.once;
|
|
21
|
+
exports.partial = rest.partial;
|
|
22
|
+
exports.partialRight = rest.partialRight;
|
|
23
|
+
exports.rest = rest.rest;
|
|
24
|
+
exports.throttle = rest.throttle;
|
|
25
|
+
exports.unary = rest.unary;
|
|
194
26
|
exports.spread = spread;
|
|
195
|
-
exports.throttle = throttle;
|
|
196
|
-
exports.unary = unary;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
2
|
+
Creates a new function that spreads elements of an array argument into individual arguments
|
|
3
|
+
* for the original function.
|
|
3
4
|
*
|
|
4
|
-
* @template F
|
|
5
|
-
* @param {F} func The function to
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
5
|
+
* @template F - A function type with any number of parameters and any return type.
|
|
6
|
+
* @param {F} func - The function to be transformed. It can be any function with any number of arguments.
|
|
7
|
+
* @returns {(argsArr: Parameters<F>) => ReturnType<F>} - A new function that takes an array of arguments and returns the result of calling the original function with those arguments.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* function add(a, b) {
|
|
11
|
+
* return a + b;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const spreadAdd = spread(add);
|
|
15
|
+
* console.log(spreadAdd([1, 2])); // Output: 3
|
|
8
16
|
*/
|
|
9
|
-
declare function spread<F extends (...args: any[]) => any>(func: F
|
|
17
|
+
declare function spread<F extends (...args: any[]) => any>(func: F): (argsArr: Parameters<F>) => ReturnType<F>;
|
|
10
18
|
|
|
11
19
|
export { spread };
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
2
|
+
Creates a new function that spreads elements of an array argument into individual arguments
|
|
3
|
+
* for the original function.
|
|
3
4
|
*
|
|
4
|
-
* @template F
|
|
5
|
-
* @param {F} func The function to
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
5
|
+
* @template F - A function type with any number of parameters and any return type.
|
|
6
|
+
* @param {F} func - The function to be transformed. It can be any function with any number of arguments.
|
|
7
|
+
* @returns {(argsArr: Parameters<F>) => ReturnType<F>} - A new function that takes an array of arguments and returns the result of calling the original function with those arguments.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* function add(a, b) {
|
|
11
|
+
* return a + b;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const spreadAdd = spread(add);
|
|
15
|
+
* console.log(spreadAdd([1, 2])); // Output: 3
|
|
8
16
|
*/
|
|
9
|
-
declare function spread<F extends (...args: any[]) => any>(func: F
|
|
17
|
+
declare function spread<F extends (...args: any[]) => any>(func: F): (argsArr: Parameters<F>) => ReturnType<F>;
|
|
10
18
|
|
|
11
19
|
export { spread };
|
package/dist/function/spread.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
function spread(func
|
|
2
|
-
return function (
|
|
3
|
-
|
|
4
|
-
const params = args.slice(0, startIndex);
|
|
5
|
-
if (array) {
|
|
6
|
-
params.push(...array);
|
|
7
|
-
}
|
|
8
|
-
return func.apply(this, params);
|
|
1
|
+
function spread(func) {
|
|
2
|
+
return function (argsArr) {
|
|
3
|
+
return func.apply(this, argsArr);
|
|
9
4
|
};
|
|
10
5
|
}
|
|
11
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ export { groupBy } from './array/groupBy.mjs';
|
|
|
18
18
|
export { intersection } from './array/intersection.mjs';
|
|
19
19
|
export { intersectionBy } from './array/intersectionBy.mjs';
|
|
20
20
|
export { intersectionWith } from './array/intersectionWith.mjs';
|
|
21
|
+
export { join } from './array/join.mjs';
|
|
21
22
|
export { keyBy } from './array/keyBy.mjs';
|
|
22
23
|
export { maxBy } from './array/maxBy.mjs';
|
|
23
24
|
export { minBy } from './array/minBy.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { groupBy } from './array/groupBy.js';
|
|
|
18
18
|
export { intersection } from './array/intersection.js';
|
|
19
19
|
export { intersectionBy } from './array/intersectionBy.js';
|
|
20
20
|
export { intersectionWith } from './array/intersectionWith.js';
|
|
21
|
+
export { join } from './array/join.js';
|
|
21
22
|
export { keyBy } from './array/keyBy.js';
|
|
22
23
|
export { maxBy } from './array/maxBy.js';
|
|
23
24
|
export { minBy } from './array/minBy.js';
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const initial = require('./_chunk/initial-
|
|
5
|
+
const initial = require('./_chunk/initial-L_KfII.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
7
|
const promise_index = require('./_chunk/index-BGZDR9.js');
|
|
8
|
+
const rest = require('./_chunk/rest-Bzm2XK.js');
|
|
8
9
|
const function_index = require('./function/index.js');
|
|
9
10
|
const math_index = require('./math/index.js');
|
|
10
11
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
@@ -39,6 +40,7 @@ exports.intersection = initial.intersection;
|
|
|
39
40
|
exports.intersectionBy = initial.intersectionBy;
|
|
40
41
|
exports.intersectionWith = initial.intersectionWith;
|
|
41
42
|
exports.isSubset = initial.isSubset;
|
|
43
|
+
exports.join = initial.join;
|
|
42
44
|
exports.keyBy = initial.keyBy;
|
|
43
45
|
exports.last = initial.last;
|
|
44
46
|
exports.maxBy = initial.maxBy;
|
|
@@ -77,20 +79,20 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
77
79
|
exports.delay = promise_index.delay;
|
|
78
80
|
exports.timeout = promise_index.timeout;
|
|
79
81
|
exports.withTimeout = promise_index.withTimeout;
|
|
80
|
-
exports.after =
|
|
81
|
-
exports.ary =
|
|
82
|
-
exports.before =
|
|
83
|
-
exports.debounce =
|
|
84
|
-
exports.memoize =
|
|
85
|
-
exports.negate =
|
|
86
|
-
exports.noop =
|
|
87
|
-
exports.once =
|
|
88
|
-
exports.partial =
|
|
89
|
-
exports.partialRight =
|
|
90
|
-
exports.rest =
|
|
82
|
+
exports.after = rest.after;
|
|
83
|
+
exports.ary = rest.ary;
|
|
84
|
+
exports.before = rest.before;
|
|
85
|
+
exports.debounce = rest.debounce;
|
|
86
|
+
exports.memoize = rest.memoize;
|
|
87
|
+
exports.negate = rest.negate;
|
|
88
|
+
exports.noop = rest.noop;
|
|
89
|
+
exports.once = rest.once;
|
|
90
|
+
exports.partial = rest.partial;
|
|
91
|
+
exports.partialRight = rest.partialRight;
|
|
92
|
+
exports.rest = rest.rest;
|
|
93
|
+
exports.throttle = rest.throttle;
|
|
94
|
+
exports.unary = rest.unary;
|
|
91
95
|
exports.spread = function_index.spread;
|
|
92
|
-
exports.throttle = function_index.throttle;
|
|
93
|
-
exports.unary = function_index.unary;
|
|
94
96
|
exports.clamp = math_index.clamp;
|
|
95
97
|
exports.inRange = math_index.inRange;
|
|
96
98
|
exports.mean = math_index.mean;
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ export { groupBy } from './array/groupBy.mjs';
|
|
|
18
18
|
export { intersection } from './array/intersection.mjs';
|
|
19
19
|
export { intersectionBy } from './array/intersectionBy.mjs';
|
|
20
20
|
export { intersectionWith } from './array/intersectionWith.mjs';
|
|
21
|
+
export { join } from './array/join.mjs';
|
|
21
22
|
export { keyBy } from './array/keyBy.mjs';
|
|
22
23
|
export { maxBy } from './array/maxBy.mjs';
|
|
23
24
|
export { minBy } from './array/minBy.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.17.0-dev.
|
|
4
|
+
"version": "1.17.0-dev.511+3a6cb365",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|