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.
Files changed (73) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/_chunk/AbortError-Cg4ZQ1.js +10 -0
  3. package/dist/_chunk/delay-_VMfFa.js +25 -0
  4. package/dist/_chunk/isPlainObject-Xaozpc.js +93 -0
  5. package/dist/_chunk/{isWeakSet-CvIdTA.js → isWeakSet-DoHqUM.js} +42 -71
  6. package/dist/_chunk/{toMerged-DGFrN7.js → toMerged-BQTfB8.js} +39 -8
  7. package/dist/_chunk/{unary-B6qG7C.js → unary-c1NFA5.js} +35 -0
  8. package/dist/array/at.d.mts +1 -1
  9. package/dist/array/at.d.ts +1 -1
  10. package/dist/array/pullAt.d.mts +1 -1
  11. package/dist/array/pullAt.d.ts +1 -1
  12. package/dist/browser.global.js +1 -1
  13. package/dist/browser.global.js.map +1 -1
  14. package/dist/compat/array/find.d.mts +16 -8
  15. package/dist/compat/array/find.d.ts +16 -8
  16. package/dist/compat/array/find.mjs +5 -2
  17. package/dist/compat/array/pullAllBy.d.mts +64 -0
  18. package/dist/compat/array/pullAllBy.d.ts +64 -0
  19. package/dist/compat/array/pullAllBy.mjs +22 -0
  20. package/dist/compat/array/sortedIndex.d.mts +16 -0
  21. package/dist/compat/array/sortedIndex.d.ts +16 -0
  22. package/dist/compat/array/sortedIndex.mjs +30 -0
  23. package/dist/compat/array/sortedIndexBy.d.mts +19 -0
  24. package/dist/compat/array/sortedIndexBy.d.ts +19 -0
  25. package/dist/compat/array/sortedIndexBy.mjs +56 -0
  26. package/dist/compat/index.d.mts +8 -0
  27. package/dist/compat/index.d.ts +8 -0
  28. package/dist/compat/index.js +165 -43
  29. package/dist/compat/index.mjs +8 -0
  30. package/dist/compat/math/multiply.d.mts +18 -0
  31. package/dist/compat/math/multiply.d.ts +18 -0
  32. package/dist/compat/math/multiply.mjs +21 -0
  33. package/dist/error/index.d.mts +2 -0
  34. package/dist/error/index.d.ts +2 -0
  35. package/dist/error/index.js +15 -0
  36. package/dist/error/index.mjs +2 -0
  37. package/dist/function/index.d.mts +1 -0
  38. package/dist/function/index.d.ts +1 -0
  39. package/dist/function/index.js +2 -1
  40. package/dist/function/index.mjs +1 -0
  41. package/dist/function/retry.d.mts +59 -0
  42. package/dist/function/retry.d.ts +59 -0
  43. package/dist/function/retry.mjs +35 -0
  44. package/dist/index.d.mts +4 -0
  45. package/dist/index.d.ts +4 -0
  46. package/dist/index.js +18 -11
  47. package/dist/index.mjs +4 -0
  48. package/dist/object/cloneDeepWith.mjs +34 -1
  49. package/dist/object/flattenObject.d.mts +10 -2
  50. package/dist/object/flattenObject.d.ts +10 -2
  51. package/dist/object/flattenObject.mjs +6 -6
  52. package/dist/object/index.js +1 -1
  53. package/dist/predicate/index.d.mts +1 -0
  54. package/dist/predicate/index.d.ts +1 -0
  55. package/dist/predicate/index.js +4 -7
  56. package/dist/predicate/index.mjs +1 -0
  57. package/dist/predicate/isPromise.d.mts +20 -0
  58. package/dist/predicate/isPromise.d.ts +20 -0
  59. package/dist/predicate/isPromise.mjs +5 -0
  60. package/dist/promise/index.d.mts +2 -0
  61. package/dist/promise/index.d.ts +2 -0
  62. package/dist/promise/index.js +56 -4
  63. package/dist/promise/index.mjs +2 -0
  64. package/dist/promise/mutex.d.mts +64 -0
  65. package/dist/promise/mutex.d.ts +64 -0
  66. package/dist/promise/mutex.mjs +16 -0
  67. package/dist/promise/semaphore.d.mts +81 -0
  68. package/dist/promise/semaphore.d.ts +81 -0
  69. package/dist/promise/semaphore.mjs +30 -0
  70. package/error.d.ts +1 -0
  71. package/package.json +42 -21
  72. package/dist/_chunk/index-BGZDR9.js +0 -50
  73. package/dist/_chunk/isPlainObject-octpoD.js +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # es-toolkit Changelog
2
2
 
3
+ ## Version v1.32.0
4
+
5
+ Released on January 30th, 2024.
6
+
7
+ - Added support for [Semaphore](https://es-toolkit.slash.page/reference/promise/Semaphore.html), [Mutex](https://es-toolkit.slash.page/reference/promise/Mutex.html), [isPromise](https://es-toolkit.slash.page/reference/predicate/isPromise.html), and [retry](https://es-toolkit.slash.page/reference/function/retry.html).
8
+ - Introduced compatibility functions for [multiply](https://es-toolkit.slash.page/reference/compat/math/multiply.html), [sortedIndex](https://es-toolkit.slash.page/reference/compat/array/sortedIndex.html), and [sortedIndexBy](https://es-toolkit.slash.page/reference/compat/array/sortedIndexBy.html).
9
+ - Added support for custom delimiters in [flattenObject](https://es-toolkit.slash.page/reference/object/flattenObject.html).
10
+ - Added support for `fromIndex` parameters in [find](https://es-toolkit.slash.page/reference/compat/array/find.html).
11
+ - Fixed a bug in [cloneDeep](https://es-toolkit.slash.page/reference/object/cloneDeep.html) and [cloneDeepWith](https://es-toolkit.slash.page/reference/object/cloneDeepWith.html) that cloned uncloneable objects.
12
+
3
13
  ## Version v1.31.0
4
14
 
5
15
  Released on December 27th, 2024.
@@ -0,0 +1,10 @@
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
+ exports.AbortError = AbortError;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const AbortError = require('./AbortError-Cg4ZQ1.js');
4
+
5
+ function delay(ms, { signal } = {}) {
6
+ return new Promise((resolve, reject) => {
7
+ const abortError = () => {
8
+ reject(new AbortError.AbortError());
9
+ };
10
+ const abortHandler = () => {
11
+ clearTimeout(timeoutId);
12
+ abortError();
13
+ };
14
+ if (signal?.aborted) {
15
+ return abortError();
16
+ }
17
+ const timeoutId = setTimeout(() => {
18
+ signal?.removeEventListener('abort', abortHandler);
19
+ resolve();
20
+ }, ms);
21
+ signal?.addEventListener('abort', abortHandler, { once: true });
22
+ });
23
+ }
24
+
25
+ exports.delay = delay;
@@ -0,0 +1,93 @@
1
+ 'use strict';
2
+
3
+ function isPrimitive(value) {
4
+ return value == null || (typeof value !== 'object' && typeof value !== 'function');
5
+ }
6
+
7
+ function isTypedArray(x) {
8
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
9
+ }
10
+
11
+ function getSymbols(object) {
12
+ return Object.getOwnPropertySymbols(object).filter(symbol => Object.prototype.propertyIsEnumerable.call(object, symbol));
13
+ }
14
+
15
+ function getTag(value) {
16
+ if (value == null) {
17
+ return value === undefined ? '[object Undefined]' : '[object Null]';
18
+ }
19
+ return Object.prototype.toString.call(value);
20
+ }
21
+
22
+ const regexpTag = '[object RegExp]';
23
+ const stringTag = '[object String]';
24
+ const numberTag = '[object Number]';
25
+ const booleanTag = '[object Boolean]';
26
+ const argumentsTag = '[object Arguments]';
27
+ const symbolTag = '[object Symbol]';
28
+ const dateTag = '[object Date]';
29
+ const mapTag = '[object Map]';
30
+ const setTag = '[object Set]';
31
+ const arrayTag = '[object Array]';
32
+ const functionTag = '[object Function]';
33
+ const arrayBufferTag = '[object ArrayBuffer]';
34
+ const objectTag = '[object Object]';
35
+ const errorTag = '[object Error]';
36
+ const dataViewTag = '[object DataView]';
37
+ const uint8ArrayTag = '[object Uint8Array]';
38
+ const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
39
+ const uint16ArrayTag = '[object Uint16Array]';
40
+ const uint32ArrayTag = '[object Uint32Array]';
41
+ const bigUint64ArrayTag = '[object BigUint64Array]';
42
+ const int8ArrayTag = '[object Int8Array]';
43
+ const int16ArrayTag = '[object Int16Array]';
44
+ const int32ArrayTag = '[object Int32Array]';
45
+ const bigInt64ArrayTag = '[object BigInt64Array]';
46
+ const float32ArrayTag = '[object Float32Array]';
47
+ const float64ArrayTag = '[object Float64Array]';
48
+
49
+ function isPlainObject(value) {
50
+ if (!value || typeof value !== 'object') {
51
+ return false;
52
+ }
53
+ const proto = Object.getPrototypeOf(value);
54
+ const hasObjectPrototype = proto === null ||
55
+ proto === Object.prototype ||
56
+ Object.getPrototypeOf(proto) === null;
57
+ if (!hasObjectPrototype) {
58
+ return false;
59
+ }
60
+ return Object.prototype.toString.call(value) === '[object Object]';
61
+ }
62
+
63
+ exports.argumentsTag = argumentsTag;
64
+ exports.arrayBufferTag = arrayBufferTag;
65
+ exports.arrayTag = arrayTag;
66
+ exports.bigInt64ArrayTag = bigInt64ArrayTag;
67
+ exports.bigUint64ArrayTag = bigUint64ArrayTag;
68
+ exports.booleanTag = booleanTag;
69
+ exports.dataViewTag = dataViewTag;
70
+ exports.dateTag = dateTag;
71
+ exports.errorTag = errorTag;
72
+ exports.float32ArrayTag = float32ArrayTag;
73
+ exports.float64ArrayTag = float64ArrayTag;
74
+ exports.functionTag = functionTag;
75
+ exports.getSymbols = getSymbols;
76
+ exports.getTag = getTag;
77
+ exports.int16ArrayTag = int16ArrayTag;
78
+ exports.int32ArrayTag = int32ArrayTag;
79
+ exports.int8ArrayTag = int8ArrayTag;
80
+ exports.isPlainObject = isPlainObject;
81
+ exports.isPrimitive = isPrimitive;
82
+ exports.isTypedArray = isTypedArray;
83
+ exports.mapTag = mapTag;
84
+ exports.numberTag = numberTag;
85
+ exports.objectTag = objectTag;
86
+ exports.regexpTag = regexpTag;
87
+ exports.setTag = setTag;
88
+ exports.stringTag = stringTag;
89
+ exports.symbolTag = symbolTag;
90
+ exports.uint16ArrayTag = uint16ArrayTag;
91
+ exports.uint32ArrayTag = uint32ArrayTag;
92
+ exports.uint8ArrayTag = uint8ArrayTag;
93
+ exports.uint8ClampedArrayTag = uint8ClampedArrayTag;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const isPlainObject = require('./isPlainObject-octpoD.js');
3
+ const isPlainObject = require('./isPlainObject-Xaozpc.js');
4
4
  const noop = require('./noop-2IwLUk.js');
5
5
 
6
6
  function isArrayBuffer(value) {
@@ -22,40 +22,6 @@ function isDate(value) {
22
22
  return value instanceof Date;
23
23
  }
24
24
 
25
- function getTag(value) {
26
- if (value == null) {
27
- return value === undefined ? '[object Undefined]' : '[object Null]';
28
- }
29
- return Object.prototype.toString.call(value);
30
- }
31
-
32
- const regexpTag = '[object RegExp]';
33
- const stringTag = '[object String]';
34
- const numberTag = '[object Number]';
35
- const booleanTag = '[object Boolean]';
36
- const argumentsTag = '[object Arguments]';
37
- const symbolTag = '[object Symbol]';
38
- const dateTag = '[object Date]';
39
- const mapTag = '[object Map]';
40
- const setTag = '[object Set]';
41
- const arrayTag = '[object Array]';
42
- const functionTag = '[object Function]';
43
- const arrayBufferTag = '[object ArrayBuffer]';
44
- const objectTag = '[object Object]';
45
- const errorTag = '[object Error]';
46
- const dataViewTag = '[object DataView]';
47
- const uint8ArrayTag = '[object Uint8Array]';
48
- const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
49
- const uint16ArrayTag = '[object Uint16Array]';
50
- const uint32ArrayTag = '[object Uint32Array]';
51
- const bigUint64ArrayTag = '[object BigUint64Array]';
52
- const int8ArrayTag = '[object Int8Array]';
53
- const int16ArrayTag = '[object Int16Array]';
54
- const int32ArrayTag = '[object Int32Array]';
55
- const bigInt64ArrayTag = '[object BigInt64Array]';
56
- const float32ArrayTag = '[object Float32Array]';
57
- const float64ArrayTag = '[object Float64Array]';
58
-
59
25
  function eq(value, other) {
60
26
  return value === other || (Number.isNaN(value) && Number.isNaN(other));
61
27
  }
@@ -94,33 +60,33 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
94
60
  if (Object.is(a, b)) {
95
61
  return true;
96
62
  }
97
- let aTag = getTag(a);
98
- let bTag = getTag(b);
99
- if (aTag === argumentsTag) {
100
- aTag = objectTag;
63
+ let aTag = isPlainObject.getTag(a);
64
+ let bTag = isPlainObject.getTag(b);
65
+ if (aTag === isPlainObject.argumentsTag) {
66
+ aTag = isPlainObject.objectTag;
101
67
  }
102
- if (bTag === argumentsTag) {
103
- bTag = objectTag;
68
+ if (bTag === isPlainObject.argumentsTag) {
69
+ bTag = isPlainObject.objectTag;
104
70
  }
105
71
  if (aTag !== bTag) {
106
72
  return false;
107
73
  }
108
74
  switch (aTag) {
109
- case stringTag:
75
+ case isPlainObject.stringTag:
110
76
  return a.toString() === b.toString();
111
- case numberTag: {
77
+ case isPlainObject.numberTag: {
112
78
  const x = a.valueOf();
113
79
  const y = b.valueOf();
114
80
  return eq(x, y);
115
81
  }
116
- case booleanTag:
117
- case dateTag:
118
- case symbolTag:
82
+ case isPlainObject.booleanTag:
83
+ case isPlainObject.dateTag:
84
+ case isPlainObject.symbolTag:
119
85
  return Object.is(a.valueOf(), b.valueOf());
120
- case regexpTag: {
86
+ case isPlainObject.regexpTag: {
121
87
  return a.source === b.source && a.flags === b.flags;
122
88
  }
123
- case functionTag: {
89
+ case isPlainObject.functionTag: {
124
90
  return a === b;
125
91
  }
126
92
  }
@@ -134,7 +100,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
134
100
  stack.set(b, a);
135
101
  try {
136
102
  switch (aTag) {
137
- case mapTag: {
103
+ case isPlainObject.mapTag: {
138
104
  if (a.size !== b.size) {
139
105
  return false;
140
106
  }
@@ -145,7 +111,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
145
111
  }
146
112
  return true;
147
113
  }
148
- case setTag: {
114
+ case isPlainObject.setTag: {
149
115
  if (a.size !== b.size) {
150
116
  return false;
151
117
  }
@@ -163,18 +129,18 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
163
129
  }
164
130
  return true;
165
131
  }
166
- case arrayTag:
167
- case uint8ArrayTag:
168
- case uint8ClampedArrayTag:
169
- case uint16ArrayTag:
170
- case uint32ArrayTag:
171
- case bigUint64ArrayTag:
172
- case int8ArrayTag:
173
- case int16ArrayTag:
174
- case int32ArrayTag:
175
- case bigInt64ArrayTag:
176
- case float32ArrayTag:
177
- case float64ArrayTag: {
132
+ case isPlainObject.arrayTag:
133
+ case isPlainObject.uint8ArrayTag:
134
+ case isPlainObject.uint8ClampedArrayTag:
135
+ case isPlainObject.uint16ArrayTag:
136
+ case isPlainObject.uint32ArrayTag:
137
+ case isPlainObject.bigUint64ArrayTag:
138
+ case isPlainObject.int8ArrayTag:
139
+ case isPlainObject.int16ArrayTag:
140
+ case isPlainObject.int32ArrayTag:
141
+ case isPlainObject.bigInt64ArrayTag:
142
+ case isPlainObject.float32ArrayTag:
143
+ case isPlainObject.float64ArrayTag: {
178
144
  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
179
145
  return false;
180
146
  }
@@ -188,22 +154,22 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
188
154
  }
189
155
  return true;
190
156
  }
191
- case arrayBufferTag: {
157
+ case isPlainObject.arrayBufferTag: {
192
158
  if (a.byteLength !== b.byteLength) {
193
159
  return false;
194
160
  }
195
161
  return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
196
162
  }
197
- case dataViewTag: {
163
+ case isPlainObject.dataViewTag: {
198
164
  if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
199
165
  return false;
200
166
  }
201
167
  return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
202
168
  }
203
- case errorTag: {
169
+ case isPlainObject.errorTag: {
204
170
  return a.name === b.name && a.message === b.message;
205
171
  }
206
- case objectTag: {
172
+ case isPlainObject.objectTag: {
207
173
  const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) ||
208
174
  (isPlainObject.isPlainObject(a) && isPlainObject.isPlainObject(b));
209
175
  if (!areEqualInstances) {
@@ -312,6 +278,10 @@ function isNull(x) {
312
278
  return x === null;
313
279
  }
314
280
 
281
+ function isPromise(value) {
282
+ return value instanceof Promise;
283
+ }
284
+
315
285
  function isRegExp(value) {
316
286
  return value instanceof RegExp;
317
287
  }
@@ -320,6 +290,10 @@ function isSet(value) {
320
290
  return value instanceof Set;
321
291
  }
322
292
 
293
+ function isSymbol(value) {
294
+ return typeof value === 'symbol';
295
+ }
296
+
323
297
  function isUndefined(x) {
324
298
  return x === undefined;
325
299
  }
@@ -332,10 +306,7 @@ function isWeakSet(value) {
332
306
  return value instanceof WeakSet;
333
307
  }
334
308
 
335
- exports.argumentsTag = argumentsTag;
336
- exports.booleanTag = booleanTag;
337
309
  exports.eq = eq;
338
- exports.getTag = getTag;
339
310
  exports.isArrayBuffer = isArrayBuffer;
340
311
  exports.isBlob = isBlob;
341
312
  exports.isBuffer = isBuffer;
@@ -352,10 +323,10 @@ exports.isMap = isMap;
352
323
  exports.isNil = isNil;
353
324
  exports.isNotNil = isNotNil;
354
325
  exports.isNull = isNull;
326
+ exports.isPromise = isPromise;
355
327
  exports.isRegExp = isRegExp;
356
328
  exports.isSet = isSet;
329
+ exports.isSymbol = isSymbol;
357
330
  exports.isUndefined = isUndefined;
358
331
  exports.isWeakMap = isWeakMap;
359
332
  exports.isWeakSet = isWeakSet;
360
- exports.numberTag = numberTag;
361
- exports.stringTag = stringTag;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const isPlainObject = require('./isPlainObject-octpoD.js');
3
+ const isPlainObject = require('./isPlainObject-Xaozpc.js');
4
4
 
5
5
  function clone(obj) {
6
6
  if (isPlainObject.isPrimitive(obj)) {
@@ -140,7 +140,7 @@ function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new
140
140
  copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
141
141
  return result;
142
142
  }
143
- if (typeof valueToClone === 'object' && valueToClone !== null) {
143
+ if (typeof valueToClone === 'object' && isCloneableObject(valueToClone)) {
144
144
  const result = Object.create(Object.getPrototypeOf(valueToClone));
145
145
  stack.set(valueToClone, result);
146
146
  copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
@@ -158,6 +158,37 @@ function copyProperties(target, source, objectToClone = target, stack, cloneValu
158
158
  }
159
159
  }
160
160
  }
161
+ function isCloneableObject(object) {
162
+ switch (isPlainObject.getTag(object)) {
163
+ case isPlainObject.argumentsTag:
164
+ case isPlainObject.arrayTag:
165
+ case isPlainObject.arrayBufferTag:
166
+ case isPlainObject.dataViewTag:
167
+ case isPlainObject.booleanTag:
168
+ case isPlainObject.dateTag:
169
+ case isPlainObject.float32ArrayTag:
170
+ case isPlainObject.float64ArrayTag:
171
+ case isPlainObject.int8ArrayTag:
172
+ case isPlainObject.int16ArrayTag:
173
+ case isPlainObject.int32ArrayTag:
174
+ case isPlainObject.mapTag:
175
+ case isPlainObject.numberTag:
176
+ case isPlainObject.objectTag:
177
+ case isPlainObject.regexpTag:
178
+ case isPlainObject.setTag:
179
+ case isPlainObject.stringTag:
180
+ case isPlainObject.symbolTag:
181
+ case isPlainObject.uint8ArrayTag:
182
+ case isPlainObject.uint8ClampedArrayTag:
183
+ case isPlainObject.uint16ArrayTag:
184
+ case isPlainObject.uint32ArrayTag: {
185
+ return true;
186
+ }
187
+ default: {
188
+ return false;
189
+ }
190
+ }
191
+ }
161
192
 
162
193
  function cloneDeep(obj) {
163
194
  return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
@@ -168,22 +199,22 @@ function findKey(obj, predicate) {
168
199
  return keys.find(key => predicate(obj[key], key, obj));
169
200
  }
170
201
 
171
- function flattenObject(object) {
172
- return flattenObjectImpl(object);
202
+ function flattenObject(object, { delimiter = '.' } = {}) {
203
+ return flattenObjectImpl(object, '', delimiter);
173
204
  }
174
- function flattenObjectImpl(object, prefix = '') {
205
+ function flattenObjectImpl(object, prefix = '', delimiter = '.') {
175
206
  const result = {};
176
207
  const keys = Object.keys(object);
177
208
  for (let i = 0; i < keys.length; i++) {
178
209
  const key = keys[i];
179
210
  const value = object[key];
180
- const prefixedKey = prefix ? `${prefix}.${key}` : key;
211
+ const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key;
181
212
  if (isPlainObject.isPlainObject(value) && Object.keys(value).length > 0) {
182
- Object.assign(result, flattenObjectImpl(value, prefixedKey));
213
+ Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
183
214
  continue;
184
215
  }
185
216
  if (Array.isArray(value)) {
186
- Object.assign(result, flattenObjectImpl(value, prefixedKey));
217
+ Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
187
218
  continue;
188
219
  }
189
220
  result[prefixedKey] = value;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const delay = require('./delay-_VMfFa.js');
4
+
3
5
  function after(n, func) {
4
6
  if (!Number.isInteger(n) || n < 0) {
5
7
  throw new Error(`n must be a non-negative integer.`);
@@ -189,6 +191,38 @@ function rest(func, startIndex = func.length - 1) {
189
191
  };
190
192
  }
191
193
 
194
+ const DEFAULT_DELAY = 0;
195
+ const DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
196
+ async function retry(func, _options) {
197
+ let delay$1;
198
+ let retries;
199
+ let signal;
200
+ if (typeof _options === 'number') {
201
+ delay$1 = DEFAULT_DELAY;
202
+ retries = _options;
203
+ signal = undefined;
204
+ }
205
+ else {
206
+ delay$1 = _options?.delay ?? DEFAULT_DELAY;
207
+ retries = _options?.retries ?? DEFAULT_RETRIES;
208
+ signal = _options?.signal;
209
+ }
210
+ let error;
211
+ for (let i = 0; i < retries; i++) {
212
+ if (signal?.aborted) {
213
+ throw error ?? new Error(`The retry operation was aborted due to an abort signal.`);
214
+ }
215
+ try {
216
+ return await func();
217
+ }
218
+ catch (err) {
219
+ error = err;
220
+ await delay.delay(delay$1);
221
+ }
222
+ }
223
+ throw error;
224
+ }
225
+
192
226
  function unary(func) {
193
227
  return ary(func, 1);
194
228
  }
@@ -206,4 +240,5 @@ exports.once = once;
206
240
  exports.partial = partial;
207
241
  exports.partialRight = partialRight;
208
242
  exports.rest = rest;
243
+ exports.retry = retry;
209
244
  exports.unary = unary;
@@ -13,6 +13,6 @@
13
13
  * const result = at(numbers, [1, 3, 4]);
14
14
  * console.log(result); // [20, 40, 50]
15
15
  */
16
- declare function at<T>(arr: readonly T[], indices: number[]): Array<T | undefined>;
16
+ declare function at<T>(arr: readonly T[], indices: number[]): T[];
17
17
 
18
18
  export { at };
@@ -13,6 +13,6 @@
13
13
  * const result = at(numbers, [1, 3, 4]);
14
14
  * console.log(result); // [20, 40, 50]
15
15
  */
16
- declare function at<T>(arr: readonly T[], indices: number[]): Array<T | undefined>;
16
+ declare function at<T>(arr: readonly T[], indices: number[]): T[];
17
17
 
18
18
  export { at };
@@ -16,6 +16,6 @@
16
16
  * console.log(removed); // [20, 40, 50]
17
17
  * console.log(numbers); // [10, 30]
18
18
  */
19
- declare function pullAt<T>(arr: T[], indicesToRemove: number[]): Array<T | undefined>;
19
+ declare function pullAt<T>(arr: T[], indicesToRemove: number[]): T[];
20
20
 
21
21
  export { pullAt };
@@ -16,6 +16,6 @@
16
16
  * console.log(removed); // [20, 40, 50]
17
17
  * console.log(numbers); // [10, 30]
18
18
  */
19
- declare function pullAt<T>(arr: T[], indicesToRemove: number[]): Array<T | undefined>;
19
+ declare function pullAt<T>(arr: T[], indicesToRemove: number[]): T[];
20
20
 
21
21
  export { pullAt };