es-toolkit 1.10.1 → 1.11.0-dev.263

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 (220) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/compat.d.ts +1 -0
  3. package/dist/array/chunk.mjs +1 -1
  4. package/dist/array/compact.mjs +1 -1
  5. package/dist/array/countBy.mjs +1 -1
  6. package/dist/array/difference.mjs +1 -1
  7. package/dist/array/differenceBy.mjs +1 -1
  8. package/dist/array/differenceWith.mjs +1 -1
  9. package/dist/array/drop.js +1 -0
  10. package/dist/array/drop.js.map +1 -1
  11. package/dist/array/drop.mjs +2 -2
  12. package/dist/array/dropRight.js +5 -1
  13. package/dist/array/dropRight.js.map +1 -1
  14. package/dist/array/dropRight.mjs +2 -2
  15. package/dist/array/dropRightWhile.js +6 -14
  16. package/dist/array/dropRightWhile.js.map +1 -1
  17. package/dist/array/dropRightWhile.mjs +2 -3
  18. package/dist/array/dropWhile.mjs +1 -1
  19. package/dist/array/fill.d.mts +10 -7
  20. package/dist/array/fill.d.ts +10 -7
  21. package/dist/array/fill.js +7 -6
  22. package/dist/array/fill.js.map +1 -1
  23. package/dist/array/fill.mjs +2 -2
  24. package/dist/array/flatMap.d.mts +23 -0
  25. package/dist/array/flatMap.d.ts +23 -0
  26. package/dist/array/flatMap.js +52 -0
  27. package/dist/array/flatMap.js.map +1 -0
  28. package/dist/array/flatMap.mjs +9 -0
  29. package/dist/array/flatten.mjs +1 -1
  30. package/dist/array/flattenDeep.mjs +1 -1
  31. package/dist/array/forEachRight.mjs +1 -1
  32. package/dist/array/groupBy.mjs +1 -1
  33. package/dist/array/head.mjs +1 -1
  34. package/dist/array/index.d.mts +1 -0
  35. package/dist/array/index.d.ts +1 -0
  36. package/dist/array/index.js +30 -14
  37. package/dist/array/index.js.map +1 -1
  38. package/dist/array/index.mjs +41 -37
  39. package/dist/array/initial.mjs +1 -1
  40. package/dist/array/intersection.mjs +1 -1
  41. package/dist/array/intersectionBy.mjs +1 -1
  42. package/dist/array/intersectionWith.mjs +1 -1
  43. package/dist/array/keyBy.mjs +1 -1
  44. package/dist/array/last.mjs +1 -1
  45. package/dist/array/maxBy.mjs +1 -1
  46. package/dist/array/minBy.mjs +1 -1
  47. package/dist/array/orderBy.mjs +1 -1
  48. package/dist/array/partition.mjs +1 -1
  49. package/dist/array/sample.mjs +1 -1
  50. package/dist/array/sampleSize.mjs +1 -1
  51. package/dist/array/shuffle.mjs +1 -1
  52. package/dist/array/tail.mjs +1 -1
  53. package/dist/array/take.mjs +1 -1
  54. package/dist/array/takeRight.mjs +1 -1
  55. package/dist/array/takeRightWhile.mjs +1 -1
  56. package/dist/array/takeWhile.mjs +1 -1
  57. package/dist/array/toFilled.mjs +1 -1
  58. package/dist/array/union.mjs +1 -1
  59. package/dist/array/unionBy.mjs +1 -1
  60. package/dist/array/unionWith.mjs +1 -1
  61. package/dist/array/uniq.mjs +1 -1
  62. package/dist/array/uniqBy.d.mts +1 -1
  63. package/dist/array/uniqBy.d.ts +1 -1
  64. package/dist/array/uniqBy.js.map +1 -1
  65. package/dist/array/uniqBy.mjs +2 -2
  66. package/dist/array/uniqWith.mjs +1 -1
  67. package/dist/array/unzip.mjs +1 -1
  68. package/dist/array/unzipWith.mjs +1 -1
  69. package/dist/array/without.mjs +1 -1
  70. package/dist/array/xor.mjs +1 -1
  71. package/dist/array/xorBy.mjs +1 -1
  72. package/dist/array/xorWith.mjs +1 -1
  73. package/dist/array/zip.mjs +1 -1
  74. package/dist/array/zipObject.mjs +1 -1
  75. package/dist/array/zipWith.mjs +1 -1
  76. package/dist/{chunk-S3CORED5.mjs → chunk-3EZAFZG3.mjs} +2 -1
  77. package/dist/{chunk-S3CORED5.mjs.map → chunk-3EZAFZG3.mjs.map} +1 -1
  78. package/dist/{chunk-2MM5EJJX.mjs → chunk-424M7IR7.mjs} +23 -2
  79. package/dist/chunk-4OIZM4HS.mjs +1 -0
  80. package/dist/{chunk-GDC64SYJ.mjs → chunk-5ASRKEB4.mjs} +1 -1
  81. package/dist/{chunk-GDC64SYJ.mjs.map → chunk-5ASRKEB4.mjs.map} +1 -1
  82. package/dist/{chunk-OXAZEEGP.mjs → chunk-B4COTK4K.mjs} +1 -1
  83. package/dist/{chunk-OXAZEEGP.mjs.map → chunk-B4COTK4K.mjs.map} +1 -1
  84. package/dist/chunk-DDH7K4QM.mjs +1 -0
  85. package/dist/chunk-F47GLYUU.mjs +1 -0
  86. package/dist/chunk-J3GE7DEU.mjs +22 -0
  87. package/dist/chunk-J3GE7DEU.mjs.map +1 -0
  88. package/dist/chunk-KIOYQRMQ.mjs +12 -0
  89. package/dist/chunk-KIOYQRMQ.mjs.map +1 -0
  90. package/dist/chunk-M7SBBYV2.mjs +14 -0
  91. package/dist/chunk-M7SBBYV2.mjs.map +1 -0
  92. package/dist/{chunk-IZAD2S7R.mjs → chunk-MY4G7R3I.mjs} +2 -2
  93. package/dist/{chunk-74WWMNZS.mjs → chunk-OLX53VEF.mjs} +4 -2
  94. package/dist/{chunk-74WWMNZS.mjs.map → chunk-OLX53VEF.mjs.map} +1 -1
  95. package/dist/chunk-OXZCMC5I.mjs +13 -0
  96. package/dist/{chunk-JEKUA56R.mjs.map → chunk-OXZCMC5I.mjs.map} +1 -1
  97. package/dist/chunk-QXTNZR7B.mjs +25 -0
  98. package/dist/chunk-QXTNZR7B.mjs.map +1 -0
  99. package/dist/{chunk-QZITBKWX.mjs → chunk-U7V3G7CR.mjs} +2 -2
  100. package/dist/chunk-UY76KTPE.mjs +13 -0
  101. package/dist/chunk-UY76KTPE.mjs.map +1 -0
  102. package/dist/chunk-XT74R35S.mjs +1 -0
  103. package/dist/chunk-XT74R35S.mjs.map +1 -0
  104. package/dist/chunk-XWPCDIFC.mjs +18 -0
  105. package/dist/chunk-XWPCDIFC.mjs.map +1 -0
  106. package/dist/chunk-YFN6KOC4.mjs +15 -0
  107. package/dist/chunk-YFN6KOC4.mjs.map +1 -0
  108. package/dist/compat/index.d.mts +392 -1
  109. package/dist/compat/index.d.ts +392 -1
  110. package/dist/compat/index.js +276 -21
  111. package/dist/compat/index.js.map +1 -1
  112. package/dist/compat/index.mjs +268 -87
  113. package/dist/compat/index.mjs.map +1 -1
  114. package/dist/error/AbortError.mjs +1 -1
  115. package/dist/error/TimeoutError.d.mts +9 -0
  116. package/dist/error/TimeoutError.d.ts +9 -0
  117. package/dist/error/TimeoutError.js +36 -0
  118. package/dist/error/TimeoutError.js.map +1 -0
  119. package/dist/error/TimeoutError.mjs +8 -0
  120. package/dist/error/TimeoutError.mjs.map +1 -0
  121. package/dist/error/index.d.mts +1 -0
  122. package/dist/error/index.d.ts +1 -0
  123. package/dist/error/index.js +12 -2
  124. package/dist/error/index.js.map +1 -1
  125. package/dist/error/index.mjs +7 -3
  126. package/dist/function/debounce.mjs +1 -1
  127. package/dist/function/index.mjs +7 -7
  128. package/dist/function/negate.mjs +1 -1
  129. package/dist/function/noop.mjs +1 -1
  130. package/dist/function/once.mjs +1 -1
  131. package/dist/function/throttle.mjs +1 -1
  132. package/dist/index.d.mts +4 -0
  133. package/dist/index.d.ts +4 -0
  134. package/dist/index.js +99 -15
  135. package/dist/index.js.map +1 -1
  136. package/dist/index.mjs +104 -87
  137. package/dist/math/clamp.mjs +1 -1
  138. package/dist/math/inRange.mjs +1 -1
  139. package/dist/math/index.js.map +1 -1
  140. package/dist/math/index.mjs +12 -12
  141. package/dist/math/mean.d.mts +1 -1
  142. package/dist/math/mean.d.ts +1 -1
  143. package/dist/math/mean.js.map +1 -1
  144. package/dist/math/mean.mjs +2 -2
  145. package/dist/math/meanBy.js.map +1 -1
  146. package/dist/math/meanBy.mjs +3 -3
  147. package/dist/math/random.mjs +1 -1
  148. package/dist/math/randomInt.mjs +1 -1
  149. package/dist/math/range.mjs +1 -1
  150. package/dist/math/round.mjs +1 -1
  151. package/dist/math/sum.mjs +1 -1
  152. package/dist/math/sumBy.mjs +1 -1
  153. package/dist/object/clone.mjs +1 -1
  154. package/dist/object/index.js +3 -1
  155. package/dist/object/index.js.map +1 -1
  156. package/dist/object/index.mjs +6 -6
  157. package/dist/object/invert.js +3 -1
  158. package/dist/object/invert.js.map +1 -1
  159. package/dist/object/invert.mjs +2 -2
  160. package/dist/object/omit.mjs +2 -2
  161. package/dist/object/omitBy.mjs +1 -1
  162. package/dist/object/pick.mjs +1 -1
  163. package/dist/object/pickBy.mjs +1 -1
  164. package/dist/predicate/index.mjs +1 -1
  165. package/dist/predicate/isEqual.mjs +1 -1
  166. package/dist/predicate/isNil.mjs +1 -1
  167. package/dist/predicate/isNotNil.mjs +1 -1
  168. package/dist/predicate/isNull.mjs +1 -1
  169. package/dist/predicate/isUndefined.mjs +1 -1
  170. package/dist/promise/delay.mjs +1 -1
  171. package/dist/promise/index.d.mts +1 -0
  172. package/dist/promise/index.d.ts +1 -0
  173. package/dist/promise/index.js +47 -2
  174. package/dist/promise/index.js.map +1 -1
  175. package/dist/promise/index.mjs +9 -3
  176. package/dist/promise/timeout.d.mts +10 -0
  177. package/dist/promise/timeout.d.ts +10 -0
  178. package/dist/promise/timeout.js +92 -0
  179. package/dist/promise/timeout.js.map +1 -0
  180. package/dist/promise/timeout.mjs +11 -0
  181. package/dist/promise/timeout.mjs.map +1 -0
  182. package/dist/promise/withTimeout.d.mts +22 -0
  183. package/dist/promise/withTimeout.d.ts +22 -0
  184. package/dist/promise/withTimeout.js +99 -0
  185. package/dist/promise/withTimeout.js.map +1 -0
  186. package/dist/promise/withTimeout.mjs +12 -0
  187. package/dist/promise/withTimeout.mjs.map +1 -0
  188. package/dist/string/camelCase.mjs +1 -1
  189. package/dist/string/capitalize.mjs +1 -1
  190. package/dist/string/index.d.mts +1 -0
  191. package/dist/string/index.d.ts +1 -0
  192. package/dist/string/index.js +21 -2
  193. package/dist/string/index.js.map +1 -1
  194. package/dist/string/index.mjs +13 -9
  195. package/dist/string/kebabCase.mjs +1 -1
  196. package/dist/string/lowerCase.mjs +1 -1
  197. package/dist/string/snakeCase.mjs +1 -1
  198. package/dist/string/startCase.d.mts +16 -0
  199. package/dist/string/startCase.d.ts +16 -0
  200. package/dist/string/startCase.js +54 -0
  201. package/dist/string/startCase.js.map +1 -0
  202. package/dist/string/startCase.mjs +9 -0
  203. package/dist/string/startCase.mjs.map +1 -0
  204. package/package.json +3 -5
  205. package/dist/chunk-2MRZANXZ.mjs +0 -1
  206. package/dist/chunk-ARZ5BDR6.mjs +0 -1
  207. package/dist/chunk-C4WE4GLC.mjs +0 -14
  208. package/dist/chunk-C4WE4GLC.mjs.map +0 -1
  209. package/dist/chunk-FZEZH22H.mjs +0 -1
  210. package/dist/chunk-JE6JKZU3.mjs +0 -15
  211. package/dist/chunk-JE6JKZU3.mjs.map +0 -1
  212. package/dist/chunk-JEKUA56R.mjs +0 -9
  213. package/dist/chunk-QKYYOLJ6.mjs +0 -1
  214. /package/dist/{chunk-2MM5EJJX.mjs.map → array/flatMap.mjs.map} +0 -0
  215. /package/dist/{chunk-2MRZANXZ.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
  216. /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
  217. /package/dist/{chunk-FZEZH22H.mjs.map → chunk-DDH7K4QM.mjs.map} +0 -0
  218. /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
  219. /package/dist/{chunk-IZAD2S7R.mjs.map → chunk-MY4G7R3I.mjs.map} +0 -0
  220. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/error/index.ts
21
21
  var error_exports = {};
22
22
  __export(error_exports, {
23
- AbortError: () => AbortError
23
+ AbortError: () => AbortError,
24
+ TimeoutError: () => TimeoutError
24
25
  });
25
26
  module.exports = __toCommonJS(error_exports);
26
27
 
@@ -31,8 +32,17 @@ var AbortError = class extends Error {
31
32
  this.name = "AbortError";
32
33
  }
33
34
  };
35
+
36
+ // src/error/TimeoutError.ts
37
+ var TimeoutError = class extends Error {
38
+ constructor(message = "The operation was timed out") {
39
+ super(message);
40
+ this.name = "TimeoutError";
41
+ }
42
+ };
34
43
  // Annotate the CommonJS export names for ESM import in node:
35
44
  0 && (module.exports = {
36
- AbortError
45
+ AbortError,
46
+ TimeoutError
37
47
  });
38
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/index.ts","../../src/error/AbortError.ts"],"sourcesContent":["export { AbortError } from './AbortError.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"],"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;","names":[]}
1
+ {"version":3,"sources":["../../src/error/index.ts","../../src/error/AbortError.ts","../../src/error/TimeoutError.ts"],"sourcesContent":["export { AbortError } from './AbortError.ts';\nexport { TimeoutError } from './TimeoutError.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","/**\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"],"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;;;ACLO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,9 +1,13 @@
1
- import "../chunk-FZEZH22H.mjs";
1
+ import "../chunk-F47GLYUU.mjs";
2
2
  import {
3
3
  AbortError
4
4
  } from "../chunk-DXB7EZUQ.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import {
6
+ TimeoutError
7
+ } from "../chunk-KIOYQRMQ.mjs";
8
+ import "../chunk-424M7IR7.mjs";
6
9
  export {
7
- AbortError
10
+ AbortError,
11
+ TimeoutError
8
12
  };
9
13
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  debounce
3
3
  } from "../chunk-3IP4JVLL.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  debounce
7
7
  };
@@ -1,10 +1,4 @@
1
1
  import "../chunk-236H5JZJ.mjs";
2
- import {
3
- once
4
- } from "../chunk-CMBC4MXG.mjs";
5
- import {
6
- throttle
7
- } from "../chunk-QOJGMVVR.mjs";
8
2
  import {
9
3
  debounce
10
4
  } from "../chunk-3IP4JVLL.mjs";
@@ -14,7 +8,13 @@ import {
14
8
  import {
15
9
  noop
16
10
  } from "../chunk-LKXCOLNY.mjs";
17
- import "../chunk-2MM5EJJX.mjs";
11
+ import {
12
+ once
13
+ } from "../chunk-CMBC4MXG.mjs";
14
+ import {
15
+ throttle
16
+ } from "../chunk-QOJGMVVR.mjs";
17
+ import "../chunk-424M7IR7.mjs";
18
18
  export {
19
19
  debounce,
20
20
  negate,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  negate
3
3
  } from "../chunk-BOOQBJN2.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  negate
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  noop
3
3
  } from "../chunk-LKXCOLNY.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  noop
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  once
3
3
  } from "../chunk-CMBC4MXG.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  once
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  throttle
3
3
  } from "../chunk-QOJGMVVR.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  throttle
7
7
  };
package/dist/index.d.mts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.mjs';
9
9
  export { dropRightWhile } from './array/dropRightWhile.mjs';
10
10
  export { dropWhile } from './array/dropWhile.mjs';
11
11
  export { fill } from './array/fill.mjs';
12
+ export { flatMap } from './array/flatMap.mjs';
12
13
  export { flatten } from './array/flatten.mjs';
13
14
  export { flattenDeep } from './array/flattenDeep.mjs';
14
15
  export { forEachRight } from './array/forEachRight.mjs';
@@ -49,6 +50,7 @@ export { toFilled } from './array/toFilled.mjs';
49
50
  export { last } from './array/last.mjs';
50
51
  export { initial } from './array/initial.mjs';
51
52
  export { AbortError } from './error/AbortError.mjs';
53
+ export { TimeoutError } from './error/TimeoutError.mjs';
52
54
  export { debounce } from './function/debounce.mjs';
53
55
  export { noop } from './function/noop.mjs';
54
56
  export { once } from './function/once.mjs';
@@ -76,8 +78,10 @@ export { isNotNil } from './predicate/isNotNil.mjs';
76
78
  export { isNull } from './predicate/isNull.mjs';
77
79
  export { isUndefined } from './predicate/isUndefined.mjs';
78
80
  export { delay } from './promise/delay.mjs';
81
+ export { withTimeout } from './promise/withTimeout.mjs';
79
82
  export { camelCase } from './string/camelCase.mjs';
80
83
  export { snakeCase } from './string/snakeCase.mjs';
81
84
  export { kebabCase } from './string/kebabCase.mjs';
82
85
  export { lowerCase } from './string/lowerCase.mjs';
86
+ export { startCase } from './string/startCase.mjs';
83
87
  export { capitalize } from './string/capitalize.mjs';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { dropRight } from './array/dropRight.js';
9
9
  export { dropRightWhile } from './array/dropRightWhile.js';
10
10
  export { dropWhile } from './array/dropWhile.js';
11
11
  export { fill } from './array/fill.js';
12
+ export { flatMap } from './array/flatMap.js';
12
13
  export { flatten } from './array/flatten.js';
13
14
  export { flattenDeep } from './array/flattenDeep.js';
14
15
  export { forEachRight } from './array/forEachRight.js';
@@ -49,6 +50,7 @@ export { toFilled } from './array/toFilled.js';
49
50
  export { last } from './array/last.js';
50
51
  export { initial } from './array/initial.js';
51
52
  export { AbortError } from './error/AbortError.js';
53
+ export { TimeoutError } from './error/TimeoutError.js';
52
54
  export { debounce } from './function/debounce.js';
53
55
  export { noop } from './function/noop.js';
54
56
  export { once } from './function/once.js';
@@ -76,8 +78,10 @@ export { isNotNil } from './predicate/isNotNil.js';
76
78
  export { isNull } from './predicate/isNull.js';
77
79
  export { isUndefined } from './predicate/isUndefined.js';
78
80
  export { delay } from './promise/delay.js';
81
+ export { withTimeout } from './promise/withTimeout.js';
79
82
  export { camelCase } from './string/camelCase.js';
80
83
  export { snakeCase } from './string/snakeCase.js';
81
84
  export { kebabCase } from './string/kebabCase.js';
82
85
  export { lowerCase } from './string/lowerCase.js';
86
+ export { startCase } from './string/startCase.js';
83
87
  export { capitalize } from './string/capitalize.js';
package/dist/index.js CHANGED
@@ -30,11 +30,32 @@ var __copyProps = (to, from, except, desc) => {
30
30
  return to;
31
31
  };
32
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
33
53
 
34
54
  // src/index.ts
35
55
  var src_exports = {};
36
56
  __export(src_exports, {
37
57
  AbortError: () => AbortError,
58
+ TimeoutError: () => TimeoutError,
38
59
  camelCase: () => camelCase,
39
60
  capitalize: () => capitalize,
40
61
  chunk: () => chunk,
@@ -52,6 +73,7 @@ __export(src_exports, {
52
73
  dropRightWhile: () => dropRightWhile,
53
74
  dropWhile: () => dropWhile,
54
75
  fill: () => fill,
76
+ flatMap: () => flatMap,
55
77
  flatten: () => flatten,
56
78
  flattenDeep: () => flattenDeep,
57
79
  forEachRight: () => forEachRight,
@@ -93,6 +115,7 @@ __export(src_exports, {
93
115
  sampleSize: () => sampleSize,
94
116
  shuffle: () => shuffle,
95
117
  snakeCase: () => snakeCase,
118
+ startCase: () => startCase,
96
119
  sum: () => sum,
97
120
  sumBy: () => sumBy,
98
121
  tail: () => tail,
@@ -110,6 +133,7 @@ __export(src_exports, {
110
133
  uniqWith: () => uniqWith,
111
134
  unzip: () => unzip,
112
135
  unzipWith: () => unzipWith,
136
+ withTimeout: () => withTimeout,
113
137
  without: () => without,
114
138
  xor: () => xor,
115
139
  xorBy: () => xorBy,
@@ -182,12 +206,27 @@ function differenceWith(firstArr, secondArr, areItemsEqual) {
182
206
 
183
207
  // src/array/drop.ts
184
208
  function drop(arr, itemsCount) {
209
+ itemsCount = Math.max(itemsCount, 0);
185
210
  return arr.slice(itemsCount);
186
211
  }
187
212
 
188
213
  // src/array/dropRight.ts
189
214
  function dropRight(arr, itemsCount) {
190
- return arr.slice(0, -itemsCount);
215
+ itemsCount = Math.min(-itemsCount, 0);
216
+ if (itemsCount === 0) {
217
+ return arr.slice();
218
+ }
219
+ return arr.slice(0, itemsCount);
220
+ }
221
+
222
+ // src/array/dropRightWhile.ts
223
+ function dropRightWhile(arr, canContinueDropping) {
224
+ for (let i = arr.length - 1; i >= 0; i--) {
225
+ if (!canContinueDropping(arr[i])) {
226
+ return arr.slice(0, i + 1);
227
+ }
228
+ }
229
+ return [];
191
230
  }
192
231
 
193
232
  // src/array/dropWhile.ts
@@ -199,21 +238,15 @@ function dropWhile(arr, canContinueDropping) {
199
238
  return arr.slice(dropEndIndex);
200
239
  }
201
240
 
202
- // src/array/dropRightWhile.ts
203
- function dropRightWhile(arr, canContinueDropping) {
204
- const reversed = arr.slice().reverse();
205
- const dropped = dropWhile(reversed, canContinueDropping);
206
- return dropped.slice().reverse();
207
- }
208
-
209
241
  // src/array/fill.ts
210
- function fill(arr, value, start = 0, end = arr.length) {
211
- start = Math.max(start, 0);
212
- end = Math.min(end, arr.length);
213
- for (let i = start; i < end; i++) {
214
- arr[i] = value;
242
+ function fill(array, value, start = 0, end = array.length) {
243
+ const length = array.length;
244
+ const finalStart = Math.max(start >= 0 ? start : length + start, 0);
245
+ const finalEnd = Math.min(end >= 0 ? end : length + end, length);
246
+ for (let i = finalStart; i < finalEnd; i++) {
247
+ array[i] = value;
215
248
  }
216
- return arr;
249
+ return array;
217
250
  }
218
251
 
219
252
  // src/array/flatten.ts
@@ -233,6 +266,11 @@ function flatten(arr, depth = 1) {
233
266
  return result;
234
267
  }
235
268
 
269
+ // src/array/flatMap.ts
270
+ function flatMap(arr, iteratee, depth = 1) {
271
+ return flatten(arr.map((item) => iteratee(item)), depth);
272
+ }
273
+
236
274
  // src/array/flattenDeep.ts
237
275
  function flattenDeep(arr) {
238
276
  return flatten(arr, Infinity);
@@ -640,6 +678,14 @@ var AbortError = class extends Error {
640
678
  }
641
679
  };
642
680
 
681
+ // src/error/TimeoutError.ts
682
+ var TimeoutError = class extends Error {
683
+ constructor(message = "The operation was timed out") {
684
+ super(message);
685
+ this.name = "TimeoutError";
686
+ }
687
+ };
688
+
643
689
  // src/function/debounce.ts
644
690
  function debounce(func, debounceMs, { signal } = {}) {
645
691
  let timeoutId = null;
@@ -825,7 +871,9 @@ function pickBy(obj, shouldPick) {
825
871
  // src/object/invert.ts
826
872
  function invert(obj) {
827
873
  const result = {};
828
- for (const key in obj) {
874
+ const keys = Object.keys(obj);
875
+ for (let i = 0; i < keys.length; i++) {
876
+ const key = keys[i];
829
877
  const value = obj[key];
830
878
  result[value] = key;
831
879
  }
@@ -940,6 +988,21 @@ function delay(ms, { signal } = {}) {
940
988
  });
941
989
  }
942
990
 
991
+ // src/promise/timeout.ts
992
+ function timeout(ms) {
993
+ return __async(this, null, function* () {
994
+ yield delay(ms);
995
+ throw new TimeoutError();
996
+ });
997
+ }
998
+
999
+ // src/promise/withTimeout.ts
1000
+ function withTimeout(run, ms) {
1001
+ return __async(this, null, function* () {
1002
+ return Promise.race([run(), timeout(ms)]);
1003
+ });
1004
+ }
1005
+
943
1006
  // src/string/capitalize.ts
944
1007
  var capitalize = (str) => {
945
1008
  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
@@ -979,9 +1042,27 @@ var lowerCase = (str) => {
979
1042
  const words = getWords(str);
980
1043
  return words.map((word) => word.toLowerCase()).join(" ");
981
1044
  };
1045
+
1046
+ // src/string/startCase.ts
1047
+ function startCase(str) {
1048
+ const words = getWords(str.trim());
1049
+ let result = "";
1050
+ for (const word of words) {
1051
+ if (result) {
1052
+ result += " ";
1053
+ }
1054
+ if (word === word.toUpperCase()) {
1055
+ result += word;
1056
+ } else {
1057
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
1058
+ }
1059
+ }
1060
+ return result;
1061
+ }
982
1062
  // Annotate the CommonJS export names for ESM import in node:
983
1063
  0 && (module.exports = {
984
1064
  AbortError,
1065
+ TimeoutError,
985
1066
  camelCase,
986
1067
  capitalize,
987
1068
  chunk,
@@ -999,6 +1080,7 @@ var lowerCase = (str) => {
999
1080
  dropRightWhile,
1000
1081
  dropWhile,
1001
1082
  fill,
1083
+ flatMap,
1002
1084
  flatten,
1003
1085
  flattenDeep,
1004
1086
  forEachRight,
@@ -1040,6 +1122,7 @@ var lowerCase = (str) => {
1040
1122
  sampleSize,
1041
1123
  shuffle,
1042
1124
  snakeCase,
1125
+ startCase,
1043
1126
  sum,
1044
1127
  sumBy,
1045
1128
  tail,
@@ -1057,6 +1140,7 @@ var lowerCase = (str) => {
1057
1140
  uniqWith,
1058
1141
  unzip,
1059
1142
  unzipWith,
1143
+ withTimeout,
1060
1144
  without,
1061
1145
  xor,
1062
1146
  xorBy,