es-toolkit 1.50.0-dev.2058 → 1.50.0-dev.2060
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/browser.global.js +3 -3
- package/dist/compat/array/drop.d.mts +1 -1
- package/dist/compat/array/drop.d.ts +1 -1
- package/dist/compat/array/pull.js +1 -1
- package/dist/compat/array/pull.mjs +1 -1
- package/dist/compat/array/remove.js +8 -4
- package/dist/compat/array/remove.mjs +8 -4
- package/dist/compat/array/unzipWith.js +1 -1
- package/dist/compat/array/unzipWith.mjs +1 -1
- package/dist/compat/function/curry.d.mts +1 -1
- package/dist/compat/function/curry.d.ts +1 -1
- package/dist/compat/function/flowRight.d.mts +1 -1
- package/dist/compat/function/flowRight.d.ts +1 -1
- package/dist/compat/function/partial.d.mts +1 -1
- package/dist/compat/function/partial.d.ts +1 -1
- package/dist/compat/function/rest.d.mts +1 -1
- package/dist/compat/function/rest.d.ts +1 -1
- package/dist/compat/function/rest.js +1 -1
- package/dist/compat/function/rest.mjs +1 -1
- package/dist/compat/object/cloneDeep.d.mts +5 -5
- package/dist/compat/object/cloneDeep.d.ts +5 -5
- package/dist/compat/object/cloneDeep.js +5 -5
- package/dist/compat/object/cloneDeep.mjs +5 -5
- package/dist/compat/object/cloneDeepWith.js +3 -1
- package/dist/compat/object/cloneDeepWith.mjs +3 -1
- package/dist/compat/object/cloneWith.d.mts +1 -1
- package/dist/compat/object/cloneWith.d.ts +1 -1
- package/dist/compat/object/cloneWith.js +1 -1
- package/dist/compat/object/cloneWith.mjs +1 -1
- package/dist/compat/object/transform.js +1 -1
- package/dist/compat/object/transform.mjs +1 -1
- package/dist/compat/string/words.js +17 -13
- package/dist/compat/string/words.mjs +17 -13
- package/dist/compat/util/toArray.d.mts +5 -5
- package/dist/compat/util/toArray.d.ts +5 -5
- package/dist/compat/util/toArray.js +4 -4
- package/dist/compat/util/toArray.mjs +4 -4
- package/dist/function/memoize.d.mts +3 -2
- package/dist/function/memoize.d.ts +3 -2
- package/dist/function/memoize.js +3 -2
- package/dist/function/memoize.mjs +3 -2
- package/dist/function/partial.d.mts +2 -2
- package/dist/function/partial.d.ts +2 -2
- package/dist/function/partialRight.d.mts +5 -5
- package/dist/function/partialRight.d.ts +5 -5
- package/dist/function/rest.d.mts +1 -1
- package/dist/function/rest.d.ts +1 -1
- package/dist/function/rest.js +1 -1
- package/dist/function/rest.mjs +1 -1
- package/dist/function/retry.d.mts +7 -4
- package/dist/function/retry.d.ts +7 -4
- package/dist/function/retry.js +1 -1
- package/dist/function/retry.mjs +1 -1
- package/dist/object/cloneDeepWith.d.mts +3 -1
- package/dist/object/cloneDeepWith.d.ts +3 -1
- package/dist/object/cloneDeepWith.js +3 -1
- package/dist/object/cloneDeepWith.mjs +3 -1
- package/package.json +5 -2
package/dist/function/rest.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* // Using start index 1
|
|
26
26
|
* const transformedFnWithStart = rest(fn, 1);
|
|
27
|
-
* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
|
|
27
|
+
* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
|
|
28
28
|
*
|
|
29
29
|
* // With fewer arguments than the start index
|
|
30
30
|
* console.log(transformedFn(1)); // [1, undefined, []]
|
package/dist/function/rest.mjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* // Using start index 1
|
|
26
26
|
* const transformedFnWithStart = rest(fn, 1);
|
|
27
|
-
* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]
|
|
27
|
+
* console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4], undefined]
|
|
28
28
|
*
|
|
29
29
|
* // With fewer arguments than the start index
|
|
30
30
|
* console.log(transformedFn(1)); // [1, undefined, []]
|
|
@@ -6,9 +6,9 @@ interface RetryOptions {
|
|
|
6
6
|
*
|
|
7
7
|
* @default 0
|
|
8
8
|
* @example
|
|
9
|
-
* delay: (attempts) =>
|
|
9
|
+
* delay: (attempts, error) => error.status === 429 ? 10000 : attempts * 50
|
|
10
10
|
*/
|
|
11
|
-
delay?: number | ((attempts: number) => number);
|
|
11
|
+
delay?: number | ((attempts: number, error: unknown) => number);
|
|
12
12
|
/**
|
|
13
13
|
* The number of retries to attempt.
|
|
14
14
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -62,7 +62,7 @@ declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
|
62
62
|
* @template T
|
|
63
63
|
* @param func - The function to retry. It should return a promise.
|
|
64
64
|
* @param options - Options to configure the retry behavior.
|
|
65
|
-
* @param [options.delay=0] - Delay(milliseconds) between retries.
|
|
65
|
+
* @param [options.delay=0] - Delay(milliseconds) between retries. A number or a function that receives the attempt number and the error object.
|
|
66
66
|
* @param [options.retries=Infinity] - The number of retries to attempt.
|
|
67
67
|
* @param [options.signal] - An AbortSignal to cancel the retry operation.
|
|
68
68
|
* @param [options.shouldRetry] - A function that determines whether to retry.
|
|
@@ -77,7 +77,10 @@ declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
|
77
77
|
* retry(() => fetchData(), { delay: 1000, retries: 5 });
|
|
78
78
|
*
|
|
79
79
|
* // Retry a function with a delay increasing linearly by 50ms per attempt
|
|
80
|
-
* retry(() => fetchData(), { delay: (attempts) =>
|
|
80
|
+
* retry(() => fetchData(), { delay: (attempts) => attempts * 50, retries: 5 });
|
|
81
|
+
*
|
|
82
|
+
* // Retry a function with an error-aware delay (e.g., respect Retry-After headers)
|
|
83
|
+
* retry(() => fetchData(), { delay: (_attempts, error) => error.status === 429 ? 10000 : 1000, retries: 3 });
|
|
81
84
|
*
|
|
82
85
|
* @example
|
|
83
86
|
* // Retry a function with exponential backoff + jitter (max delay 10 seconds)
|
package/dist/function/retry.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ interface RetryOptions {
|
|
|
6
6
|
*
|
|
7
7
|
* @default 0
|
|
8
8
|
* @example
|
|
9
|
-
* delay: (attempts) =>
|
|
9
|
+
* delay: (attempts, error) => error.status === 429 ? 10000 : attempts * 50
|
|
10
10
|
*/
|
|
11
|
-
delay?: number | ((attempts: number) => number);
|
|
11
|
+
delay?: number | ((attempts: number, error: unknown) => number);
|
|
12
12
|
/**
|
|
13
13
|
* The number of retries to attempt.
|
|
14
14
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -62,7 +62,7 @@ declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
|
62
62
|
* @template T
|
|
63
63
|
* @param func - The function to retry. It should return a promise.
|
|
64
64
|
* @param options - Options to configure the retry behavior.
|
|
65
|
-
* @param [options.delay=0] - Delay(milliseconds) between retries.
|
|
65
|
+
* @param [options.delay=0] - Delay(milliseconds) between retries. A number or a function that receives the attempt number and the error object.
|
|
66
66
|
* @param [options.retries=Infinity] - The number of retries to attempt.
|
|
67
67
|
* @param [options.signal] - An AbortSignal to cancel the retry operation.
|
|
68
68
|
* @param [options.shouldRetry] - A function that determines whether to retry.
|
|
@@ -77,7 +77,10 @@ declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
|
77
77
|
* retry(() => fetchData(), { delay: 1000, retries: 5 });
|
|
78
78
|
*
|
|
79
79
|
* // Retry a function with a delay increasing linearly by 50ms per attempt
|
|
80
|
-
* retry(() => fetchData(), { delay: (attempts) =>
|
|
80
|
+
* retry(() => fetchData(), { delay: (attempts) => attempts * 50, retries: 5 });
|
|
81
|
+
*
|
|
82
|
+
* // Retry a function with an error-aware delay (e.g., respect Retry-After headers)
|
|
83
|
+
* retry(() => fetchData(), { delay: (_attempts, error) => error.status === 429 ? 10000 : 1000, retries: 3 });
|
|
81
84
|
*
|
|
82
85
|
* @example
|
|
83
86
|
* // Retry a function with exponential backoff + jitter (max delay 10 seconds)
|
package/dist/function/retry.js
CHANGED
|
@@ -36,7 +36,7 @@ async function retry(func, _options) {
|
|
|
36
36
|
error = err;
|
|
37
37
|
if (!shouldRetry(err, attempts)) throw err;
|
|
38
38
|
if (attempts < retries) {
|
|
39
|
-
const currentDelay = typeof delay$1 === "function" ? delay$1(attempts) : delay$1;
|
|
39
|
+
const currentDelay = typeof delay$1 === "function" ? delay$1(attempts, error) : delay$1;
|
|
40
40
|
await require_delay.delay(currentDelay);
|
|
41
41
|
}
|
|
42
42
|
}
|
package/dist/function/retry.mjs
CHANGED
|
@@ -35,7 +35,7 @@ async function retry(func, _options) {
|
|
|
35
35
|
} catch (err) {
|
|
36
36
|
error = err;
|
|
37
37
|
if (!shouldRetry(err, attempts)) throw err;
|
|
38
|
-
if (attempts < retries) await delay(typeof delay$1 === "function" ? delay$1(attempts) : delay$1);
|
|
38
|
+
if (attempts < retries) await delay(typeof delay$1 === "function" ? delay$1(attempts, error) : delay$1);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
throw error;
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
* // Clone an array with a customizer
|
|
35
35
|
* const arr = [1, 2, 3];
|
|
36
36
|
* const clonedArr = cloneDeepWith(arr, (value) => {
|
|
37
|
-
*
|
|
37
|
+
* if (typeof value === 'number') {
|
|
38
|
+
* return value + 1; // Increment each number
|
|
39
|
+
* }
|
|
38
40
|
* });
|
|
39
41
|
* console.log(clonedArr); // [2, 3, 4]
|
|
40
42
|
* console.log(clonedArr === arr); // false
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
* // Clone an array with a customizer
|
|
35
35
|
* const arr = [1, 2, 3];
|
|
36
36
|
* const clonedArr = cloneDeepWith(arr, (value) => {
|
|
37
|
-
*
|
|
37
|
+
* if (typeof value === 'number') {
|
|
38
|
+
* return value + 1; // Increment each number
|
|
39
|
+
* }
|
|
38
40
|
* });
|
|
39
41
|
* console.log(clonedArr); // [2, 3, 4]
|
|
40
42
|
* console.log(clonedArr === arr); // false
|
|
@@ -40,7 +40,9 @@ const require_isBuffer = require("../predicate/isBuffer.js");
|
|
|
40
40
|
* // Clone an array with a customizer
|
|
41
41
|
* const arr = [1, 2, 3];
|
|
42
42
|
* const clonedArr = cloneDeepWith(arr, (value) => {
|
|
43
|
-
*
|
|
43
|
+
* if (typeof value === 'number') {
|
|
44
|
+
* return value + 1; // Increment each number
|
|
45
|
+
* }
|
|
44
46
|
* });
|
|
45
47
|
* console.log(clonedArr); // [2, 3, 4]
|
|
46
48
|
* console.log(clonedArr === arr); // false
|
|
@@ -40,7 +40,9 @@ import { isBuffer } from "../predicate/isBuffer.mjs";
|
|
|
40
40
|
* // Clone an array with a customizer
|
|
41
41
|
* const arr = [1, 2, 3];
|
|
42
42
|
* const clonedArr = cloneDeepWith(arr, (value) => {
|
|
43
|
-
*
|
|
43
|
+
* if (typeof value === 'number') {
|
|
44
|
+
* return value + 1; // Increment each number
|
|
45
|
+
* }
|
|
44
46
|
* });
|
|
45
47
|
* console.log(clonedArr); // [2, 3, 4]
|
|
46
48
|
* console.log(clonedArr === arr); // false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.50.0-dev.
|
|
3
|
+
"version": "1.50.0-dev.2060+2a37b36c",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
@@ -218,7 +218,8 @@
|
|
|
218
218
|
"workspaces": [
|
|
219
219
|
"docs",
|
|
220
220
|
"benchmarks",
|
|
221
|
-
"tests/types"
|
|
221
|
+
"tests/types",
|
|
222
|
+
"tests/browser-compat"
|
|
222
223
|
],
|
|
223
224
|
"scripts": {
|
|
224
225
|
"bench": "yarn workspace benchmarks bench",
|
|
@@ -250,6 +251,8 @@
|
|
|
250
251
|
"broken-link-checker": "0.7.8",
|
|
251
252
|
"eslint": "^9.39.2",
|
|
252
253
|
"eslint-config-prettier": "^9.1.0",
|
|
254
|
+
"eslint-plugin-compat": "^7.0.2",
|
|
255
|
+
"eslint-plugin-es-x": "^10.0.0",
|
|
253
256
|
"eslint-plugin-no-for-of-array": "^0.0.1",
|
|
254
257
|
"eslint-plugin-prettier": "^5.2.1",
|
|
255
258
|
"eslint-plugin-vue": "^9.28.0",
|