es-toolkit 1.10.1-dev.250 → 1.10.1-dev.252

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 (168) hide show
  1. package/dist/array/chunk.mjs +1 -1
  2. package/dist/array/compact.mjs +1 -1
  3. package/dist/array/countBy.mjs +1 -1
  4. package/dist/array/difference.mjs +1 -1
  5. package/dist/array/differenceBy.mjs +1 -1
  6. package/dist/array/differenceWith.mjs +1 -1
  7. package/dist/array/drop.mjs +1 -1
  8. package/dist/array/dropRight.mjs +1 -1
  9. package/dist/array/dropRightWhile.mjs +1 -1
  10. package/dist/array/dropWhile.mjs +1 -1
  11. package/dist/array/fill.mjs +1 -1
  12. package/dist/array/flatMap.mjs +1 -1
  13. package/dist/array/flatten.mjs +1 -1
  14. package/dist/array/flattenDeep.mjs +1 -1
  15. package/dist/array/forEachRight.mjs +1 -1
  16. package/dist/array/groupBy.mjs +1 -1
  17. package/dist/array/head.mjs +1 -1
  18. package/dist/array/index.mjs +20 -20
  19. package/dist/array/initial.mjs +1 -1
  20. package/dist/array/intersection.mjs +1 -1
  21. package/dist/array/intersectionBy.mjs +1 -1
  22. package/dist/array/intersectionWith.mjs +1 -1
  23. package/dist/array/keyBy.mjs +1 -1
  24. package/dist/array/last.mjs +1 -1
  25. package/dist/array/maxBy.mjs +1 -1
  26. package/dist/array/minBy.mjs +1 -1
  27. package/dist/array/orderBy.mjs +1 -1
  28. package/dist/array/partition.mjs +1 -1
  29. package/dist/array/sample.mjs +1 -1
  30. package/dist/array/sampleSize.mjs +1 -1
  31. package/dist/array/shuffle.mjs +1 -1
  32. package/dist/array/tail.mjs +1 -1
  33. package/dist/array/take.mjs +1 -1
  34. package/dist/array/takeRight.mjs +1 -1
  35. package/dist/array/takeRightWhile.mjs +1 -1
  36. package/dist/array/takeWhile.mjs +1 -1
  37. package/dist/array/toFilled.mjs +1 -1
  38. package/dist/array/union.mjs +1 -1
  39. package/dist/array/unionBy.mjs +1 -1
  40. package/dist/array/unionWith.mjs +1 -1
  41. package/dist/array/uniq.mjs +1 -1
  42. package/dist/array/uniqBy.mjs +1 -1
  43. package/dist/array/uniqWith.mjs +1 -1
  44. package/dist/array/unzip.mjs +1 -1
  45. package/dist/array/unzipWith.mjs +1 -1
  46. package/dist/array/without.mjs +1 -1
  47. package/dist/array/xor.mjs +1 -1
  48. package/dist/array/xorBy.mjs +1 -1
  49. package/dist/array/xorWith.mjs +1 -1
  50. package/dist/array/zip.mjs +1 -1
  51. package/dist/array/zipObject.mjs +1 -1
  52. package/dist/array/zipWith.mjs +1 -1
  53. package/dist/{chunk-2MM5EJJX.mjs → chunk-424M7IR7.mjs} +23 -2
  54. package/dist/chunk-4OIZM4HS.mjs +1 -0
  55. package/dist/chunk-F47GLYUU.mjs +1 -0
  56. package/dist/chunk-J3GE7DEU.mjs +22 -0
  57. package/dist/chunk-J3GE7DEU.mjs.map +1 -0
  58. package/dist/chunk-KIOYQRMQ.mjs +12 -0
  59. package/dist/chunk-KIOYQRMQ.mjs.map +1 -0
  60. package/dist/{chunk-QZITBKWX.mjs → chunk-U7V3G7CR.mjs} +2 -2
  61. package/dist/chunk-XT74R35S.mjs +1 -0
  62. package/dist/chunk-XWPCDIFC.mjs +18 -0
  63. package/dist/chunk-XWPCDIFC.mjs.map +1 -0
  64. package/dist/compat/index.d.mts +41 -3
  65. package/dist/compat/index.d.ts +41 -3
  66. package/dist/compat/index.js +57 -10
  67. package/dist/compat/index.js.map +1 -1
  68. package/dist/compat/index.mjs +68 -55
  69. package/dist/compat/index.mjs.map +1 -1
  70. package/dist/error/AbortError.mjs +1 -1
  71. package/dist/error/TimeoutError.d.mts +9 -0
  72. package/dist/error/TimeoutError.d.ts +9 -0
  73. package/dist/{string/startsWith.js → error/TimeoutError.js} +12 -9
  74. package/dist/error/TimeoutError.js.map +1 -0
  75. package/dist/error/TimeoutError.mjs +8 -0
  76. package/dist/error/index.d.mts +1 -0
  77. package/dist/error/index.d.ts +1 -0
  78. package/dist/error/index.js +12 -2
  79. package/dist/error/index.js.map +1 -1
  80. package/dist/error/index.mjs +7 -3
  81. package/dist/function/debounce.mjs +1 -1
  82. package/dist/function/index.mjs +4 -4
  83. package/dist/function/negate.mjs +1 -1
  84. package/dist/function/noop.mjs +1 -1
  85. package/dist/function/once.mjs +1 -1
  86. package/dist/function/throttle.mjs +1 -1
  87. package/dist/index.d.mts +2 -2
  88. package/dist/index.d.ts +2 -2
  89. package/dist/index.js +47 -14
  90. package/dist/index.js.map +1 -1
  91. package/dist/index.mjs +58 -57
  92. package/dist/math/clamp.mjs +1 -1
  93. package/dist/math/inRange.mjs +1 -1
  94. package/dist/math/index.mjs +7 -7
  95. package/dist/math/mean.mjs +1 -1
  96. package/dist/math/meanBy.mjs +1 -1
  97. package/dist/math/random.mjs +1 -1
  98. package/dist/math/randomInt.mjs +1 -1
  99. package/dist/math/range.mjs +1 -1
  100. package/dist/math/round.mjs +1 -1
  101. package/dist/math/sum.mjs +1 -1
  102. package/dist/math/sumBy.mjs +1 -1
  103. package/dist/object/clone.mjs +1 -1
  104. package/dist/object/get.mjs +1 -1
  105. package/dist/object/index.mjs +5 -5
  106. package/dist/object/invert.mjs +1 -1
  107. package/dist/object/omit.mjs +2 -2
  108. package/dist/object/omitBy.mjs +1 -1
  109. package/dist/object/pick.mjs +1 -1
  110. package/dist/object/pickBy.mjs +1 -1
  111. package/dist/predicate/index.mjs +1 -1
  112. package/dist/predicate/isEqual.mjs +1 -1
  113. package/dist/predicate/isNil.mjs +1 -1
  114. package/dist/predicate/isNotNil.mjs +1 -1
  115. package/dist/predicate/isNull.mjs +1 -1
  116. package/dist/predicate/isUndefined.mjs +1 -1
  117. package/dist/promise/delay.mjs +1 -1
  118. package/dist/promise/index.d.mts +1 -0
  119. package/dist/promise/index.d.ts +1 -0
  120. package/dist/promise/index.js +47 -2
  121. package/dist/promise/index.js.map +1 -1
  122. package/dist/promise/index.mjs +9 -3
  123. package/dist/promise/timeout.d.mts +10 -0
  124. package/dist/promise/timeout.d.ts +10 -0
  125. package/dist/promise/timeout.js +92 -0
  126. package/dist/promise/timeout.js.map +1 -0
  127. package/dist/promise/timeout.mjs +11 -0
  128. package/dist/promise/withTimeout.d.mts +22 -0
  129. package/dist/promise/withTimeout.d.ts +22 -0
  130. package/dist/promise/withTimeout.js +99 -0
  131. package/dist/promise/withTimeout.js.map +1 -0
  132. package/dist/promise/withTimeout.mjs +12 -0
  133. package/dist/promise/withTimeout.mjs.map +1 -0
  134. package/dist/string/camelCase.mjs +1 -1
  135. package/dist/string/capitalize.mjs +1 -1
  136. package/dist/string/index.d.mts +0 -2
  137. package/dist/string/index.d.ts +0 -2
  138. package/dist/string/index.js +2 -16
  139. package/dist/string/index.js.map +1 -1
  140. package/dist/string/index.mjs +9 -17
  141. package/dist/string/kebabCase.mjs +1 -1
  142. package/dist/string/lowerCase.mjs +1 -1
  143. package/dist/string/snakeCase.mjs +1 -1
  144. package/dist/string/startCase.mjs +1 -1
  145. package/package.json +1 -1
  146. package/dist/chunk-ARZ5BDR6.mjs +0 -1
  147. package/dist/chunk-FZEZH22H.mjs +0 -1
  148. package/dist/chunk-SR5RPVRM.mjs +0 -9
  149. package/dist/chunk-SR5RPVRM.mjs.map +0 -1
  150. package/dist/chunk-YCTGSM4S.mjs +0 -1
  151. package/dist/chunk-ZFRI6VS4.mjs +0 -9
  152. package/dist/chunk-ZFRI6VS4.mjs.map +0 -1
  153. package/dist/string/endsWith.d.mts +0 -20
  154. package/dist/string/endsWith.d.ts +0 -20
  155. package/dist/string/endsWith.js +0 -33
  156. package/dist/string/endsWith.js.map +0 -1
  157. package/dist/string/endsWith.mjs +0 -8
  158. package/dist/string/startsWith.d.mts +0 -20
  159. package/dist/string/startsWith.d.ts +0 -20
  160. package/dist/string/startsWith.js.map +0 -1
  161. package/dist/string/startsWith.mjs +0 -8
  162. /package/dist/{chunk-2MM5EJJX.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
  163. /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
  164. /package/dist/{chunk-FZEZH22H.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
  165. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
  166. /package/dist/{chunk-YCTGSM4S.mjs.map → chunk-XT74R35S.mjs.map} +0 -0
  167. /package/dist/{string/endsWith.mjs.map → error/TimeoutError.mjs.map} +0 -0
  168. /package/dist/{string/startsWith.mjs.map → promise/timeout.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,30 +1,31 @@
1
1
  import "./chunk-NKLIE2OI.mjs";
2
- import "./chunk-ARZ5BDR6.mjs";
3
- import "./chunk-YCTGSM4S.mjs";
2
+ import "./chunk-4OIZM4HS.mjs";
3
+ import {
4
+ withTimeout
5
+ } from "./chunk-XWPCDIFC.mjs";
6
+ import "./chunk-J3GE7DEU.mjs";
7
+ import {
8
+ delay
9
+ } from "./chunk-O64NE2P4.mjs";
10
+ import "./chunk-XT74R35S.mjs";
11
+ import {
12
+ lowerCase
13
+ } from "./chunk-5IKVJGHO.mjs";
14
+ import {
15
+ snakeCase
16
+ } from "./chunk-F3WCQQET.mjs";
4
17
  import {
5
18
  startCase
6
19
  } from "./chunk-QXTNZR7B.mjs";
7
- import {
8
- startsWith
9
- } from "./chunk-SR5RPVRM.mjs";
10
20
  import {
11
21
  camelCase
12
22
  } from "./chunk-Y5V7UAZZ.mjs";
13
23
  import {
14
24
  capitalize
15
25
  } from "./chunk-U56ZOM7L.mjs";
16
- import {
17
- endsWith
18
- } from "./chunk-ZFRI6VS4.mjs";
19
26
  import {
20
27
  kebabCase
21
28
  } from "./chunk-EYYZQFOP.mjs";
22
- import {
23
- lowerCase
24
- } from "./chunk-5IKVJGHO.mjs";
25
- import {
26
- snakeCase
27
- } from "./chunk-F3WCQQET.mjs";
28
29
  import "./chunk-WVQ7YVRK.mjs";
29
30
  import "./chunk-ASJF5D6C.mjs";
30
31
  import {
@@ -42,10 +43,10 @@ import {
42
43
  import {
43
44
  isUndefined
44
45
  } from "./chunk-VH2PV426.mjs";
45
- import {
46
- delay
47
- } from "./chunk-O64NE2P4.mjs";
48
46
  import "./chunk-54TK5BIS.mjs";
47
+ import {
48
+ pick
49
+ } from "./chunk-HPFDYUGP.mjs";
49
50
  import {
50
51
  pickBy
51
52
  } from "./chunk-6CLH5YZ2.mjs";
@@ -60,39 +61,39 @@ import {
60
61
  } from "./chunk-OLX53VEF.mjs";
61
62
  import {
62
63
  omit
63
- } from "./chunk-QZITBKWX.mjs";
64
+ } from "./chunk-U7V3G7CR.mjs";
64
65
  import {
65
66
  omitBy
66
67
  } from "./chunk-BCTYOXT7.mjs";
67
- import {
68
- pick
69
- } from "./chunk-HPFDYUGP.mjs";
70
68
  import "./chunk-FUS75PJ7.mjs";
71
69
  import {
72
70
  sumBy
73
71
  } from "./chunk-5L4VWRFX.mjs";
72
+ import {
73
+ inRange
74
+ } from "./chunk-BH6HLGBA.mjs";
74
75
  import {
75
76
  meanBy
76
77
  } from "./chunk-MY4G7R3I.mjs";
77
78
  import {
78
79
  mean
79
80
  } from "./chunk-5ASRKEB4.mjs";
81
+ import {
82
+ sum
83
+ } from "./chunk-2SLTL4KL.mjs";
80
84
  import {
81
85
  range
82
86
  } from "./chunk-DPH2KE6O.mjs";
83
87
  import {
84
88
  round
85
89
  } from "./chunk-5PMKOZ2F.mjs";
86
- import {
87
- sum
88
- } from "./chunk-2SLTL4KL.mjs";
89
90
  import {
90
91
  clamp
91
92
  } from "./chunk-MLCL773E.mjs";
92
- import {
93
- inRange
94
- } from "./chunk-BH6HLGBA.mjs";
95
93
  import "./chunk-DDH7K4QM.mjs";
94
+ import {
95
+ without
96
+ } from "./chunk-PYEYV7BY.mjs";
96
97
  import {
97
98
  xor
98
99
  } from "./chunk-L7FQX5MN.mjs";
@@ -111,12 +112,18 @@ import {
111
112
  import {
112
113
  zipWith
113
114
  } from "./chunk-4KYXHZ4R.mjs";
115
+ import {
116
+ union
117
+ } from "./chunk-R6QA7PLZ.mjs";
114
118
  import {
115
119
  unionBy
116
120
  } from "./chunk-NFS7RWWE.mjs";
117
121
  import {
118
122
  unionWith
119
123
  } from "./chunk-2ZCITDMK.mjs";
124
+ import {
125
+ uniq
126
+ } from "./chunk-DVK2N4KC.mjs";
120
127
  import {
121
128
  uniqBy
122
129
  } from "./chunk-B4COTK4K.mjs";
@@ -130,8 +137,14 @@ import {
130
137
  unzipWith
131
138
  } from "./chunk-IFNXROZR.mjs";
132
139
  import {
133
- without
134
- } from "./chunk-PYEYV7BY.mjs";
140
+ sampleSize
141
+ } from "./chunk-EHSKB6DF.mjs";
142
+ import {
143
+ randomInt
144
+ } from "./chunk-GIWAOOFY.mjs";
145
+ import {
146
+ random
147
+ } from "./chunk-SYWMYQYJ.mjs";
135
148
  import {
136
149
  shuffle
137
150
  } from "./chunk-G7UQ5PUR.mjs";
@@ -154,11 +167,8 @@ import {
154
167
  toFilled
155
168
  } from "./chunk-OP4OAKQJ.mjs";
156
169
  import {
157
- union
158
- } from "./chunk-R6QA7PLZ.mjs";
159
- import {
160
- uniq
161
- } from "./chunk-DVK2N4KC.mjs";
170
+ intersectionWith
171
+ } from "./chunk-XI7KRD2C.mjs";
162
172
  import {
163
173
  keyBy
164
174
  } from "./chunk-AJKZMN2V.mjs";
@@ -181,14 +191,8 @@ import {
181
191
  sample
182
192
  } from "./chunk-2KNLZB7V.mjs";
183
193
  import {
184
- sampleSize
185
- } from "./chunk-EHSKB6DF.mjs";
186
- import {
187
- randomInt
188
- } from "./chunk-GIWAOOFY.mjs";
189
- import {
190
- random
191
- } from "./chunk-SYWMYQYJ.mjs";
194
+ flattenDeep
195
+ } from "./chunk-ML727RRJ.mjs";
192
196
  import {
193
197
  forEachRight
194
198
  } from "./chunk-IEA53J7P.mjs";
@@ -208,8 +212,8 @@ import {
208
212
  intersectionBy
209
213
  } from "./chunk-O6UXZR3U.mjs";
210
214
  import {
211
- intersectionWith
212
- } from "./chunk-XI7KRD2C.mjs";
215
+ differenceWith
216
+ } from "./chunk-6NVQAHXP.mjs";
213
217
  import {
214
218
  drop
215
219
  } from "./chunk-S3CORED5.mjs";
@@ -228,9 +232,6 @@ import {
228
232
  import {
229
233
  flatMap
230
234
  } from "./chunk-UY76KTPE.mjs";
231
- import {
232
- flattenDeep
233
- } from "./chunk-ML727RRJ.mjs";
234
235
  import {
235
236
  flatten
236
237
  } from "./chunk-33MSBDC6.mjs";
@@ -249,14 +250,17 @@ import {
249
250
  import {
250
251
  differenceBy
251
252
  } from "./chunk-LVWX5B43.mjs";
252
- import {
253
- differenceWith
254
- } from "./chunk-6NVQAHXP.mjs";
255
- import "./chunk-FZEZH22H.mjs";
253
+ import "./chunk-F47GLYUU.mjs";
256
254
  import {
257
255
  AbortError
258
256
  } from "./chunk-DXB7EZUQ.mjs";
257
+ import {
258
+ TimeoutError
259
+ } from "./chunk-KIOYQRMQ.mjs";
259
260
  import "./chunk-236H5JZJ.mjs";
261
+ import {
262
+ noop
263
+ } from "./chunk-LKXCOLNY.mjs";
260
264
  import {
261
265
  once
262
266
  } from "./chunk-CMBC4MXG.mjs";
@@ -269,12 +273,10 @@ import {
269
273
  import {
270
274
  negate
271
275
  } from "./chunk-BOOQBJN2.mjs";
272
- import {
273
- noop
274
- } from "./chunk-LKXCOLNY.mjs";
275
- import "./chunk-2MM5EJJX.mjs";
276
+ import "./chunk-424M7IR7.mjs";
276
277
  export {
277
278
  AbortError,
279
+ TimeoutError,
278
280
  camelCase,
279
281
  capitalize,
280
282
  chunk,
@@ -291,7 +293,6 @@ export {
291
293
  dropRight,
292
294
  dropRightWhile,
293
295
  dropWhile,
294
- endsWith,
295
296
  fill,
296
297
  flatMap,
297
298
  flatten,
@@ -337,7 +338,6 @@ export {
337
338
  shuffle,
338
339
  snakeCase,
339
340
  startCase,
340
- startsWith,
341
341
  sum,
342
342
  sumBy,
343
343
  tail,
@@ -355,6 +355,7 @@ export {
355
355
  uniqWith,
356
356
  unzip,
357
357
  unzipWith,
358
+ withTimeout,
358
359
  without,
359
360
  xor,
360
361
  xorBy,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  clamp
3
3
  } from "../chunk-MLCL773E.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  clamp
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  inRange
3
3
  } from "../chunk-BH6HLGBA.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  inRange
7
7
  };
@@ -2,34 +2,34 @@ import "../chunk-FUS75PJ7.mjs";
2
2
  import {
3
3
  sumBy
4
4
  } from "../chunk-5L4VWRFX.mjs";
5
+ import {
6
+ inRange
7
+ } from "../chunk-BH6HLGBA.mjs";
5
8
  import {
6
9
  meanBy
7
10
  } from "../chunk-MY4G7R3I.mjs";
8
11
  import {
9
12
  mean
10
13
  } from "../chunk-5ASRKEB4.mjs";
14
+ import {
15
+ sum
16
+ } from "../chunk-2SLTL4KL.mjs";
11
17
  import {
12
18
  range
13
19
  } from "../chunk-DPH2KE6O.mjs";
14
20
  import {
15
21
  round
16
22
  } from "../chunk-5PMKOZ2F.mjs";
17
- import {
18
- sum
19
- } from "../chunk-2SLTL4KL.mjs";
20
23
  import {
21
24
  clamp
22
25
  } from "../chunk-MLCL773E.mjs";
23
- import {
24
- inRange
25
- } from "../chunk-BH6HLGBA.mjs";
26
26
  import {
27
27
  randomInt
28
28
  } from "../chunk-GIWAOOFY.mjs";
29
29
  import {
30
30
  random
31
31
  } from "../chunk-SYWMYQYJ.mjs";
32
- import "../chunk-2MM5EJJX.mjs";
32
+ import "../chunk-424M7IR7.mjs";
33
33
  export {
34
34
  clamp,
35
35
  inRange,
@@ -2,7 +2,7 @@ import {
2
2
  mean
3
3
  } from "../chunk-5ASRKEB4.mjs";
4
4
  import "../chunk-2SLTL4KL.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
6
  export {
7
7
  mean
8
8
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-MY4G7R3I.mjs";
4
4
  import "../chunk-5ASRKEB4.mjs";
5
5
  import "../chunk-2SLTL4KL.mjs";
6
- import "../chunk-2MM5EJJX.mjs";
6
+ import "../chunk-424M7IR7.mjs";
7
7
  export {
8
8
  meanBy
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  random
3
3
  } from "../chunk-SYWMYQYJ.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  random
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  randomInt
3
3
  } from "../chunk-GIWAOOFY.mjs";
4
4
  import "../chunk-SYWMYQYJ.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
6
  export {
7
7
  randomInt
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  range
3
3
  } from "../chunk-DPH2KE6O.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  range
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  round
3
3
  } from "../chunk-5PMKOZ2F.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  round
7
7
  };
package/dist/math/sum.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  sum
3
3
  } from "../chunk-2SLTL4KL.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  sum
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  sumBy
3
3
  } from "../chunk-5L4VWRFX.mjs";
4
4
  import "../chunk-2SLTL4KL.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
6
  export {
7
7
  sumBy
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  clone
3
3
  } from "../chunk-U4JGKZ56.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  clone
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  get
3
3
  } from "../chunk-4RQPJUPQ.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  get
7
7
  };
@@ -1,4 +1,7 @@
1
1
  import "../chunk-54TK5BIS.mjs";
2
+ import {
3
+ pick
4
+ } from "../chunk-HPFDYUGP.mjs";
2
5
  import {
3
6
  pickBy
4
7
  } from "../chunk-6CLH5YZ2.mjs";
@@ -13,14 +16,11 @@ import {
13
16
  } from "../chunk-OLX53VEF.mjs";
14
17
  import {
15
18
  omit
16
- } from "../chunk-QZITBKWX.mjs";
19
+ } from "../chunk-U7V3G7CR.mjs";
17
20
  import {
18
21
  omitBy
19
22
  } from "../chunk-BCTYOXT7.mjs";
20
- import {
21
- pick
22
- } from "../chunk-HPFDYUGP.mjs";
23
- import "../chunk-2MM5EJJX.mjs";
23
+ import "../chunk-424M7IR7.mjs";
24
24
  export {
25
25
  clone,
26
26
  get,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  invert
3
3
  } from "../chunk-OLX53VEF.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  invert
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  omit
3
- } from "../chunk-QZITBKWX.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
3
+ } from "../chunk-U7V3G7CR.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  omit
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  omitBy
3
3
  } from "../chunk-BCTYOXT7.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  omitBy
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  pick
3
3
  } from "../chunk-HPFDYUGP.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  pick
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  pickBy
3
3
  } from "../chunk-6CLH5YZ2.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  pickBy
7
7
  };
@@ -16,7 +16,7 @@ import {
16
16
  } from "../chunk-VH2PV426.mjs";
17
17
  import "../chunk-R6QA7PLZ.mjs";
18
18
  import "../chunk-DVK2N4KC.mjs";
19
- import "../chunk-2MM5EJJX.mjs";
19
+ import "../chunk-424M7IR7.mjs";
20
20
  export {
21
21
  isEqual,
22
22
  isNil,
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-JYSV56US.mjs";
4
4
  import "../chunk-R6QA7PLZ.mjs";
5
5
  import "../chunk-DVK2N4KC.mjs";
6
- import "../chunk-2MM5EJJX.mjs";
6
+ import "../chunk-424M7IR7.mjs";
7
7
  export {
8
8
  isEqual
9
9
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNil
3
3
  } from "../chunk-WMM7TZLG.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  isNil
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNotNil
3
3
  } from "../chunk-BMRTZMRE.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  isNotNil
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isNull
3
3
  } from "../chunk-AIRSKN47.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  isNull
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isUndefined
3
3
  } from "../chunk-VH2PV426.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  isUndefined
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  delay
3
3
  } from "../chunk-O64NE2P4.mjs";
4
4
  import "../chunk-DXB7EZUQ.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
6
  export {
7
7
  delay
8
8
  };
@@ -1 +1,2 @@
1
1
  export { delay } from './delay.mjs';
2
+ export { withTimeout } from './withTimeout.mjs';
@@ -1 +1,2 @@
1
1
  export { delay } from './delay.js';
2
+ export { withTimeout } from './withTimeout.js';
@@ -16,11 +16,32 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __async = (__this, __arguments, generator) => {
20
+ return new Promise((resolve, reject) => {
21
+ var fulfilled = (value) => {
22
+ try {
23
+ step(generator.next(value));
24
+ } catch (e) {
25
+ reject(e);
26
+ }
27
+ };
28
+ var rejected = (value) => {
29
+ try {
30
+ step(generator.throw(value));
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ };
35
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
36
+ step((generator = generator.apply(__this, __arguments)).next());
37
+ });
38
+ };
19
39
 
20
40
  // src/promise/index.ts
21
41
  var promise_exports = {};
22
42
  __export(promise_exports, {
23
- delay: () => delay
43
+ delay: () => delay,
44
+ withTimeout: () => withTimeout
24
45
  });
25
46
  module.exports = __toCommonJS(promise_exports);
26
47
 
@@ -49,8 +70,32 @@ function delay(ms, { signal } = {}) {
49
70
  signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
50
71
  });
51
72
  }
73
+
74
+ // src/error/TimeoutError.ts
75
+ var TimeoutError = class extends Error {
76
+ constructor(message = "The operation was timed out") {
77
+ super(message);
78
+ this.name = "TimeoutError";
79
+ }
80
+ };
81
+
82
+ // src/promise/timeout.ts
83
+ function timeout(ms) {
84
+ return __async(this, null, function* () {
85
+ yield delay(ms);
86
+ throw new TimeoutError();
87
+ });
88
+ }
89
+
90
+ // src/promise/withTimeout.ts
91
+ function withTimeout(run, ms) {
92
+ return __async(this, null, function* () {
93
+ return Promise.race([run(), timeout(ms)]);
94
+ });
95
+ }
52
96
  // Annotate the CommonJS export names for ESM import in node:
53
97
  0 && (module.exports = {
54
- delay
98
+ delay,
99
+ withTimeout
55
100
  });
56
101
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/promise/index.ts","../../src/error/AbortError.ts","../../src/promise/delay.ts"],"sourcesContent":["export { delay } from './delay.ts';\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AC6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,iCAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,qCAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK;AAAA,EAC/D,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/promise/index.ts","../../src/error/AbortError.ts","../../src/promise/delay.ts","../../src/error/TimeoutError.ts","../../src/promise/timeout.ts","../../src/promise/withTimeout.ts"],"sourcesContent":["export { delay } from './delay.ts';\nexport { withTimeout } from './withTimeout.ts';\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n","import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n","import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YAAY,UAAU,6BAA6B;AACjD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;AC6BO,SAAS,MAAM,IAAY,EAAE,OAAO,IAAkB,CAAC,GAAkB;AAC9E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,aAAa,MAAM;AACvB,aAAO,IAAI,WAAW,CAAC;AAAA,IACzB;AAEA,UAAM,eAAe,MAAM;AACzB,mBAAa,SAAS;AACtB,iBAAW;AAAA,IACb;AAEA,QAAI,iCAAQ,SAAS;AACnB,aAAO,WAAW;AAAA,IACpB;AAEA,UAAM,YAAY,WAAW,SAAS,EAAE;AAExC,qCAAQ,iBAAiB,SAAS,cAAc,EAAE,MAAM,KAAK;AAAA,EAC/D,CAAC;AACH;;;ACrDO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACCA,SAAsB,QAAQ,IAA4B;AAAA;AACxD,UAAM,MAAM,EAAE;AACd,UAAM,IAAI,aAAa;AAAA,EACzB;AAAA;;;ACQA,SAAsB,YAAe,KAAuB,IAAwB;AAAA;AAClF,WAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAM,CAAC;AAAA,EAC/C;AAAA;","names":[]}
@@ -1,10 +1,16 @@
1
- import "../chunk-ARZ5BDR6.mjs";
1
+ import "../chunk-4OIZM4HS.mjs";
2
+ import {
3
+ withTimeout
4
+ } from "../chunk-XWPCDIFC.mjs";
5
+ import "../chunk-J3GE7DEU.mjs";
2
6
  import {
3
7
  delay
4
8
  } from "../chunk-O64NE2P4.mjs";
5
9
  import "../chunk-DXB7EZUQ.mjs";
6
- import "../chunk-2MM5EJJX.mjs";
10
+ import "../chunk-KIOYQRMQ.mjs";
11
+ import "../chunk-424M7IR7.mjs";
7
12
  export {
8
- delay
13
+ delay,
14
+ withTimeout
9
15
  };
10
16
  //# sourceMappingURL=index.mjs.map