es-toolkit 1.10.1-dev.251 → 1.10.1-dev.253

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 (148) 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-XWPCDIFC.mjs +18 -0
  62. package/dist/chunk-XWPCDIFC.mjs.map +1 -0
  63. package/dist/compat/index.d.mts +2 -0
  64. package/dist/compat/index.d.ts +2 -0
  65. package/dist/compat/index.js +47 -0
  66. package/dist/compat/index.js.map +1 -1
  67. package/dist/compat/index.mjs +59 -50
  68. package/dist/compat/index.mjs.map +1 -1
  69. package/dist/error/AbortError.mjs +1 -1
  70. package/dist/error/TimeoutError.d.mts +9 -0
  71. package/dist/error/TimeoutError.d.ts +9 -0
  72. package/dist/error/TimeoutError.js +36 -0
  73. package/dist/error/TimeoutError.js.map +1 -0
  74. package/dist/error/TimeoutError.mjs +8 -0
  75. package/dist/error/TimeoutError.mjs.map +1 -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 -0
  88. package/dist/index.d.ts +2 -0
  89. package/dist/index.js +47 -0
  90. package/dist/index.js.map +1 -1
  91. package/dist/index.mjs +59 -50
  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/timeout.mjs.map +1 -0
  129. package/dist/promise/withTimeout.d.mts +22 -0
  130. package/dist/promise/withTimeout.d.ts +22 -0
  131. package/dist/promise/withTimeout.js +99 -0
  132. package/dist/promise/withTimeout.js.map +1 -0
  133. package/dist/promise/withTimeout.mjs +12 -0
  134. package/dist/promise/withTimeout.mjs.map +1 -0
  135. package/dist/string/camelCase.mjs +1 -1
  136. package/dist/string/capitalize.mjs +1 -1
  137. package/dist/string/index.mjs +10 -10
  138. package/dist/string/kebabCase.mjs +1 -1
  139. package/dist/string/lowerCase.mjs +1 -1
  140. package/dist/string/snakeCase.mjs +1 -1
  141. package/dist/string/startCase.mjs +1 -1
  142. package/package.json +1 -1
  143. package/dist/chunk-ARZ5BDR6.mjs +0 -1
  144. package/dist/chunk-FZEZH22H.mjs +0 -1
  145. /package/dist/{chunk-2MM5EJJX.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
  146. /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
  147. /package/dist/{chunk-FZEZH22H.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
  148. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,15 +1,13 @@
1
1
  import "./chunk-NKLIE2OI.mjs";
2
- import "./chunk-ARZ5BDR6.mjs";
3
- import "./chunk-XT74R35S.mjs";
4
- import {
5
- camelCase
6
- } from "./chunk-Y5V7UAZZ.mjs";
2
+ import "./chunk-4OIZM4HS.mjs";
7
3
  import {
8
- capitalize
9
- } from "./chunk-U56ZOM7L.mjs";
4
+ withTimeout
5
+ } from "./chunk-XWPCDIFC.mjs";
6
+ import "./chunk-J3GE7DEU.mjs";
10
7
  import {
11
- kebabCase
12
- } from "./chunk-EYYZQFOP.mjs";
8
+ delay
9
+ } from "./chunk-O64NE2P4.mjs";
10
+ import "./chunk-XT74R35S.mjs";
13
11
  import {
14
12
  lowerCase
15
13
  } from "./chunk-5IKVJGHO.mjs";
@@ -19,6 +17,15 @@ import {
19
17
  import {
20
18
  startCase
21
19
  } from "./chunk-QXTNZR7B.mjs";
20
+ import {
21
+ camelCase
22
+ } from "./chunk-Y5V7UAZZ.mjs";
23
+ import {
24
+ capitalize
25
+ } from "./chunk-U56ZOM7L.mjs";
26
+ import {
27
+ kebabCase
28
+ } from "./chunk-EYYZQFOP.mjs";
22
29
  import "./chunk-WVQ7YVRK.mjs";
23
30
  import "./chunk-ASJF5D6C.mjs";
24
31
  import {
@@ -36,10 +43,10 @@ import {
36
43
  import {
37
44
  isUndefined
38
45
  } from "./chunk-VH2PV426.mjs";
39
- import {
40
- delay
41
- } from "./chunk-O64NE2P4.mjs";
42
46
  import "./chunk-54TK5BIS.mjs";
47
+ import {
48
+ pick
49
+ } from "./chunk-HPFDYUGP.mjs";
43
50
  import {
44
51
  pickBy
45
52
  } from "./chunk-6CLH5YZ2.mjs";
@@ -54,39 +61,39 @@ import {
54
61
  } from "./chunk-OLX53VEF.mjs";
55
62
  import {
56
63
  omit
57
- } from "./chunk-QZITBKWX.mjs";
64
+ } from "./chunk-U7V3G7CR.mjs";
58
65
  import {
59
66
  omitBy
60
67
  } from "./chunk-BCTYOXT7.mjs";
61
- import {
62
- pick
63
- } from "./chunk-HPFDYUGP.mjs";
64
68
  import "./chunk-FUS75PJ7.mjs";
65
69
  import {
66
70
  sumBy
67
71
  } from "./chunk-5L4VWRFX.mjs";
72
+ import {
73
+ inRange
74
+ } from "./chunk-BH6HLGBA.mjs";
68
75
  import {
69
76
  meanBy
70
77
  } from "./chunk-MY4G7R3I.mjs";
71
78
  import {
72
79
  mean
73
80
  } from "./chunk-5ASRKEB4.mjs";
81
+ import {
82
+ sum
83
+ } from "./chunk-2SLTL4KL.mjs";
74
84
  import {
75
85
  range
76
86
  } from "./chunk-DPH2KE6O.mjs";
77
87
  import {
78
88
  round
79
89
  } from "./chunk-5PMKOZ2F.mjs";
80
- import {
81
- sum
82
- } from "./chunk-2SLTL4KL.mjs";
83
90
  import {
84
91
  clamp
85
92
  } from "./chunk-MLCL773E.mjs";
86
- import {
87
- inRange
88
- } from "./chunk-BH6HLGBA.mjs";
89
93
  import "./chunk-DDH7K4QM.mjs";
94
+ import {
95
+ without
96
+ } from "./chunk-PYEYV7BY.mjs";
90
97
  import {
91
98
  xor
92
99
  } from "./chunk-L7FQX5MN.mjs";
@@ -105,12 +112,18 @@ import {
105
112
  import {
106
113
  zipWith
107
114
  } from "./chunk-4KYXHZ4R.mjs";
115
+ import {
116
+ union
117
+ } from "./chunk-R6QA7PLZ.mjs";
108
118
  import {
109
119
  unionBy
110
120
  } from "./chunk-NFS7RWWE.mjs";
111
121
  import {
112
122
  unionWith
113
123
  } from "./chunk-2ZCITDMK.mjs";
124
+ import {
125
+ uniq
126
+ } from "./chunk-DVK2N4KC.mjs";
114
127
  import {
115
128
  uniqBy
116
129
  } from "./chunk-B4COTK4K.mjs";
@@ -124,8 +137,14 @@ import {
124
137
  unzipWith
125
138
  } from "./chunk-IFNXROZR.mjs";
126
139
  import {
127
- without
128
- } 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";
129
148
  import {
130
149
  shuffle
131
150
  } from "./chunk-G7UQ5PUR.mjs";
@@ -148,11 +167,8 @@ import {
148
167
  toFilled
149
168
  } from "./chunk-OP4OAKQJ.mjs";
150
169
  import {
151
- union
152
- } from "./chunk-R6QA7PLZ.mjs";
153
- import {
154
- uniq
155
- } from "./chunk-DVK2N4KC.mjs";
170
+ intersectionWith
171
+ } from "./chunk-XI7KRD2C.mjs";
156
172
  import {
157
173
  keyBy
158
174
  } from "./chunk-AJKZMN2V.mjs";
@@ -175,14 +191,8 @@ import {
175
191
  sample
176
192
  } from "./chunk-2KNLZB7V.mjs";
177
193
  import {
178
- sampleSize
179
- } from "./chunk-EHSKB6DF.mjs";
180
- import {
181
- randomInt
182
- } from "./chunk-GIWAOOFY.mjs";
183
- import {
184
- random
185
- } from "./chunk-SYWMYQYJ.mjs";
194
+ flattenDeep
195
+ } from "./chunk-ML727RRJ.mjs";
186
196
  import {
187
197
  forEachRight
188
198
  } from "./chunk-IEA53J7P.mjs";
@@ -202,8 +212,8 @@ import {
202
212
  intersectionBy
203
213
  } from "./chunk-O6UXZR3U.mjs";
204
214
  import {
205
- intersectionWith
206
- } from "./chunk-XI7KRD2C.mjs";
215
+ differenceWith
216
+ } from "./chunk-6NVQAHXP.mjs";
207
217
  import {
208
218
  drop
209
219
  } from "./chunk-S3CORED5.mjs";
@@ -222,9 +232,6 @@ import {
222
232
  import {
223
233
  flatMap
224
234
  } from "./chunk-UY76KTPE.mjs";
225
- import {
226
- flattenDeep
227
- } from "./chunk-ML727RRJ.mjs";
228
235
  import {
229
236
  flatten
230
237
  } from "./chunk-33MSBDC6.mjs";
@@ -243,14 +250,17 @@ import {
243
250
  import {
244
251
  differenceBy
245
252
  } from "./chunk-LVWX5B43.mjs";
246
- import {
247
- differenceWith
248
- } from "./chunk-6NVQAHXP.mjs";
249
- import "./chunk-FZEZH22H.mjs";
253
+ import "./chunk-F47GLYUU.mjs";
250
254
  import {
251
255
  AbortError
252
256
  } from "./chunk-DXB7EZUQ.mjs";
257
+ import {
258
+ TimeoutError
259
+ } from "./chunk-KIOYQRMQ.mjs";
253
260
  import "./chunk-236H5JZJ.mjs";
261
+ import {
262
+ noop
263
+ } from "./chunk-LKXCOLNY.mjs";
254
264
  import {
255
265
  once
256
266
  } from "./chunk-CMBC4MXG.mjs";
@@ -263,12 +273,10 @@ import {
263
273
  import {
264
274
  negate
265
275
  } from "./chunk-BOOQBJN2.mjs";
266
- import {
267
- noop
268
- } from "./chunk-LKXCOLNY.mjs";
269
- import "./chunk-2MM5EJJX.mjs";
276
+ import "./chunk-424M7IR7.mjs";
270
277
  export {
271
278
  AbortError,
279
+ TimeoutError,
272
280
  camelCase,
273
281
  capitalize,
274
282
  chunk,
@@ -347,6 +355,7 @@ export {
347
355
  uniqWith,
348
356
  unzip,
349
357
  unzipWith,
358
+ withTimeout,
350
359
  without,
351
360
  xor,
352
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
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns a promise that rejects with a `TimeoutError` after a specified delay.
3
+ *
4
+ * @param {number} ms - The delay duration in milliseconds.
5
+ * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.
6
+ * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.
7
+ */
8
+ declare function timeout(ms: number): Promise<never>;
9
+
10
+ export { timeout };