es-toolkit 1.31.0 → 1.32.0-dev.1005
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/CHANGELOG.md +10 -0
- package/dist/_chunk/AbortError-Cg4ZQ1.js +10 -0
- package/dist/_chunk/delay-_VMfFa.js +25 -0
- package/dist/_chunk/isPlainObject-Xaozpc.js +93 -0
- package/dist/_chunk/{isWeakSet-CvIdTA.js → isWeakSet-DoHqUM.js} +42 -71
- package/dist/_chunk/{toMerged-DGFrN7.js → toMerged-BQTfB8.js} +39 -8
- package/dist/_chunk/{unary-B6qG7C.js → unary-c1NFA5.js} +35 -0
- package/dist/array/at.d.mts +1 -1
- package/dist/array/at.d.ts +1 -1
- package/dist/array/pullAt.d.mts +1 -1
- package/dist/array/pullAt.d.ts +1 -1
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/find.d.mts +16 -8
- package/dist/compat/array/find.d.ts +16 -8
- package/dist/compat/array/find.mjs +5 -2
- package/dist/compat/array/pullAllBy.d.mts +64 -0
- package/dist/compat/array/pullAllBy.d.ts +64 -0
- package/dist/compat/array/pullAllBy.mjs +22 -0
- package/dist/compat/array/sortedIndex.d.mts +16 -0
- package/dist/compat/array/sortedIndex.d.ts +16 -0
- package/dist/compat/array/sortedIndex.mjs +30 -0
- package/dist/compat/array/sortedIndexBy.d.mts +19 -0
- package/dist/compat/array/sortedIndexBy.d.ts +19 -0
- package/dist/compat/array/sortedIndexBy.mjs +56 -0
- package/dist/compat/index.d.mts +8 -0
- package/dist/compat/index.d.ts +8 -0
- package/dist/compat/index.js +165 -43
- package/dist/compat/index.mjs +8 -0
- package/dist/compat/math/multiply.d.mts +18 -0
- package/dist/compat/math/multiply.d.ts +18 -0
- package/dist/compat/math/multiply.mjs +21 -0
- package/dist/error/index.d.mts +2 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +15 -0
- package/dist/error/index.mjs +2 -0
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +2 -1
- package/dist/function/index.mjs +1 -0
- package/dist/function/retry.d.mts +59 -0
- package/dist/function/retry.d.ts +59 -0
- package/dist/function/retry.mjs +35 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -11
- package/dist/index.mjs +4 -0
- package/dist/object/cloneDeepWith.mjs +34 -1
- package/dist/object/flattenObject.d.mts +10 -2
- package/dist/object/flattenObject.d.ts +10 -2
- package/dist/object/flattenObject.mjs +6 -6
- package/dist/object/index.js +1 -1
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +4 -7
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isPromise.d.mts +20 -0
- package/dist/predicate/isPromise.d.ts +20 -0
- package/dist/predicate/isPromise.mjs +5 -0
- package/dist/promise/index.d.mts +2 -0
- package/dist/promise/index.d.ts +2 -0
- package/dist/promise/index.js +56 -4
- package/dist/promise/index.mjs +2 -0
- package/dist/promise/mutex.d.mts +64 -0
- package/dist/promise/mutex.d.ts +64 -0
- package/dist/promise/mutex.mjs +16 -0
- package/dist/promise/semaphore.d.mts +81 -0
- package/dist/promise/semaphore.d.ts +81 -0
- package/dist/promise/semaphore.mjs +30 -0
- package/error.d.ts +1 -0
- package/package.json +42 -21
- package/dist/_chunk/index-BGZDR9.js +0 -50
- package/dist/_chunk/isPlainObject-octpoD.js +0 -32
package/dist/compat/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { noop } from '../function/noop.js';
|
|
|
36
36
|
export { once } from '../function/once.js';
|
|
37
37
|
export { partial } from '../function/partial.js';
|
|
38
38
|
export { partialRight } from '../function/partialRight.js';
|
|
39
|
+
export { retry } from '../function/retry.js';
|
|
39
40
|
export { ThrottledFunction } from '../function/throttle.js';
|
|
40
41
|
export { unary } from '../function/unary.js';
|
|
41
42
|
export { mean } from '../math/mean.js';
|
|
@@ -58,7 +59,10 @@ export { isLength } from '../predicate/isLength.js';
|
|
|
58
59
|
export { isNotNil } from '../predicate/isNotNil.js';
|
|
59
60
|
export { isNull } from '../predicate/isNull.js';
|
|
60
61
|
export { isPrimitive } from '../predicate/isPrimitive.js';
|
|
62
|
+
export { isPromise } from '../predicate/isPromise.js';
|
|
61
63
|
export { isUndefined } from '../predicate/isUndefined.js';
|
|
64
|
+
export { Mutex } from '../promise/mutex.js';
|
|
65
|
+
export { Semaphore } from '../promise/semaphore.js';
|
|
62
66
|
export { timeout } from '../promise/timeout.js';
|
|
63
67
|
export { withTimeout } from '../promise/withTimeout.js';
|
|
64
68
|
export { capitalize } from '../string/capitalize.js';
|
|
@@ -99,6 +103,7 @@ export { nth } from './array/nth.js';
|
|
|
99
103
|
export { orderBy } from './array/orderBy.js';
|
|
100
104
|
export { pull } from './array/pull.js';
|
|
101
105
|
export { pullAll } from './array/pullAll.js';
|
|
106
|
+
export { pullAllBy } from './array/pullAllBy.js';
|
|
102
107
|
export { remove } from './array/remove.js';
|
|
103
108
|
export { reverse } from './array/reverse.js';
|
|
104
109
|
export { sample } from './array/sample.js';
|
|
@@ -106,6 +111,8 @@ export { size } from './array/size.js';
|
|
|
106
111
|
export { slice } from './array/slice.js';
|
|
107
112
|
export { some } from './array/some.js';
|
|
108
113
|
export { sortBy } from './array/sortBy.js';
|
|
114
|
+
export { sortedIndex } from './array/sortedIndex.js';
|
|
115
|
+
export { sortedIndexBy } from './array/sortedIndexBy.js';
|
|
109
116
|
export { tail } from './array/tail.js';
|
|
110
117
|
export { take } from './array/take.js';
|
|
111
118
|
export { takeRight } from './array/takeRight.js';
|
|
@@ -144,6 +151,7 @@ export { floor } from './math/floor.js';
|
|
|
144
151
|
export { inRange } from './math/inRange.js';
|
|
145
152
|
export { max } from './math/max.js';
|
|
146
153
|
export { min } from './math/min.js';
|
|
154
|
+
export { multiply } from './math/multiply.js';
|
|
147
155
|
export { parseInt } from './math/parseInt.js';
|
|
148
156
|
export { random } from './math/random.js';
|
|
149
157
|
export { range } from './math/range.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const zipWith = require('../_chunk/zipWith-Bdyzuy.js');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const AbortError = require('../_chunk/AbortError-Cg4ZQ1.js');
|
|
7
|
+
const error_index = require('../error/index.js');
|
|
8
|
+
const unary = require('../_chunk/unary-c1NFA5.js');
|
|
8
9
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
9
10
|
const range$1 = require('../_chunk/range-HnEIT7.js');
|
|
10
11
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
|
-
const toMerged = require('../_chunk/toMerged-
|
|
12
|
-
const isPlainObject$1 = require('../_chunk/isPlainObject-
|
|
13
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-
|
|
12
|
+
const toMerged = require('../_chunk/toMerged-BQTfB8.js');
|
|
13
|
+
const isPlainObject$1 = require('../_chunk/isPlainObject-Xaozpc.js');
|
|
14
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-DoHqUM.js');
|
|
15
|
+
const promise_index = require('../promise/index.js');
|
|
14
16
|
const upperFirst$1 = require('../_chunk/upperFirst-CorAVn.js');
|
|
15
17
|
const util_index = require('../util/index.js');
|
|
16
18
|
|
|
@@ -361,14 +363,14 @@ function cloneDeepWith(obj, cloneValue) {
|
|
|
361
363
|
return undefined;
|
|
362
364
|
}
|
|
363
365
|
switch (Object.prototype.toString.call(obj)) {
|
|
364
|
-
case
|
|
365
|
-
case
|
|
366
|
-
case
|
|
366
|
+
case isPlainObject$1.numberTag:
|
|
367
|
+
case isPlainObject$1.stringTag:
|
|
368
|
+
case isPlainObject$1.booleanTag: {
|
|
367
369
|
const result = new obj.constructor(obj?.valueOf());
|
|
368
370
|
toMerged.copyProperties(result, obj);
|
|
369
371
|
return result;
|
|
370
372
|
}
|
|
371
|
-
case
|
|
373
|
+
case isPlainObject$1.argumentsTag: {
|
|
372
374
|
const result = {};
|
|
373
375
|
toMerged.copyProperties(result, obj);
|
|
374
376
|
result.length = obj.length;
|
|
@@ -402,7 +404,7 @@ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
|
|
|
402
404
|
}
|
|
403
405
|
|
|
404
406
|
function isArguments(value) {
|
|
405
|
-
return value !== null && typeof value === 'object' &&
|
|
407
|
+
return value !== null && typeof value === 'object' && isPlainObject$1.getTag(value) === '[object Arguments]';
|
|
406
408
|
}
|
|
407
409
|
|
|
408
410
|
function has(object, path) {
|
|
@@ -726,11 +728,14 @@ function filter(source, predicate) {
|
|
|
726
728
|
}
|
|
727
729
|
}
|
|
728
730
|
|
|
729
|
-
function find(source, doesMatch) {
|
|
731
|
+
function find(source, doesMatch, fromIndex = 0) {
|
|
730
732
|
if (!source) {
|
|
731
733
|
return undefined;
|
|
732
734
|
}
|
|
733
|
-
|
|
735
|
+
if (fromIndex < 0) {
|
|
736
|
+
fromIndex = Math.max(source.length + fromIndex, 0);
|
|
737
|
+
}
|
|
738
|
+
const values = Array.isArray(source) ? source.slice(fromIndex) : Object.values(source).slice(fromIndex);
|
|
734
739
|
switch (typeof doesMatch) {
|
|
735
740
|
case 'function': {
|
|
736
741
|
if (!Array.isArray(source)) {
|
|
@@ -1172,6 +1177,25 @@ function pullAll(arr, valuesToRemove = []) {
|
|
|
1172
1177
|
return zipWith.pull(arr, Array.from(valuesToRemove));
|
|
1173
1178
|
}
|
|
1174
1179
|
|
|
1180
|
+
function pullAllBy(arr, valuesToRemove, _getValue) {
|
|
1181
|
+
const getValue = iteratee(_getValue);
|
|
1182
|
+
const valuesSet = new Set(Array.from(valuesToRemove).map(x => getValue(x)));
|
|
1183
|
+
let resultIndex = 0;
|
|
1184
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1185
|
+
const value = getValue(arr[i]);
|
|
1186
|
+
if (valuesSet.has(value)) {
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (!Object.hasOwn(arr, i)) {
|
|
1190
|
+
delete arr[resultIndex++];
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
arr[resultIndex++] = arr[i];
|
|
1194
|
+
}
|
|
1195
|
+
arr.length = resultIndex;
|
|
1196
|
+
return arr;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1175
1199
|
function remove(arr, shouldRemoveElement) {
|
|
1176
1200
|
return zipWith.remove(arr, iteratee(shouldRemoveElement));
|
|
1177
1201
|
}
|
|
@@ -1292,6 +1316,90 @@ function sortBy(collection, ...criteria) {
|
|
|
1292
1316
|
return orderBy(collection, zipWith.flatten(criteria), ['asc']);
|
|
1293
1317
|
}
|
|
1294
1318
|
|
|
1319
|
+
function isNaN(value) {
|
|
1320
|
+
return Number.isNaN(value);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
function isNil(x) {
|
|
1324
|
+
return x == null;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
const MAX_ARRAY_LENGTH$2 = 4294967295;
|
|
1328
|
+
const MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH$2 - 1;
|
|
1329
|
+
function sortedIndexBy(array, value, iteratee, retHighest) {
|
|
1330
|
+
let low = 0;
|
|
1331
|
+
let high = array == null ? 0 : array.length;
|
|
1332
|
+
if (high === 0 || isNil(array)) {
|
|
1333
|
+
return 0;
|
|
1334
|
+
}
|
|
1335
|
+
const transformedValue = iteratee?.(value);
|
|
1336
|
+
const valIsNaN = isNaN(transformedValue);
|
|
1337
|
+
const valIsNull = isWeakSet$1.isNull(transformedValue);
|
|
1338
|
+
const valIsSymbol = isSymbol(transformedValue);
|
|
1339
|
+
const valIsUndefined = isWeakSet$1.isUndefined(transformedValue);
|
|
1340
|
+
while (low < high) {
|
|
1341
|
+
let setLow;
|
|
1342
|
+
const mid = Math.floor((low + high) / 2);
|
|
1343
|
+
const computed = iteratee?.(array[mid]);
|
|
1344
|
+
const othIsDefined = !isWeakSet$1.isUndefined(computed);
|
|
1345
|
+
const othIsNull = isWeakSet$1.isNull(computed);
|
|
1346
|
+
const othIsReflexive = !isNaN(computed);
|
|
1347
|
+
const othIsSymbol = isSymbol(computed);
|
|
1348
|
+
if (valIsNaN) {
|
|
1349
|
+
setLow = retHighest || othIsReflexive;
|
|
1350
|
+
}
|
|
1351
|
+
else if (valIsUndefined) {
|
|
1352
|
+
setLow = othIsReflexive && (retHighest || othIsDefined);
|
|
1353
|
+
}
|
|
1354
|
+
else if (valIsNull) {
|
|
1355
|
+
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
|
|
1356
|
+
}
|
|
1357
|
+
else if (valIsSymbol) {
|
|
1358
|
+
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
|
|
1359
|
+
}
|
|
1360
|
+
else if (othIsNull || othIsSymbol) {
|
|
1361
|
+
setLow = false;
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
setLow = retHighest ? computed <= transformedValue : computed < transformedValue;
|
|
1365
|
+
}
|
|
1366
|
+
if (setLow) {
|
|
1367
|
+
low = mid + 1;
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
high = mid;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return Math.min(high, MAX_ARRAY_INDEX);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function isNumber(value) {
|
|
1377
|
+
return typeof value === 'number' || value instanceof Number;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
const MAX_ARRAY_LENGTH$1 = 4294967295;
|
|
1381
|
+
const HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH$1 >>> 1;
|
|
1382
|
+
function sortedIndex(array, value) {
|
|
1383
|
+
if (isWeakSet$1.isNil(array)) {
|
|
1384
|
+
return 0;
|
|
1385
|
+
}
|
|
1386
|
+
let low = 0, high = isWeakSet$1.isNil(array) ? low : array.length;
|
|
1387
|
+
if (isNumber(value) && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
|
|
1388
|
+
while (low < high) {
|
|
1389
|
+
const mid = (low + high) >>> 1;
|
|
1390
|
+
const compute = array[mid];
|
|
1391
|
+
if (!isWeakSet$1.isNull(compute) && !isWeakSet$1.isSymbol(compute) && compute < value) {
|
|
1392
|
+
low = mid + 1;
|
|
1393
|
+
}
|
|
1394
|
+
else {
|
|
1395
|
+
high = mid;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return high;
|
|
1399
|
+
}
|
|
1400
|
+
return sortedIndexBy(array, value, value => value);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1295
1403
|
function tail(arr) {
|
|
1296
1404
|
if (!isArrayLike(arr)) {
|
|
1297
1405
|
return [];
|
|
@@ -1855,6 +1963,38 @@ function min(items = []) {
|
|
|
1855
1963
|
return minElement;
|
|
1856
1964
|
}
|
|
1857
1965
|
|
|
1966
|
+
function toString(value) {
|
|
1967
|
+
if (value == null) {
|
|
1968
|
+
return '';
|
|
1969
|
+
}
|
|
1970
|
+
if (Array.isArray(value)) {
|
|
1971
|
+
return value.map(toString).join(',');
|
|
1972
|
+
}
|
|
1973
|
+
const result = String(value);
|
|
1974
|
+
if (result === '0' && Object.is(Number(value), -0)) {
|
|
1975
|
+
return '-0';
|
|
1976
|
+
}
|
|
1977
|
+
return result;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
function multiply(value, other) {
|
|
1981
|
+
if (value === undefined && other === undefined) {
|
|
1982
|
+
return 1;
|
|
1983
|
+
}
|
|
1984
|
+
if (value === undefined || other === undefined) {
|
|
1985
|
+
return value || other;
|
|
1986
|
+
}
|
|
1987
|
+
if (typeof value === 'string' || typeof other === 'string') {
|
|
1988
|
+
value = toString(value);
|
|
1989
|
+
other = toString(other);
|
|
1990
|
+
}
|
|
1991
|
+
else {
|
|
1992
|
+
value = Number(value);
|
|
1993
|
+
other = Number(other);
|
|
1994
|
+
}
|
|
1995
|
+
return value * other;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1858
1998
|
function parseInt(string, radix = 0, guard) {
|
|
1859
1999
|
if (guard) {
|
|
1860
2000
|
radix = 0;
|
|
@@ -2415,10 +2555,6 @@ function omit(obj, ...keysArr) {
|
|
|
2415
2555
|
return result;
|
|
2416
2556
|
}
|
|
2417
2557
|
|
|
2418
|
-
function isNil(x) {
|
|
2419
|
-
return x == null;
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
2558
|
function pick(obj, ...keysArr) {
|
|
2423
2559
|
if (isNil(obj)) {
|
|
2424
2560
|
return {};
|
|
@@ -2559,7 +2695,7 @@ function isEqualWith(a, b, areValuesEqual = noop.noop) {
|
|
|
2559
2695
|
}
|
|
2560
2696
|
|
|
2561
2697
|
function isError(value) {
|
|
2562
|
-
return
|
|
2698
|
+
return isPlainObject$1.getTag(value) === '[object Error]';
|
|
2563
2699
|
}
|
|
2564
2700
|
|
|
2565
2701
|
function isFinite(value) {
|
|
@@ -2574,14 +2710,6 @@ function isMap(value) {
|
|
|
2574
2710
|
return isWeakSet$1.isMap(value);
|
|
2575
2711
|
}
|
|
2576
2712
|
|
|
2577
|
-
function isNaN(value) {
|
|
2578
|
-
return Number.isNaN(value);
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
function isNumber(value) {
|
|
2582
|
-
return typeof value === 'number' || value instanceof Number;
|
|
2583
|
-
}
|
|
2584
|
-
|
|
2585
2713
|
function isRegExp(value) {
|
|
2586
2714
|
return isWeakSet$1.isRegExp(value);
|
|
2587
2715
|
}
|
|
@@ -2602,20 +2730,6 @@ function isWeakSet(value) {
|
|
|
2602
2730
|
return isWeakSet$1.isWeakSet(value);
|
|
2603
2731
|
}
|
|
2604
2732
|
|
|
2605
|
-
function toString(value) {
|
|
2606
|
-
if (value == null) {
|
|
2607
|
-
return '';
|
|
2608
|
-
}
|
|
2609
|
-
if (Array.isArray(value)) {
|
|
2610
|
-
return value.map(toString).join(',');
|
|
2611
|
-
}
|
|
2612
|
-
const result = String(value);
|
|
2613
|
-
if (result === '0' && Object.is(Number(value), -0)) {
|
|
2614
|
-
return '-0';
|
|
2615
|
-
}
|
|
2616
|
-
return result;
|
|
2617
|
-
}
|
|
2618
|
-
|
|
2619
2733
|
function normalizeForCase(str) {
|
|
2620
2734
|
if (typeof str !== 'string') {
|
|
2621
2735
|
str = toString(str);
|
|
@@ -3081,16 +3195,15 @@ exports.xorBy = zipWith.xorBy;
|
|
|
3081
3195
|
exports.xorWith = zipWith.xorWith;
|
|
3082
3196
|
exports.zipObject = zipWith.zipObject;
|
|
3083
3197
|
exports.zipWith = zipWith.zipWith;
|
|
3084
|
-
exports.AbortError =
|
|
3085
|
-
exports.TimeoutError =
|
|
3086
|
-
exports.timeout = promise_index.timeout;
|
|
3087
|
-
exports.withTimeout = promise_index.withTimeout;
|
|
3198
|
+
exports.AbortError = AbortError.AbortError;
|
|
3199
|
+
exports.TimeoutError = error_index.TimeoutError;
|
|
3088
3200
|
exports.asyncNoop = unary.asyncNoop;
|
|
3089
3201
|
exports.identity = unary.identity;
|
|
3090
3202
|
exports.memoize = unary.memoize;
|
|
3091
3203
|
exports.once = unary.once;
|
|
3092
3204
|
exports.partial = unary.partial;
|
|
3093
3205
|
exports.partialRight = unary.partialRight;
|
|
3206
|
+
exports.retry = unary.retry;
|
|
3094
3207
|
exports.unary = unary.unary;
|
|
3095
3208
|
exports.noop = noop.noop;
|
|
3096
3209
|
exports.mean = range$1.mean;
|
|
@@ -3117,7 +3230,12 @@ exports.isJSONValue = isWeakSet$1.isJSONValue;
|
|
|
3117
3230
|
exports.isLength = isWeakSet$1.isLength;
|
|
3118
3231
|
exports.isNotNil = isWeakSet$1.isNotNil;
|
|
3119
3232
|
exports.isNull = isWeakSet$1.isNull;
|
|
3233
|
+
exports.isPromise = isWeakSet$1.isPromise;
|
|
3120
3234
|
exports.isUndefined = isWeakSet$1.isUndefined;
|
|
3235
|
+
exports.Mutex = promise_index.Mutex;
|
|
3236
|
+
exports.Semaphore = promise_index.Semaphore;
|
|
3237
|
+
exports.timeout = promise_index.timeout;
|
|
3238
|
+
exports.withTimeout = promise_index.withTimeout;
|
|
3121
3239
|
exports.capitalize = upperFirst$1.capitalize;
|
|
3122
3240
|
exports.constantCase = upperFirst$1.constantCase;
|
|
3123
3241
|
exports.pascalCase = upperFirst$1.pascalCase;
|
|
@@ -3242,6 +3360,7 @@ exports.mergeWith = mergeWith;
|
|
|
3242
3360
|
exports.method = method;
|
|
3243
3361
|
exports.methodOf = methodOf;
|
|
3244
3362
|
exports.min = min;
|
|
3363
|
+
exports.multiply = multiply;
|
|
3245
3364
|
exports.negate = negate;
|
|
3246
3365
|
exports.now = now;
|
|
3247
3366
|
exports.nth = nth;
|
|
@@ -3257,6 +3376,7 @@ exports.property = property;
|
|
|
3257
3376
|
exports.propertyOf = propertyOf;
|
|
3258
3377
|
exports.pull = pull;
|
|
3259
3378
|
exports.pullAll = pullAll;
|
|
3379
|
+
exports.pullAllBy = pullAllBy;
|
|
3260
3380
|
exports.random = random;
|
|
3261
3381
|
exports.range = range;
|
|
3262
3382
|
exports.rangeRight = rangeRight;
|
|
@@ -3274,6 +3394,8 @@ exports.slice = slice;
|
|
|
3274
3394
|
exports.snakeCase = snakeCase;
|
|
3275
3395
|
exports.some = some;
|
|
3276
3396
|
exports.sortBy = sortBy;
|
|
3397
|
+
exports.sortedIndex = sortedIndex;
|
|
3398
|
+
exports.sortedIndexBy = sortedIndexBy;
|
|
3277
3399
|
exports.spread = spread;
|
|
3278
3400
|
exports.startCase = startCase;
|
|
3279
3401
|
exports.startsWith = startsWith;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -36,6 +36,7 @@ export { noop } from '../function/noop.mjs';
|
|
|
36
36
|
export { once } from '../function/once.mjs';
|
|
37
37
|
export { partial } from '../function/partial.mjs';
|
|
38
38
|
export { partialRight } from '../function/partialRight.mjs';
|
|
39
|
+
export { retry } from '../function/retry.mjs';
|
|
39
40
|
export { unary } from '../function/unary.mjs';
|
|
40
41
|
export { mean } from '../math/mean.mjs';
|
|
41
42
|
export { meanBy } from '../math/meanBy.mjs';
|
|
@@ -59,7 +60,10 @@ export { isJSONArray, isJSONObject, isJSONValue } from '../predicate/isJSONValue
|
|
|
59
60
|
export { isLength } from '../predicate/isLength.mjs';
|
|
60
61
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
61
62
|
export { isNull } from '../predicate/isNull.mjs';
|
|
63
|
+
export { isPromise } from '../predicate/isPromise.mjs';
|
|
62
64
|
export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
65
|
+
export { Mutex } from '../promise/mutex.mjs';
|
|
66
|
+
export { Semaphore } from '../promise/semaphore.mjs';
|
|
63
67
|
export { timeout } from '../promise/timeout.mjs';
|
|
64
68
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
65
69
|
export { capitalize } from '../string/capitalize.mjs';
|
|
@@ -101,6 +105,7 @@ export { nth } from './array/nth.mjs';
|
|
|
101
105
|
export { orderBy } from './array/orderBy.mjs';
|
|
102
106
|
export { pull } from './array/pull.mjs';
|
|
103
107
|
export { pullAll } from './array/pullAll.mjs';
|
|
108
|
+
export { pullAllBy } from './array/pullAllBy.mjs';
|
|
104
109
|
export { remove } from './array/remove.mjs';
|
|
105
110
|
export { reverse } from './array/reverse.mjs';
|
|
106
111
|
export { sample } from './array/sample.mjs';
|
|
@@ -108,6 +113,8 @@ export { size } from './array/size.mjs';
|
|
|
108
113
|
export { slice } from './array/slice.mjs';
|
|
109
114
|
export { some } from './array/some.mjs';
|
|
110
115
|
export { sortBy } from './array/sortBy.mjs';
|
|
116
|
+
export { sortedIndex } from './array/sortedIndex.mjs';
|
|
117
|
+
export { sortedIndexBy } from './array/sortedIndexBy.mjs';
|
|
111
118
|
export { tail } from './array/tail.mjs';
|
|
112
119
|
export { take } from './array/take.mjs';
|
|
113
120
|
export { takeRight } from './array/takeRight.mjs';
|
|
@@ -146,6 +153,7 @@ export { floor } from './math/floor.mjs';
|
|
|
146
153
|
export { inRange } from './math/inRange.mjs';
|
|
147
154
|
export { max } from './math/max.mjs';
|
|
148
155
|
export { min } from './math/min.mjs';
|
|
156
|
+
export { multiply } from './math/multiply.mjs';
|
|
149
157
|
export { parseInt } from './math/parseInt.mjs';
|
|
150
158
|
export { random } from './math/random.mjs';
|
|
151
159
|
export { range } from './math/range.mjs';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multiply two numbers.
|
|
3
|
+
*
|
|
4
|
+
* If either of the numbers is `NaN`, the function returns `NaN`.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} value The first number in a multiplication
|
|
7
|
+
* @param {number} other The second number in a multiplication
|
|
8
|
+
* @returns {number} The product of value and other
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* multiply(2, 3); // => 6
|
|
12
|
+
* multiply(2, NaN); // => NaN
|
|
13
|
+
* multiply(NaN, 3); // => NaN
|
|
14
|
+
* multiply(NaN, NaN); // => NaN
|
|
15
|
+
*/
|
|
16
|
+
declare function multiply(value: number, other: number): number;
|
|
17
|
+
|
|
18
|
+
export { multiply };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multiply two numbers.
|
|
3
|
+
*
|
|
4
|
+
* If either of the numbers is `NaN`, the function returns `NaN`.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} value The first number in a multiplication
|
|
7
|
+
* @param {number} other The second number in a multiplication
|
|
8
|
+
* @returns {number} The product of value and other
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* multiply(2, 3); // => 6
|
|
12
|
+
* multiply(2, NaN); // => NaN
|
|
13
|
+
* multiply(NaN, 3); // => NaN
|
|
14
|
+
* multiply(NaN, NaN); // => NaN
|
|
15
|
+
*/
|
|
16
|
+
declare function multiply(value: number, other: number): number;
|
|
17
|
+
|
|
18
|
+
export { multiply };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { toString } from '../util/toString.mjs';
|
|
2
|
+
|
|
3
|
+
function multiply(value, other) {
|
|
4
|
+
if (value === undefined && other === undefined) {
|
|
5
|
+
return 1;
|
|
6
|
+
}
|
|
7
|
+
if (value === undefined || other === undefined) {
|
|
8
|
+
return value || other;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === 'string' || typeof other === 'string') {
|
|
11
|
+
value = toString(value);
|
|
12
|
+
other = toString(other);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
value = Number(value);
|
|
16
|
+
other = Number(other);
|
|
17
|
+
}
|
|
18
|
+
return value * other;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { multiply };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const AbortError = require('../_chunk/AbortError-Cg4ZQ1.js');
|
|
6
|
+
|
|
7
|
+
class TimeoutError extends Error {
|
|
8
|
+
constructor(message = 'The operation was timed out') {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'TimeoutError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.AbortError = AbortError.AbortError;
|
|
15
|
+
exports.TimeoutError = TimeoutError;
|
|
@@ -15,6 +15,7 @@ export { once } from './once.mjs';
|
|
|
15
15
|
export { partial } from './partial.mjs';
|
|
16
16
|
export { partialRight } from './partialRight.mjs';
|
|
17
17
|
export { rest } from './rest.mjs';
|
|
18
|
+
export { retry } from './retry.mjs';
|
|
18
19
|
export { spread } from './spread.mjs';
|
|
19
20
|
export { ThrottledFunction, throttle } from './throttle.mjs';
|
|
20
21
|
export { unary } from './unary.mjs';
|
package/dist/function/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { once } from './once.js';
|
|
|
15
15
|
export { partial } from './partial.js';
|
|
16
16
|
export { partialRight } from './partialRight.js';
|
|
17
17
|
export { rest } from './rest.js';
|
|
18
|
+
export { retry } from './retry.js';
|
|
18
19
|
export { spread } from './spread.js';
|
|
19
20
|
export { ThrottledFunction, throttle } from './throttle.js';
|
|
20
21
|
export { unary } from './unary.js';
|
package/dist/function/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const unary = require('../_chunk/unary-
|
|
5
|
+
const unary = require('../_chunk/unary-c1NFA5.js');
|
|
6
6
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
7
7
|
|
|
8
8
|
function before(n, func) {
|
|
@@ -98,6 +98,7 @@ exports.once = unary.once;
|
|
|
98
98
|
exports.partial = unary.partial;
|
|
99
99
|
exports.partialRight = unary.partialRight;
|
|
100
100
|
exports.rest = unary.rest;
|
|
101
|
+
exports.retry = unary.retry;
|
|
101
102
|
exports.unary = unary.unary;
|
|
102
103
|
exports.noop = noop.noop;
|
|
103
104
|
exports.before = before;
|
package/dist/function/index.mjs
CHANGED
|
@@ -15,6 +15,7 @@ export { once } from './once.mjs';
|
|
|
15
15
|
export { partial } from './partial.mjs';
|
|
16
16
|
export { partialRight } from './partialRight.mjs';
|
|
17
17
|
export { rest } from './rest.mjs';
|
|
18
|
+
export { retry } from './retry.mjs';
|
|
18
19
|
export { spread } from './spread.mjs';
|
|
19
20
|
export { throttle } from './throttle.mjs';
|
|
20
21
|
export { unary } from './unary.mjs';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
interface RetryOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The number of milliseconds to interval delay.
|
|
4
|
+
* @default 0
|
|
5
|
+
*/
|
|
6
|
+
delay?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of retries to attempt.
|
|
9
|
+
* @default Number.POSITIVE_INFINITY
|
|
10
|
+
*/
|
|
11
|
+
retries?: number;
|
|
12
|
+
/**
|
|
13
|
+
* An AbortSignal to cancel the retry operation.
|
|
14
|
+
*/
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retries a function that returns a promise until it resolves successfully.
|
|
19
|
+
*
|
|
20
|
+
* @template T
|
|
21
|
+
* @param {() => Promise<T>} func - The function to retry.
|
|
22
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Basic usage with default retry options
|
|
26
|
+
* retry(() => fetchData()).then(data => console.log(data));
|
|
27
|
+
*/
|
|
28
|
+
declare function retry<T>(func: () => Promise<T>): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Retries a function that returns a promise a specified number of times.
|
|
31
|
+
*
|
|
32
|
+
* @template T
|
|
33
|
+
* @param {() => Promise<T>} func - The function to retry. It should return a promise.
|
|
34
|
+
* @param {number} retries - The number of retries to attempt. Default is Infinity.
|
|
35
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Retry a function up to 3 times
|
|
39
|
+
* retry(() => fetchData(), 3).then(data => console.log(data));
|
|
40
|
+
*/
|
|
41
|
+
declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Retries a function that returns a promise with specified options.
|
|
44
|
+
*
|
|
45
|
+
* @template T
|
|
46
|
+
* @param {() => Promise<T>} func - The function to retry. It should return a promise.
|
|
47
|
+
* @param {RetryOptions} options - Options to configure the retry behavior.
|
|
48
|
+
* @param {number} [options.delay=0] - The number of milliseconds to wait between retries.
|
|
49
|
+
* @param {number} [options.retries=Infinity] - The number of retries to attempt.
|
|
50
|
+
* @param {AbortSignal} [options.signal] - An AbortSignal to cancel the retry operation.
|
|
51
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Retry a function with a delay of 1000ms between attempts
|
|
55
|
+
* retry(() => fetchData(), { delay: 1000, times: 5 }).then(data => console.log(data));
|
|
56
|
+
*/
|
|
57
|
+
declare function retry<T>(func: () => Promise<T>, options: RetryOptions): Promise<T>;
|
|
58
|
+
|
|
59
|
+
export { retry };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
interface RetryOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The number of milliseconds to interval delay.
|
|
4
|
+
* @default 0
|
|
5
|
+
*/
|
|
6
|
+
delay?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of retries to attempt.
|
|
9
|
+
* @default Number.POSITIVE_INFINITY
|
|
10
|
+
*/
|
|
11
|
+
retries?: number;
|
|
12
|
+
/**
|
|
13
|
+
* An AbortSignal to cancel the retry operation.
|
|
14
|
+
*/
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retries a function that returns a promise until it resolves successfully.
|
|
19
|
+
*
|
|
20
|
+
* @template T
|
|
21
|
+
* @param {() => Promise<T>} func - The function to retry.
|
|
22
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Basic usage with default retry options
|
|
26
|
+
* retry(() => fetchData()).then(data => console.log(data));
|
|
27
|
+
*/
|
|
28
|
+
declare function retry<T>(func: () => Promise<T>): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Retries a function that returns a promise a specified number of times.
|
|
31
|
+
*
|
|
32
|
+
* @template T
|
|
33
|
+
* @param {() => Promise<T>} func - The function to retry. It should return a promise.
|
|
34
|
+
* @param {number} retries - The number of retries to attempt. Default is Infinity.
|
|
35
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Retry a function up to 3 times
|
|
39
|
+
* retry(() => fetchData(), 3).then(data => console.log(data));
|
|
40
|
+
*/
|
|
41
|
+
declare function retry<T>(func: () => Promise<T>, retries: number): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Retries a function that returns a promise with specified options.
|
|
44
|
+
*
|
|
45
|
+
* @template T
|
|
46
|
+
* @param {() => Promise<T>} func - The function to retry. It should return a promise.
|
|
47
|
+
* @param {RetryOptions} options - Options to configure the retry behavior.
|
|
48
|
+
* @param {number} [options.delay=0] - The number of milliseconds to wait between retries.
|
|
49
|
+
* @param {number} [options.retries=Infinity] - The number of retries to attempt.
|
|
50
|
+
* @param {AbortSignal} [options.signal] - An AbortSignal to cancel the retry operation.
|
|
51
|
+
* @returns {Promise<T>} A promise that resolves with the value of the successful function call.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Retry a function with a delay of 1000ms between attempts
|
|
55
|
+
* retry(() => fetchData(), { delay: 1000, times: 5 }).then(data => console.log(data));
|
|
56
|
+
*/
|
|
57
|
+
declare function retry<T>(func: () => Promise<T>, options: RetryOptions): Promise<T>;
|
|
58
|
+
|
|
59
|
+
export { retry };
|