es-toolkit 1.31.0-dev.991 → 1.31.0-dev.992
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/compat/index.js +6 -5
- package/dist/error/index.d.mts +2 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +20 -0
- package/dist/error/index.mjs +2 -0
- package/dist/index.js +7 -6
- package/dist/promise/index.js +31 -4
- package/error.d.ts +1 -0
- package/package.json +41 -21
- package/dist/_chunk/index-BGZDR9.js +0 -50
package/dist/compat/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const zipWith = require('../_chunk/zipWith-Bdyzuy.js');
|
|
6
|
-
const
|
|
6
|
+
const error_index = require('../error/index.js');
|
|
7
7
|
const unary = require('../_chunk/unary-B6qG7C.js');
|
|
8
8
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
9
9
|
const range$1 = require('../_chunk/range-HnEIT7.js');
|
|
@@ -11,6 +11,7 @@ const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
|
11
11
|
const toMerged = require('../_chunk/toMerged-DGFrN7.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
|
|
13
13
|
const isWeakSet$1 = require('../_chunk/isWeakSet-CvIdTA.js');
|
|
14
|
+
const promise_index = require('../promise/index.js');
|
|
14
15
|
const upperFirst$1 = require('../_chunk/upperFirst-CorAVn.js');
|
|
15
16
|
const util_index = require('../util/index.js');
|
|
16
17
|
|
|
@@ -3084,10 +3085,8 @@ exports.xorBy = zipWith.xorBy;
|
|
|
3084
3085
|
exports.xorWith = zipWith.xorWith;
|
|
3085
3086
|
exports.zipObject = zipWith.zipObject;
|
|
3086
3087
|
exports.zipWith = zipWith.zipWith;
|
|
3087
|
-
exports.AbortError =
|
|
3088
|
-
exports.TimeoutError =
|
|
3089
|
-
exports.timeout = promise_index.timeout;
|
|
3090
|
-
exports.withTimeout = promise_index.withTimeout;
|
|
3088
|
+
exports.AbortError = error_index.AbortError;
|
|
3089
|
+
exports.TimeoutError = error_index.TimeoutError;
|
|
3091
3090
|
exports.asyncNoop = unary.asyncNoop;
|
|
3092
3091
|
exports.identity = unary.identity;
|
|
3093
3092
|
exports.memoize = unary.memoize;
|
|
@@ -3121,6 +3120,8 @@ exports.isLength = isWeakSet$1.isLength;
|
|
|
3121
3120
|
exports.isNotNil = isWeakSet$1.isNotNil;
|
|
3122
3121
|
exports.isNull = isWeakSet$1.isNull;
|
|
3123
3122
|
exports.isUndefined = isWeakSet$1.isUndefined;
|
|
3123
|
+
exports.timeout = promise_index.timeout;
|
|
3124
|
+
exports.withTimeout = promise_index.withTimeout;
|
|
3124
3125
|
exports.capitalize = upperFirst$1.capitalize;
|
|
3125
3126
|
exports.constantCase = upperFirst$1.constantCase;
|
|
3126
3127
|
exports.pascalCase = upperFirst$1.pascalCase;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
class AbortError extends Error {
|
|
6
|
+
constructor(message = 'The operation was aborted') {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'AbortError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class TimeoutError extends Error {
|
|
13
|
+
constructor(message = 'The operation was timed out') {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'TimeoutError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.AbortError = AbortError;
|
|
20
|
+
exports.TimeoutError = TimeoutError;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const zipWith = require('./_chunk/zipWith-Bdyzuy.js');
|
|
6
6
|
const array_index = require('./array/index.js');
|
|
7
|
-
const
|
|
7
|
+
const error_index = require('./error/index.js');
|
|
8
8
|
const unary = require('./_chunk/unary-B6qG7C.js');
|
|
9
9
|
const function_index = require('./function/index.js');
|
|
10
10
|
const noop = require('./_chunk/noop-2IwLUk.js');
|
|
@@ -16,6 +16,7 @@ const object_index = require('./object/index.js');
|
|
|
16
16
|
const isWeakSet = require('./_chunk/isWeakSet-CvIdTA.js');
|
|
17
17
|
const predicate_index = require('./predicate/index.js');
|
|
18
18
|
const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
|
|
19
|
+
const promise_index = require('./promise/index.js');
|
|
19
20
|
const upperFirst = require('./_chunk/upperFirst-CorAVn.js');
|
|
20
21
|
const string_index = require('./string/index.js');
|
|
21
22
|
const util_index = require('./util/index.js');
|
|
@@ -82,11 +83,8 @@ exports.zipWith = zipWith.zipWith;
|
|
|
82
83
|
exports.orderBy = array_index.orderBy;
|
|
83
84
|
exports.sortBy = array_index.sortBy;
|
|
84
85
|
exports.takeRightWhile = array_index.takeRightWhile;
|
|
85
|
-
exports.AbortError =
|
|
86
|
-
exports.TimeoutError =
|
|
87
|
-
exports.delay = promise_index.delay;
|
|
88
|
-
exports.timeout = promise_index.timeout;
|
|
89
|
-
exports.withTimeout = promise_index.withTimeout;
|
|
86
|
+
exports.AbortError = error_index.AbortError;
|
|
87
|
+
exports.TimeoutError = error_index.TimeoutError;
|
|
90
88
|
exports.after = unary.after;
|
|
91
89
|
exports.ary = unary.ary;
|
|
92
90
|
exports.asyncNoop = unary.asyncNoop;
|
|
@@ -163,6 +161,9 @@ exports.isSymbol = predicate_index.isSymbol;
|
|
|
163
161
|
exports.isPlainObject = isPlainObject.isPlainObject;
|
|
164
162
|
exports.isPrimitive = isPlainObject.isPrimitive;
|
|
165
163
|
exports.isTypedArray = isPlainObject.isTypedArray;
|
|
164
|
+
exports.delay = promise_index.delay;
|
|
165
|
+
exports.timeout = promise_index.timeout;
|
|
166
|
+
exports.withTimeout = promise_index.withTimeout;
|
|
166
167
|
exports.camelCase = upperFirst.camelCase;
|
|
167
168
|
exports.capitalize = upperFirst.capitalize;
|
|
168
169
|
exports.constantCase = upperFirst.constantCase;
|
package/dist/promise/index.js
CHANGED
|
@@ -2,10 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const error_index = require('../error/index.js');
|
|
6
6
|
|
|
7
|
+
function delay(ms, { signal } = {}) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const abortError = () => {
|
|
10
|
+
reject(new error_index.AbortError());
|
|
11
|
+
};
|
|
12
|
+
const abortHandler = () => {
|
|
13
|
+
clearTimeout(timeoutId);
|
|
14
|
+
abortError();
|
|
15
|
+
};
|
|
16
|
+
if (signal?.aborted) {
|
|
17
|
+
return abortError();
|
|
18
|
+
}
|
|
19
|
+
const timeoutId = setTimeout(() => {
|
|
20
|
+
signal?.removeEventListener('abort', abortHandler);
|
|
21
|
+
resolve();
|
|
22
|
+
}, ms);
|
|
23
|
+
signal?.addEventListener('abort', abortHandler, { once: true });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
7
26
|
|
|
27
|
+
async function timeout(ms) {
|
|
28
|
+
await delay(ms);
|
|
29
|
+
throw new error_index.TimeoutError();
|
|
30
|
+
}
|
|
8
31
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
async function withTimeout(run, ms) {
|
|
33
|
+
return Promise.race([run(), timeout(ms)]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.delay = delay;
|
|
37
|
+
exports.timeout = timeout;
|
|
38
|
+
exports.withTimeout = withTimeout;
|
package/error.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/error';
|
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.31.0-dev.
|
|
4
|
+
"version": "1.31.0-dev.992+030e4ead",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -35,6 +35,26 @@
|
|
|
35
35
|
"default": "./dist/array/index.js"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
+
"./compat": {
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/compat/index.d.mts",
|
|
41
|
+
"default": "./dist/compat/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./dist/compat/index.d.ts",
|
|
45
|
+
"default": "./dist/compat/index.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"./error": {
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/error/index.d.mts",
|
|
51
|
+
"default": "./dist/error/index.mjs"
|
|
52
|
+
},
|
|
53
|
+
"require": {
|
|
54
|
+
"types": "./dist/error/index.d.ts",
|
|
55
|
+
"default": "./dist/error/index.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
38
58
|
"./function": {
|
|
39
59
|
"import": {
|
|
40
60
|
"types": "./dist/function/index.d.mts",
|
|
@@ -105,16 +125,6 @@
|
|
|
105
125
|
"default": "./dist/util/index.js"
|
|
106
126
|
}
|
|
107
127
|
},
|
|
108
|
-
"./compat": {
|
|
109
|
-
"import": {
|
|
110
|
-
"types": "./dist/compat/index.d.mts",
|
|
111
|
-
"default": "./dist/compat/index.mjs"
|
|
112
|
-
},
|
|
113
|
-
"require": {
|
|
114
|
-
"types": "./dist/compat/index.d.ts",
|
|
115
|
-
"default": "./dist/compat/index.js"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
128
|
"./package.json": "./package.json"
|
|
119
129
|
},
|
|
120
130
|
"files": [
|
|
@@ -148,6 +158,26 @@
|
|
|
148
158
|
"default": "./dist/array/index.js"
|
|
149
159
|
}
|
|
150
160
|
},
|
|
161
|
+
"./compat": {
|
|
162
|
+
"import": {
|
|
163
|
+
"types": "./dist/compat/index.d.mts",
|
|
164
|
+
"default": "./dist/compat/index.mjs"
|
|
165
|
+
},
|
|
166
|
+
"require": {
|
|
167
|
+
"types": "./dist/compat/index.d.ts",
|
|
168
|
+
"default": "./dist/compat/index.js"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"./error": {
|
|
172
|
+
"import": {
|
|
173
|
+
"types": "./dist/error/index.d.mts",
|
|
174
|
+
"default": "./dist/error/index.mjs"
|
|
175
|
+
},
|
|
176
|
+
"require": {
|
|
177
|
+
"types": "./dist/error/index.d.ts",
|
|
178
|
+
"default": "./dist/error/index.js"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
151
181
|
"./function": {
|
|
152
182
|
"import": {
|
|
153
183
|
"types": "./dist/function/index.d.mts",
|
|
@@ -218,16 +248,6 @@
|
|
|
218
248
|
"default": "./dist/util/index.js"
|
|
219
249
|
}
|
|
220
250
|
},
|
|
221
|
-
"./compat": {
|
|
222
|
-
"import": {
|
|
223
|
-
"types": "./dist/compat/index.d.mts",
|
|
224
|
-
"default": "./dist/compat/index.mjs"
|
|
225
|
-
},
|
|
226
|
-
"require": {
|
|
227
|
-
"types": "./dist/compat/index.d.ts",
|
|
228
|
-
"default": "./dist/compat/index.js"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
251
|
"./package.json": "./package.json"
|
|
232
252
|
}
|
|
233
253
|
},
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class AbortError extends Error {
|
|
4
|
-
constructor(message = 'The operation was aborted') {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = 'AbortError';
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
class TimeoutError extends Error {
|
|
11
|
-
constructor(message = 'The operation was timed out') {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = 'TimeoutError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function delay(ms, { signal } = {}) {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const abortError = () => {
|
|
20
|
-
reject(new AbortError());
|
|
21
|
-
};
|
|
22
|
-
const abortHandler = () => {
|
|
23
|
-
clearTimeout(timeoutId);
|
|
24
|
-
abortError();
|
|
25
|
-
};
|
|
26
|
-
if (signal?.aborted) {
|
|
27
|
-
return abortError();
|
|
28
|
-
}
|
|
29
|
-
const timeoutId = setTimeout(() => {
|
|
30
|
-
signal?.removeEventListener('abort', abortHandler);
|
|
31
|
-
resolve();
|
|
32
|
-
}, ms);
|
|
33
|
-
signal?.addEventListener('abort', abortHandler, { once: true });
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function timeout(ms) {
|
|
38
|
-
await delay(ms);
|
|
39
|
-
throw new TimeoutError();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function withTimeout(run, ms) {
|
|
43
|
-
return Promise.race([run(), timeout(ms)]);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.AbortError = AbortError;
|
|
47
|
-
exports.TimeoutError = TimeoutError;
|
|
48
|
-
exports.delay = delay;
|
|
49
|
-
exports.timeout = timeout;
|
|
50
|
-
exports.withTimeout = withTimeout;
|