es-toolkit 1.9.0 → 1.10.0-dev.204

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 (253) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +1 -1
  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.mjs +1 -1
  10. package/dist/array/dropRight.mjs +1 -1
  11. package/dist/array/dropRightWhile.mjs +1 -1
  12. package/dist/array/dropWhile.mjs +1 -1
  13. package/dist/array/fill.mjs +1 -1
  14. package/dist/array/flatten.mjs +1 -1
  15. package/dist/array/flattenDeep.d.mts +25 -0
  16. package/dist/array/flattenDeep.d.ts +25 -0
  17. package/dist/array/flattenDeep.js +52 -0
  18. package/dist/array/flattenDeep.js.map +1 -0
  19. package/dist/array/flattenDeep.mjs +9 -0
  20. package/dist/array/forEachRight.mjs +1 -1
  21. package/dist/array/groupBy.mjs +1 -1
  22. package/dist/array/head.mjs +1 -1
  23. package/dist/array/index.d.mts +4 -0
  24. package/dist/array/index.d.ts +4 -0
  25. package/dist/array/index.js +38 -0
  26. package/dist/array/index.js.map +1 -1
  27. package/dist/array/index.mjs +45 -29
  28. package/dist/array/initial.d.mts +26 -0
  29. package/dist/array/initial.d.ts +26 -0
  30. package/dist/array/initial.js +36 -0
  31. package/dist/array/initial.js.map +1 -0
  32. package/dist/array/initial.mjs +8 -0
  33. package/dist/array/intersection.mjs +1 -1
  34. package/dist/array/intersectionBy.mjs +1 -1
  35. package/dist/array/intersectionWith.mjs +1 -1
  36. package/dist/array/keyBy.mjs +1 -1
  37. package/dist/array/last.d.mts +25 -0
  38. package/dist/array/last.d.ts +25 -0
  39. package/dist/array/last.js +33 -0
  40. package/dist/array/last.js.map +1 -0
  41. package/dist/array/last.mjs +8 -0
  42. package/dist/array/maxBy.mjs +1 -1
  43. package/dist/array/minBy.mjs +1 -1
  44. package/dist/array/orderBy.mjs +1 -1
  45. package/dist/array/partition.mjs +1 -1
  46. package/dist/array/sample.mjs +1 -1
  47. package/dist/array/sampleSize.mjs +1 -1
  48. package/dist/array/shuffle.mjs +1 -1
  49. package/dist/array/tail.mjs +1 -1
  50. package/dist/array/take.mjs +1 -1
  51. package/dist/array/takeRight.mjs +1 -1
  52. package/dist/array/takeRightWhile.mjs +1 -1
  53. package/dist/array/takeWhile.mjs +1 -1
  54. package/dist/array/toFilled.d.mts +33 -0
  55. package/dist/array/toFilled.d.ts +33 -0
  56. package/dist/array/toFilled.js +40 -0
  57. package/dist/array/toFilled.js.map +1 -0
  58. package/dist/array/toFilled.mjs +8 -0
  59. package/dist/array/union.mjs +1 -1
  60. package/dist/array/unionBy.mjs +1 -1
  61. package/dist/array/unionWith.mjs +1 -1
  62. package/dist/array/uniq.mjs +1 -1
  63. package/dist/array/uniqBy.mjs +1 -1
  64. package/dist/array/uniqWith.mjs +1 -1
  65. package/dist/array/unzip.mjs +1 -1
  66. package/dist/array/unzipWith.mjs +1 -1
  67. package/dist/array/without.mjs +1 -1
  68. package/dist/array/xor.mjs +1 -1
  69. package/dist/array/xorBy.mjs +1 -1
  70. package/dist/array/xorWith.mjs +1 -1
  71. package/dist/array/zip.mjs +1 -1
  72. package/dist/array/zipObject.mjs +1 -1
  73. package/dist/array/zipWith.mjs +1 -1
  74. package/dist/chunk-236H5JZJ.mjs +1 -0
  75. package/dist/chunk-2HIMLZE3.mjs +46 -0
  76. package/dist/chunk-2HIMLZE3.mjs.map +1 -0
  77. package/dist/chunk-2MRZANXZ.mjs +1 -0
  78. package/dist/chunk-2MRZANXZ.mjs.map +1 -0
  79. package/dist/chunk-2SLTL4KL.mjs +13 -0
  80. package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
  81. package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
  82. package/dist/chunk-5IKVJGHO.mjs +14 -0
  83. package/dist/chunk-5IKVJGHO.mjs.map +1 -0
  84. package/dist/chunk-ASJF5D6C.mjs +1 -0
  85. package/dist/chunk-ASJF5D6C.mjs.map +1 -0
  86. package/dist/chunk-BOOQBJN2.mjs +9 -0
  87. package/dist/chunk-BOOQBJN2.mjs.map +1 -0
  88. package/dist/chunk-EYYZQFOP.mjs +14 -0
  89. package/dist/chunk-EYYZQFOP.mjs.map +1 -0
  90. package/dist/chunk-F3WCQQET.mjs +14 -0
  91. package/dist/chunk-F3WCQQET.mjs.map +1 -0
  92. package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
  93. package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
  94. package/dist/chunk-JYSV56US.mjs +41 -0
  95. package/dist/chunk-JYSV56US.mjs.map +1 -0
  96. package/dist/chunk-KPBQ7OUY.mjs +9 -0
  97. package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
  98. package/dist/chunk-ML727RRJ.mjs +13 -0
  99. package/dist/chunk-ML727RRJ.mjs.map +1 -0
  100. package/dist/chunk-NKLIE2OI.mjs +1 -0
  101. package/dist/chunk-NKLIE2OI.mjs.map +1 -0
  102. package/dist/chunk-OP4OAKQJ.mjs +16 -0
  103. package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
  104. package/dist/chunk-OSOLEQLZ.mjs +1 -0
  105. package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
  106. package/dist/chunk-QKYYOLJ6.mjs +1 -0
  107. package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
  108. package/dist/chunk-U4JGKZ56.mjs +41 -0
  109. package/dist/chunk-U4JGKZ56.mjs.map +1 -0
  110. package/dist/chunk-U56ZOM7L.mjs +9 -0
  111. package/dist/chunk-U56ZOM7L.mjs.map +1 -0
  112. package/dist/chunk-WMM7TZLG.mjs +9 -0
  113. package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
  114. package/dist/chunk-WVQ7YVRK.mjs +11 -0
  115. package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
  116. package/dist/chunk-XGCYC4YA.mjs +5516 -0
  117. package/dist/chunk-XGCYC4YA.mjs.map +1 -0
  118. package/dist/chunk-XPSOKBRZ.mjs +12 -0
  119. package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
  120. package/dist/compat/index.d.mts +108 -0
  121. package/dist/compat/index.d.ts +108 -0
  122. package/dist/compat/index.js +6578 -0
  123. package/dist/compat/index.js.map +1 -0
  124. package/dist/compat/index.mjs +351 -0
  125. package/dist/compat/index.mjs.map +1 -0
  126. package/dist/error/AbortError.mjs +1 -1
  127. package/dist/error/index.mjs +1 -1
  128. package/dist/function/debounce.mjs +1 -1
  129. package/dist/function/index.d.mts +1 -0
  130. package/dist/function/index.d.ts +1 -0
  131. package/dist/function/index.js +7 -0
  132. package/dist/function/index.js.map +1 -1
  133. package/dist/function/index.mjs +8 -4
  134. package/dist/function/negate.d.mts +10 -0
  135. package/dist/function/negate.d.ts +10 -0
  136. package/dist/function/negate.js +33 -0
  137. package/dist/function/negate.js.map +1 -0
  138. package/dist/function/negate.mjs +8 -0
  139. package/dist/function/negate.mjs.map +1 -0
  140. package/dist/function/noop.mjs +1 -1
  141. package/dist/function/once.mjs +1 -1
  142. package/dist/function/throttle.mjs +1 -1
  143. package/dist/index.d.mts +12 -0
  144. package/dist/index.d.ts +12 -0
  145. package/dist/index.js +5681 -3
  146. package/dist/index.js.map +1 -1
  147. package/dist/index.mjs +101 -50
  148. package/dist/math/clamp.mjs +1 -1
  149. package/dist/math/inRange.mjs +1 -1
  150. package/dist/math/index.js +2 -2
  151. package/dist/math/index.js.map +1 -1
  152. package/dist/math/index.mjs +9 -9
  153. package/dist/math/mean.js +2 -2
  154. package/dist/math/mean.js.map +1 -1
  155. package/dist/math/mean.mjs +3 -3
  156. package/dist/math/meanBy.js +2 -2
  157. package/dist/math/meanBy.js.map +1 -1
  158. package/dist/math/meanBy.mjs +4 -4
  159. package/dist/math/random.mjs +1 -1
  160. package/dist/math/randomInt.mjs +1 -1
  161. package/dist/math/range.mjs +1 -1
  162. package/dist/math/round.mjs +1 -1
  163. package/dist/math/sum.js +2 -2
  164. package/dist/math/sum.js.map +1 -1
  165. package/dist/math/sum.mjs +2 -2
  166. package/dist/object/clone.d.mts +31 -0
  167. package/dist/object/clone.d.ts +31 -0
  168. package/dist/object/clone.js +65 -0
  169. package/dist/object/clone.js.map +1 -0
  170. package/dist/object/clone.mjs +8 -0
  171. package/dist/object/clone.mjs.map +1 -0
  172. package/dist/object/index.d.mts +1 -0
  173. package/dist/object/index.d.ts +1 -0
  174. package/dist/object/index.js +39 -0
  175. package/dist/object/index.js.map +1 -1
  176. package/dist/object/index.mjs +7 -3
  177. package/dist/object/invert.mjs +1 -1
  178. package/dist/object/omit.mjs +2 -2
  179. package/dist/object/omitBy.mjs +1 -1
  180. package/dist/object/pick.mjs +1 -1
  181. package/dist/object/pickBy.mjs +1 -1
  182. package/dist/predicate/index.d.mts +1 -0
  183. package/dist/predicate/index.d.ts +1 -0
  184. package/dist/predicate/index.js +46 -1
  185. package/dist/predicate/index.js.map +1 -1
  186. package/dist/predicate/index.mjs +9 -3
  187. package/dist/predicate/isEqual.d.mts +17 -0
  188. package/dist/predicate/isEqual.d.ts +17 -0
  189. package/dist/predicate/isEqual.js +73 -0
  190. package/dist/predicate/isEqual.js.map +1 -0
  191. package/dist/predicate/isEqual.mjs +10 -0
  192. package/dist/predicate/isEqual.mjs.map +1 -0
  193. package/dist/predicate/isNil.js +1 -1
  194. package/dist/predicate/isNil.js.map +1 -1
  195. package/dist/predicate/isNil.mjs +2 -2
  196. package/dist/predicate/isNotNil.mjs +1 -1
  197. package/dist/predicate/isNull.mjs +1 -1
  198. package/dist/predicate/isUndefined.mjs +1 -1
  199. package/dist/promise/delay.mjs +1 -1
  200. package/dist/promise/index.mjs +1 -1
  201. package/dist/string/camelCase.d.mts +17 -0
  202. package/dist/string/camelCase.d.ts +17 -0
  203. package/dist/string/camelCase.js +5554 -0
  204. package/dist/string/camelCase.js.map +1 -0
  205. package/dist/string/camelCase.mjs +9 -0
  206. package/dist/string/camelCase.mjs.map +1 -0
  207. package/dist/string/capitalize.d.mts +14 -0
  208. package/dist/string/capitalize.d.ts +14 -0
  209. package/dist/string/capitalize.js +33 -0
  210. package/dist/string/capitalize.js.map +1 -0
  211. package/dist/string/capitalize.mjs +8 -0
  212. package/dist/string/capitalize.mjs.map +1 -0
  213. package/dist/string/index.d.mts +5 -0
  214. package/dist/string/index.d.ts +5 -0
  215. package/dist/string/index.js +5587 -0
  216. package/dist/string/index.js.map +1 -0
  217. package/dist/string/index.mjs +26 -0
  218. package/dist/string/index.mjs.map +1 -0
  219. package/dist/string/kebabCase.d.mts +17 -0
  220. package/dist/string/kebabCase.d.ts +17 -0
  221. package/dist/string/kebabCase.js +43 -0
  222. package/dist/string/kebabCase.js.map +1 -0
  223. package/dist/string/kebabCase.mjs +9 -0
  224. package/dist/string/kebabCase.mjs.map +1 -0
  225. package/dist/string/lowerCase.d.mts +17 -0
  226. package/dist/string/lowerCase.d.ts +17 -0
  227. package/dist/string/lowerCase.js +43 -0
  228. package/dist/string/lowerCase.js.map +1 -0
  229. package/dist/string/lowerCase.mjs +9 -0
  230. package/dist/string/lowerCase.mjs.map +1 -0
  231. package/dist/string/snakeCase.d.mts +17 -0
  232. package/dist/string/snakeCase.d.ts +17 -0
  233. package/dist/string/snakeCase.js +43 -0
  234. package/dist/string/snakeCase.js.map +1 -0
  235. package/dist/string/snakeCase.mjs +9 -0
  236. package/dist/string/snakeCase.mjs.map +1 -0
  237. package/package.json +21 -1
  238. package/string.d.ts +1 -0
  239. package/dist/chunk-2MM5EJJX.mjs +0 -21
  240. package/dist/chunk-LOY6PATI.mjs +0 -1
  241. package/dist/chunk-MAJSPFA6.mjs +0 -1
  242. package/dist/chunk-N6EM6ETS.mjs +0 -1
  243. package/dist/chunk-NOFHNJ5C.mjs +0 -13
  244. package/dist/chunk-OHQAR5AU.mjs +0 -9
  245. package/dist/chunk-PMHULJNL.mjs +0 -1
  246. /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
  247. /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
  248. /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
  249. /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
  250. /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
  251. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
  252. /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
  253. /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # es-toolkit Changelog
2
2
 
3
+ ## Version v1.10.0
4
+
5
+ Released on July 14th, 2024.
6
+
7
+ ### Features
8
+
9
+
10
+ - Add support for [capitalize](https://es-toolkit.slash.page/reference/string/capitalize.html), [snakeCase](https://es-toolkit.slash.page/reference/string/snakeCase.html), [kebabCase](https://es-toolkit.slash.page/reference/string/kebabCase.html), [camelCase](https://es-toolkit.slash.page/reference/string/camelCase.html) and [lowerCase](https://es-toolkit.slash.page/reference/string/lowerCase.html). (https://github.com/toss/es-toolkit/pull/152, https://github.com/toss/es-toolkit/pull/161, https://github.com/toss/es-toolkit/pull/162, https://github.com/toss/es-toolkit/pull/166, [21d6530](https://github.com/toss/es-toolkit/commit/21d6530e16471d596410d57d59fd3ced8fc5569f)).
11
+ - Add support for [negate](https://es-toolkit.slash.page/reference/function/negate.html). (https://github.com/toss/es-toolkit/pull/177)
12
+ - Add support for [isEqual](https://es-toolkit.slash.page/reference/predicate/isEqual.html). (https://github.com/toss/es-toolkit/pull/174)
13
+ - Add support for [clone](https://es-toolkit.slash.page/reference/object/clone.html). (https://github.com/toss/es-toolkit/pull/155)
14
+ - Add support for [toFilled](https://es-toolkit.slash.page/reference/array/toFilled.html). (https://github.com/toss/es-toolkit/pull/154)
15
+ - Add support for [initial](https://es-toolkit.slash.page/reference/array/initial.html) and [last](https://es-toolkit.slash.page/reference/array/last.html). (https://github.com/toss/es-toolkit/pull/188, https://github.com/toss/es-toolkit/pull/149)
16
+ - Add support for [flattenDeep](https://es-toolkit.slash.page/reference/array/flattenDeep.html). (https://github.com/toss/es-toolkit/pull/160)
17
+
18
+ ### Performance Improvements
19
+
20
+ - Optimize the performance of [isNil](https://es-toolkit.slash.page/reference/predicate/isNil.html) by simplifying its check. ([489ac76](https://github.com/toss/es-toolkit/commit/489ac76fc62f97cbfa3ca9eec2e0a4c03c4f5b1c))
21
+ - Optimize the performance of [sum](https://es-toolkit.slash.page/reference/array/sum.html). (https://github.com/toss/es-toolkit/pull/155)
22
+
23
+
24
+
3
25
  ## Version v1.9.0
4
26
 
5
27
  Released on July 10th, 2024.
@@ -8,7 +30,6 @@ Released on July 10th, 2024.
8
30
  - Add support for [unzip](https://es-toolkit.slash.page/reference/array/unzip.html). (https://github.com/toss/es-toolkit/pull/130)
9
31
  - Add support for [flatten](https://es-toolkit.slash.page/reference/array/flatten.html), which is six times faster than `Array#flat`. (https://github.com/toss/es-toolkit/pull/147)
10
32
 
11
-
12
33
  ## Version v1.8.0
13
34
 
14
35
  Released on July 5th, 2024.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # es-toolkit · [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/toss/slash/blob/main/LICENSE) [![codecov](https://codecov.io/gh/toss/es-toolkit/graph/badge.svg?token=8N5S3AR3C7)](https://codecov.io/gh/toss/es-toolkit) [![NPM badge](https://img.shields.io/npm/v/es-toolkit?logo=npm)](https://www.npmjs.com/package/es-toolkit) [![JSR badge](https://jsr.io/badges/@es-toolkit/es-toolkit)](https://jsr.io/@es-toolkit/es-toolkit)
4
4
 
5
- English | [한국어](https://github.com/toss/es-toolkit/blob/main/README-ko_kr.md)
5
+ English | [한국어](https://github.com/toss/es-toolkit/blob/main/README-ko_kr.md) | [简体中文](https://github.com/toss/es-toolkit/blob/main/README-zh_hans.md)
6
6
 
7
7
  es-toolkit is a state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
8
8
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  chunk
3
3
  } from "../chunk-E6C5EZQA.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  chunk
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compact
3
3
  } from "../chunk-DTJJIMKJ.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  compact
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  countBy
3
3
  } from "../chunk-CRSKT4WW.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  countBy
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  difference
3
3
  } from "../chunk-JPUKH67K.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  difference
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  differenceBy
3
3
  } from "../chunk-LVWX5B43.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  differenceBy
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  differenceWith
3
3
  } from "../chunk-6NVQAHXP.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  differenceWith
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  drop
3
3
  } from "../chunk-S3CORED5.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  drop
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dropRight
3
3
  } from "../chunk-JEKUA56R.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  dropRight
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  dropRightWhile
3
3
  } from "../chunk-JE6JKZU3.mjs";
4
4
  import "../chunk-LJ2C6MVP.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
6
  export {
7
7
  dropRightWhile
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dropWhile
3
3
  } from "../chunk-LJ2C6MVP.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  dropWhile
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fill
3
3
  } from "../chunk-C4WE4GLC.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  fill
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  flatten
3
3
  } from "../chunk-33MSBDC6.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  flatten
7
7
  };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Utility type for recursively unpacking nested array types to extract the type of the innermost element
3
+ *
4
+ * @example
5
+ * ExtractNestedArrayType<(number | (number | number[])[])[]>
6
+ * // number
7
+ *
8
+ * ExtractNestedArrayType<(boolean | (string | number[])[])[]>
9
+ * // string | number | boolean
10
+ */
11
+ type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
12
+ /**
13
+ * Flattens all depths of a nested array.
14
+ *
15
+ * @template T - The type of elements within the array.
16
+ * @param {T[]} arr - The array to flatten.
17
+ * @returns {Array<ExtractNestedArrayType<T>>} A new array that has been flattened.
18
+ *
19
+ * @example
20
+ * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
21
+ * // Returns: [1, 2, 3, 4, 5, 6]
22
+ */
23
+ declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
24
+
25
+ export { flattenDeep };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Utility type for recursively unpacking nested array types to extract the type of the innermost element
3
+ *
4
+ * @example
5
+ * ExtractNestedArrayType<(number | (number | number[])[])[]>
6
+ * // number
7
+ *
8
+ * ExtractNestedArrayType<(boolean | (string | number[])[])[]>
9
+ * // string | number | boolean
10
+ */
11
+ type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
12
+ /**
13
+ * Flattens all depths of a nested array.
14
+ *
15
+ * @template T - The type of elements within the array.
16
+ * @param {T[]} arr - The array to flatten.
17
+ * @returns {Array<ExtractNestedArrayType<T>>} A new array that has been flattened.
18
+ *
19
+ * @example
20
+ * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
21
+ * // Returns: [1, 2, 3, 4, 5, 6]
22
+ */
23
+ declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
24
+
25
+ export { flattenDeep };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/array/flattenDeep.ts
21
+ var flattenDeep_exports = {};
22
+ __export(flattenDeep_exports, {
23
+ flattenDeep: () => flattenDeep
24
+ });
25
+ module.exports = __toCommonJS(flattenDeep_exports);
26
+
27
+ // src/array/flatten.ts
28
+ function flatten(arr, depth = 1) {
29
+ const result = [];
30
+ const flooredDepth = Math.floor(depth);
31
+ const recursive = (arr2, currentDepth) => {
32
+ for (const item of arr2) {
33
+ if (Array.isArray(item) && currentDepth < flooredDepth) {
34
+ recursive(item, currentDepth + 1);
35
+ } else {
36
+ result.push(item);
37
+ }
38
+ }
39
+ };
40
+ recursive(arr, 0);
41
+ return result;
42
+ }
43
+
44
+ // src/array/flattenDeep.ts
45
+ function flattenDeep(arr) {
46
+ return flatten(arr, Infinity);
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ flattenDeep
51
+ });
52
+ //# sourceMappingURL=flattenDeep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/array/flattenDeep.ts","../../src/array/flatten.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Utility type for recursively unpacking nested array types to extract the type of the innermost element\n *\n * @example\n * ExtractNestedArrayType<(number | (number | number[])[])[]>\n * // number\n *\n * ExtractNestedArrayType<(boolean | (string | number[])[])[]>\n * // string | number | boolean\n */\ntype ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;\n\n/**\n * Flattens all depths of a nested array.\n *\n * @template T - The type of elements within the array.\n * @param {T[]} arr - The array to flatten.\n * @returns {Array<ExtractNestedArrayType<T>>} A new array that has been flattened.\n *\n * @example\n * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>> {\n return flatten(arr, Infinity) as Array<ExtractNestedArrayType<T>>;\n}\n","/**\n * Flattens an array up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<T[], D>>} A new array that has been flattened.\n *\n * @example\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);\n * // Returns: [1, 2, 3, 4, [5, 6]]\n *\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flatten<T, D extends number = 1>(arr: readonly T[], depth = 1 as D): Array<FlatArray<T[], D>> {\n const result: Array<FlatArray<T[], D>> = [];\n const flooredDepth = Math.floor(depth);\n\n const recursive = (arr: readonly T[], currentDepth: number) => {\n for (const item of arr) {\n if (Array.isArray(item) && currentDepth < flooredDepth) {\n recursive(item, currentDepth + 1);\n } else {\n result.push(item as FlatArray<T[], D>);\n }\n }\n };\n\n recursive(arr, 0);\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBO,SAAS,QAAiC,KAAmB,QAAQ,GAAkC;AAC5G,QAAM,SAAmC,CAAC;AAC1C,QAAM,eAAe,KAAK,MAAM,KAAK;AAErC,QAAM,YAAY,CAACA,MAAmB,iBAAyB;AAC7D,eAAW,QAAQA,MAAK;AACtB,UAAI,MAAM,QAAQ,IAAI,KAAK,eAAe,cAAc;AACtD,kBAAU,MAAM,eAAe,CAAC;AAAA,MAClC,OAAO;AACL,eAAO,KAAK,IAAyB;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAEA,YAAU,KAAK,CAAC;AAChB,SAAO;AACT;;;ADPO,SAAS,YAAe,KAAqD;AAClF,SAAO,QAAQ,KAAK,QAAQ;AAC9B;","names":["arr"]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ flattenDeep
3
+ } from "../chunk-ML727RRJ.mjs";
4
+ import "../chunk-33MSBDC6.mjs";
5
+ import "../chunk-2HIMLZE3.mjs";
6
+ export {
7
+ flattenDeep
8
+ };
9
+ //# sourceMappingURL=flattenDeep.mjs.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  forEachRight
3
3
  } from "../chunk-IEA53J7P.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  forEachRight
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  groupBy
3
3
  } from "../chunk-E6E4RZLN.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  groupBy
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  head
3
3
  } from "../chunk-HM2JT2RX.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-2HIMLZE3.mjs";
5
5
  export {
6
6
  head
7
7
  };
@@ -10,6 +10,7 @@ export { dropRightWhile } from './dropRightWhile.mjs';
10
10
  export { dropWhile } from './dropWhile.mjs';
11
11
  export { fill } from './fill.mjs';
12
12
  export { flatten } from './flatten.mjs';
13
+ export { flattenDeep } from './flattenDeep.mjs';
13
14
  export { forEachRight } from './forEachRight.mjs';
14
15
  export { groupBy } from './groupBy.mjs';
15
16
  export { intersection } from './intersection.mjs';
@@ -44,3 +45,6 @@ export { zipWith } from './zipWith.mjs';
44
45
  export { without } from './without.mjs';
45
46
  export { head } from './head.mjs';
46
47
  export { tail } from './tail.mjs';
48
+ export { toFilled } from './toFilled.mjs';
49
+ export { last } from './last.mjs';
50
+ export { initial } from './initial.mjs';
@@ -10,6 +10,7 @@ export { dropRightWhile } from './dropRightWhile.js';
10
10
  export { dropWhile } from './dropWhile.js';
11
11
  export { fill } from './fill.js';
12
12
  export { flatten } from './flatten.js';
13
+ export { flattenDeep } from './flattenDeep.js';
13
14
  export { forEachRight } from './forEachRight.js';
14
15
  export { groupBy } from './groupBy.js';
15
16
  export { intersection } from './intersection.js';
@@ -44,3 +45,6 @@ export { zipWith } from './zipWith.js';
44
45
  export { without } from './without.js';
45
46
  export { head } from './head.js';
46
47
  export { tail } from './tail.js';
48
+ export { toFilled } from './toFilled.js';
49
+ export { last } from './last.js';
50
+ export { initial } from './initial.js';
@@ -32,13 +32,16 @@ __export(array_exports, {
32
32
  dropWhile: () => dropWhile,
33
33
  fill: () => fill,
34
34
  flatten: () => flatten,
35
+ flattenDeep: () => flattenDeep,
35
36
  forEachRight: () => forEachRight,
36
37
  groupBy: () => groupBy,
37
38
  head: () => head,
39
+ initial: () => initial,
38
40
  intersection: () => intersection,
39
41
  intersectionBy: () => intersectionBy,
40
42
  intersectionWith: () => intersectionWith,
41
43
  keyBy: () => keyBy,
44
+ last: () => last,
42
45
  maxBy: () => maxBy,
43
46
  minBy: () => minBy,
44
47
  orderBy: () => orderBy,
@@ -51,6 +54,7 @@ __export(array_exports, {
51
54
  takeRight: () => takeRight,
52
55
  takeRightWhile: () => takeRightWhile,
53
56
  takeWhile: () => takeWhile,
57
+ toFilled: () => toFilled,
54
58
  union: () => union,
55
59
  unionBy: () => unionBy,
56
60
  unionWith: () => unionWith,
@@ -182,6 +186,11 @@ function flatten(arr, depth = 1) {
182
186
  return result;
183
187
  }
184
188
 
189
+ // src/array/flattenDeep.ts
190
+ function flattenDeep(arr) {
191
+ return flatten(arr, Infinity);
192
+ }
193
+
185
194
  // src/array/forEachRight.ts
186
195
  function forEachRight(arr, callback) {
187
196
  for (let i = arr.length - 1; i >= 0; i--) {
@@ -550,6 +559,31 @@ function tail(arr) {
550
559
  }
551
560
  return result;
552
561
  }
562
+
563
+ // src/array/toFilled.ts
564
+ function toFilled(arr, value, start = 0, end = arr.length) {
565
+ const length = arr.length;
566
+ const finalStart = Math.max(start >= 0 ? start : length + start, 0);
567
+ const finalEnd = Math.min(end >= 0 ? end : length + end, length);
568
+ const newArr = arr.slice();
569
+ for (let i = finalStart; i < finalEnd; i++) {
570
+ newArr[i] = value;
571
+ }
572
+ return newArr;
573
+ }
574
+
575
+ // src/array/last.ts
576
+ function last(arr) {
577
+ return arr[arr.length - 1];
578
+ }
579
+
580
+ // src/array/initial.ts
581
+ function initial(arr) {
582
+ if (arr.length <= 1) {
583
+ return [];
584
+ }
585
+ return arr.slice(0, -1);
586
+ }
553
587
  // Annotate the CommonJS export names for ESM import in node:
554
588
  0 && (module.exports = {
555
589
  chunk,
@@ -564,13 +598,16 @@ function tail(arr) {
564
598
  dropWhile,
565
599
  fill,
566
600
  flatten,
601
+ flattenDeep,
567
602
  forEachRight,
568
603
  groupBy,
569
604
  head,
605
+ initial,
570
606
  intersection,
571
607
  intersectionBy,
572
608
  intersectionWith,
573
609
  keyBy,
610
+ last,
574
611
  maxBy,
575
612
  minBy,
576
613
  orderBy,
@@ -583,6 +620,7 @@ function tail(arr) {
583
620
  takeRight,
584
621
  takeRightWhile,
585
622
  takeWhile,
623
+ toFilled,
586
624
  union,
587
625
  unionBy,
588
626
  unionWith,