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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # es-toolkit Changelog
2
2
 
3
+ ## Version v1.11.0
4
+
5
+ Released on July 18th, 2024.
6
+
7
+ ### Introducing `es-toolkit/compat`
8
+
9
+ We're introducing `es-toolkit/compat`, a new module designed as a drop-in replacement for lodash. It replicates lodash's API, making it easier to switch between the two libraries.
10
+
11
+ `es-toolkit/compat` is undergoing rigorous testing using real `lodash` test cases. Initial benchmarks suggest it's typically 5% slower and increases bundle size by 10% compared to the original `es-toolkit`.
12
+
13
+ This module is intended to facilitate a smooth transition and should be replaced with the original `es-toolkit` for optimal performance once migration is complete.
14
+
15
+ For more information, see our [compatibility documentation](https://es-toolkit.slash.page/compatibility.html).
16
+
17
+ ### Features
18
+
19
+ - Added support for [get](https://es-toolkit.slash.page/reference/compat/object/get.html) and [set](https://es-toolkit.slash.page/reference/compat/object/set.html) in our compatibility layer `es-toolkit/compat`. (https://github.com/toss/es-toolkit/pull/232, https://github.com/toss/es-toolkit/pull/223)
20
+ - Added support for [zipObjectDeep](https://es-toolkit.slash.page/reference/compat/array/zipObjectDeep.html) in our compatibility layer `es-toolkit/compat`. (https://github.com/toss/es-toolkit/pull/150)
21
+ - Added support for [flatMap](https://es-toolkit.slash.page/reference/compat/array/flatMap.html). (https://github.com/toss/es-toolkit/pull/209)
22
+ - Added support for [startCase](https://es-toolkit.slash.page/reference/string/startCase.html), [startsWith](https://es-toolkit.slash.page/reference/string/startsWith.html), and [endsWith](https://es-toolkit.slash.page/reference/string/endsWith.html). (https://github.com/toss/es-toolkit/pull/224).
23
+ - Added support for [withTimeout](https://es-toolkit.slash.page/reference/promise/withTimeout.html). (https://github.com/toss/es-toolkit/pull/210)
24
+
25
+ ### Bug fixes
26
+
27
+ - Fixed `drop` and `dropRight` incorrectly accepting negative integers. (https://github.com/toss/es-toolkit/pull/218)
28
+ - Fixed `invert` not to invert inherited properties. (https://github.com/toss/es-toolkit/pull/221)
29
+
30
+ ### Performance Improvements
31
+
32
+ - Improved performance for `dropRightWhile`. (https://github.com/toss/es-toolkit/pull/220)
33
+
34
+
35
+
3
36
  ## Version v1.10.1
4
37
 
5
38
  Released on July 15th, 2024.
package/compat.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/compat';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  chunk
3
3
  } from "../chunk-E6C5EZQA.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.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-424M7IR7.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-424M7IR7.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-424M7IR7.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-424M7IR7.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-424M7IR7.mjs";
5
5
  export {
6
6
  differenceWith
7
7
  };
@@ -24,6 +24,7 @@ __export(drop_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(drop_exports);
26
26
  function drop(arr, itemsCount) {
27
+ itemsCount = Math.max(itemsCount, 0);
27
28
  return arr.slice(itemsCount);
28
29
  }
29
30
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
1
+ {"version":3,"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.max(itemsCount, 0);\n\n return arr.slice(itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,eAAa,KAAK,IAAI,YAAY,CAAC;AAEnC,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  drop
3
- } from "../chunk-S3CORED5.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
3
+ } from "../chunk-3EZAFZG3.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  drop
7
7
  };
@@ -24,7 +24,11 @@ __export(dropRight_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(dropRight_exports);
26
26
  function dropRight(arr, itemsCount) {
27
- return arr.slice(0, -itemsCount);
27
+ itemsCount = Math.min(-itemsCount, 0);
28
+ if (itemsCount === 0) {
29
+ return arr.slice();
30
+ }
31
+ return arr.slice(0, itemsCount);
28
32
  }
29
33
  // Annotate the CommonJS export names for ESM import in node:
30
34
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(0, -itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,SAAO,IAAI,MAAM,GAAG,CAAC,UAAU;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.min(-itemsCount, 0);\n\n if (itemsCount === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,eAAa,KAAK,IAAI,CAAC,YAAY,CAAC;AAEpC,MAAI,eAAe,GAAG;AACpB,WAAO,IAAI,MAAM;AAAA,EACnB;AAEA,SAAO,IAAI,MAAM,GAAG,UAAU;AAChC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dropRight
3
- } from "../chunk-JEKUA56R.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
3
+ } from "../chunk-OXZCMC5I.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  dropRight
7
7
  };
@@ -23,21 +23,13 @@ __export(dropRightWhile_exports, {
23
23
  dropRightWhile: () => dropRightWhile
24
24
  });
25
25
  module.exports = __toCommonJS(dropRightWhile_exports);
26
-
27
- // src/array/dropWhile.ts
28
- function dropWhile(arr, canContinueDropping) {
29
- const dropEndIndex = arr.findIndex((item) => !canContinueDropping(item));
30
- if (dropEndIndex === -1) {
31
- return [];
32
- }
33
- return arr.slice(dropEndIndex);
34
- }
35
-
36
- // src/array/dropRightWhile.ts
37
26
  function dropRightWhile(arr, canContinueDropping) {
38
- const reversed = arr.slice().reverse();
39
- const dropped = dropWhile(reversed, canContinueDropping);
40
- return dropped.slice().reverse();
27
+ for (let i = arr.length - 1; i >= 0; i--) {
28
+ if (!canContinueDropping(arr[i])) {
29
+ return arr.slice(0, i + 1);
30
+ }
31
+ }
32
+ return [];
41
33
  }
42
34
  // Annotate the CommonJS export names for ESM import in node:
43
35
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/dropRightWhile.ts","../../src/array/dropWhile.ts"],"sourcesContent":["import { dropWhile } from './dropWhile.ts';\n\n/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const reversed = arr.slice().reverse();\n const dropped = dropWhile(reversed, canContinueDropping);\n return dropped.slice().reverse();\n}\n","/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkBO,SAAS,UAAa,KAAmB,qBAAgD;AAC9F,QAAM,eAAe,IAAI,UAAU,UAAQ,CAAC,oBAAoB,IAAI,CAAC;AACrE,MAAI,iBAAiB,IAAI;AACvB,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,YAAY;AAC/B;;;ADLO,SAAS,eAAkB,KAAmB,qBAAgD;AACnG,QAAM,WAAW,IAAI,MAAM,EAAE,QAAQ;AACrC,QAAM,UAAU,UAAU,UAAU,mBAAmB;AACvD,SAAO,QAAQ,MAAM,EAAE,QAAQ;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/array/dropRightWhile.ts"],"sourcesContent":["/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!canContinueDropping(arr[i])) {\n return arr.slice(0, i + 1);\n }\n }\n\n return [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,eAAkB,KAAmB,qBAAgD;AACnG,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC,GAAG;AAChC,aAAO,IAAI,MAAM,GAAG,IAAI,CAAC;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,CAAC;AACV;","names":[]}
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  dropRightWhile
3
- } from "../chunk-JE6JKZU3.mjs";
4
- import "../chunk-LJ2C6MVP.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
3
+ } from "../chunk-M7SBBYV2.mjs";
4
+ import "../chunk-424M7IR7.mjs";
6
5
  export {
7
6
  dropRightWhile
8
7
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  dropWhile
3
3
  } from "../chunk-LJ2C6MVP.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  dropWhile
7
7
  };
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * This function mutates the original array and replaces its elements with the provided value, starting from the specified
5
5
  * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
6
- * entire array. Negative indices can be used to specify positions from the end of the array.
6
+ * entire array.
7
7
  *
8
- * @param {Array<T | P>} arr - The array to fill.
9
- * @param {P} value - The value to fill the array with.
8
+ * @param {Array<T | U>} array - The array to fill.
9
+ * @param {U} value - The value to fill the array with.
10
10
  * @param {number} [start=0] - The start position. Defaults to 0.
11
11
  * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
12
- * @returns {Array<T | P>} The array with the filled values.
12
+ * @returns {Array<T | U>} The array with the filled values.
13
13
  *
14
14
  * @example
15
15
  * const array = [1, 2, 3];
@@ -21,9 +21,12 @@
21
21
  *
22
22
  * const result = fill([4, 6, 8, 10], '*', 1, 3);
23
23
  * // => [4, '*', '*', 10]
24
+ *
25
+ * const result = fill(array, '*', -2, -1);
26
+ * // => [1, '*', 3]
24
27
  */
25
- declare function fill<T>(arr: unknown[], value: T): T[];
26
- declare function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;
27
- declare function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;
28
+ declare function fill<T>(array: unknown[], value: T): T[];
29
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
30
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
28
31
 
29
32
  export { fill };
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * This function mutates the original array and replaces its elements with the provided value, starting from the specified
5
5
  * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
6
- * entire array. Negative indices can be used to specify positions from the end of the array.
6
+ * entire array.
7
7
  *
8
- * @param {Array<T | P>} arr - The array to fill.
9
- * @param {P} value - The value to fill the array with.
8
+ * @param {Array<T | U>} array - The array to fill.
9
+ * @param {U} value - The value to fill the array with.
10
10
  * @param {number} [start=0] - The start position. Defaults to 0.
11
11
  * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
12
- * @returns {Array<T | P>} The array with the filled values.
12
+ * @returns {Array<T | U>} The array with the filled values.
13
13
  *
14
14
  * @example
15
15
  * const array = [1, 2, 3];
@@ -21,9 +21,12 @@
21
21
  *
22
22
  * const result = fill([4, 6, 8, 10], '*', 1, 3);
23
23
  * // => [4, '*', '*', 10]
24
+ *
25
+ * const result = fill(array, '*', -2, -1);
26
+ * // => [1, '*', 3]
24
27
  */
25
- declare function fill<T>(arr: unknown[], value: T): T[];
26
- declare function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;
27
- declare function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;
28
+ declare function fill<T>(array: unknown[], value: T): T[];
29
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;
30
+ declare function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;
28
31
 
29
32
  export { fill };
@@ -23,13 +23,14 @@ __export(fill_exports, {
23
23
  fill: () => fill
24
24
  });
25
25
  module.exports = __toCommonJS(fill_exports);
26
- function fill(arr, value, start = 0, end = arr.length) {
27
- start = Math.max(start, 0);
28
- end = Math.min(end, arr.length);
29
- for (let i = start; i < end; i++) {
30
- arr[i] = value;
26
+ function fill(array, value, start = 0, end = array.length) {
27
+ const length = array.length;
28
+ const finalStart = Math.max(start >= 0 ? start : length + start, 0);
29
+ const finalEnd = Math.min(end >= 0 ? end : length + end, length);
30
+ for (let i = finalStart; i < finalEnd; i++) {
31
+ array[i] = value;
31
32
  }
32
- return arr;
33
+ return array;
33
34
  }
34
35
  // Annotate the CommonJS export names for ESM import in node:
35
36
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array. Negative indices can be used to specify positions from the end of the array.\n *\n * @param {Array<T | P>} arr - The array to fill.\n * @param {P} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | P>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n */\n\nexport function fill<T>(arr: unknown[], value: T): T[];\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start = 0, end = arr.length): Array<T | P> {\n start = Math.max(start, 0);\n end = Math.min(end, arr.length);\n\n for (let i = start; i < end; i++) {\n arr[i] = value;\n }\n\n return arr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,SAAS,KAAW,KAAmB,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AACjG,UAAQ,KAAK,IAAI,OAAO,CAAC;AACzB,QAAM,KAAK,IAAI,KAAK,IAAI,MAAM;AAE9B,WAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAChC,QAAI,CAAC,IAAI;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value: T): T[];\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n const length = array.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n for (let i = finalStart; i < finalEnd; i++) {\n array[i] = value;\n }\n\n return array;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,SAAS,KAAW,OAAqB,OAAU,QAAQ,GAAG,MAAM,MAAM,QAAsB;AACrG,QAAM,SAAS,MAAM;AACrB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,UAAM,CAAC,IAAI;AAAA,EACb;AAEA,SAAO;AACT;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fill
3
- } from "../chunk-C4WE4GLC.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
3
+ } from "../chunk-YFN6KOC4.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  fill
7
7
  };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
3
+ *
4
+ * @template T - The type of elements within the array.
5
+ * @template U - The type of elements within the returned array from the iteratee function.
6
+ * @template D - The depth to which the array should be flattened.
7
+ * @param {T[]} arr - The array to flatten.
8
+ * @param {(item: T) => U} iteratee - The function that produces the new array elements.
9
+ * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
10
+ * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.
11
+ *
12
+ * @example
13
+ * const arr = [1, 2, 3];
14
+ *
15
+ * flatMap(arr, (item: number) => [item, item]);
16
+ * // [1, 1, 2, 2, 3, 3]
17
+ *
18
+ * flatMap(arr, (item: number) => [[item, item]], 2);
19
+ * // [1, 1, 2, 2, 3, 3]
20
+ */
21
+ declare function flatMap<T, U, D extends number>(arr: readonly T[], iteratee: (item: T) => U, depth?: D): Array<FlatArray<U[], D>>;
22
+
23
+ export { flatMap };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.
3
+ *
4
+ * @template T - The type of elements within the array.
5
+ * @template U - The type of elements within the returned array from the iteratee function.
6
+ * @template D - The depth to which the array should be flattened.
7
+ * @param {T[]} arr - The array to flatten.
8
+ * @param {(item: T) => U} iteratee - The function that produces the new array elements.
9
+ * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
10
+ * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.
11
+ *
12
+ * @example
13
+ * const arr = [1, 2, 3];
14
+ *
15
+ * flatMap(arr, (item: number) => [item, item]);
16
+ * // [1, 1, 2, 2, 3, 3]
17
+ *
18
+ * flatMap(arr, (item: number) => [[item, item]], 2);
19
+ * // [1, 1, 2, 2, 3, 3]
20
+ */
21
+ declare function flatMap<T, U, D extends number>(arr: readonly T[], iteratee: (item: T) => U, depth?: D): Array<FlatArray<U[], D>>;
22
+
23
+ export { flatMap };
@@ -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/flatMap.ts
21
+ var flatMap_exports = {};
22
+ __export(flatMap_exports, {
23
+ flatMap: () => flatMap
24
+ });
25
+ module.exports = __toCommonJS(flatMap_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/flatMap.ts
45
+ function flatMap(arr, iteratee, depth = 1) {
46
+ return flatten(arr.map((item) => iteratee(item)), depth);
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ flatMap
51
+ });
52
+ //# sourceMappingURL=flatMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/array/flatMap.ts","../../src/array/flatten.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.\n *\n * @example\n * const arr = [1, 2, 3];\n *\n * flatMap(arr, (item: number) => [item, item]);\n * // [1, 1, 2, 2, 3, 3]\n *\n * flatMap(arr, (item: number) => [[item, item]], 2);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMap<T, U, D extends number>(\n arr: readonly T[],\n iteratee: (item: T) => U,\n depth = 1 as D\n): Array<FlatArray<U[], D>> {\n return flatten(arr.map(item => iteratee(item)), depth);\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;;;ADVO,SAAS,QACd,KACA,UACA,QAAQ,GACkB;AAC1B,SAAO,QAAQ,IAAI,IAAI,UAAQ,SAAS,IAAI,CAAC,GAAG,KAAK;AACvD;","names":["arr"]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ flatMap
3
+ } from "../chunk-UY76KTPE.mjs";
4
+ import "../chunk-33MSBDC6.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
+ export {
7
+ flatMap
8
+ };
9
+ //# sourceMappingURL=flatMap.mjs.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  flatten
3
3
  } from "../chunk-33MSBDC6.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.mjs";
5
5
  export {
6
6
  flatten
7
7
  };
@@ -2,7 +2,7 @@ import {
2
2
  flattenDeep
3
3
  } from "../chunk-ML727RRJ.mjs";
4
4
  import "../chunk-33MSBDC6.mjs";
5
- import "../chunk-2MM5EJJX.mjs";
5
+ import "../chunk-424M7IR7.mjs";
6
6
  export {
7
7
  flattenDeep
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  forEachRight
3
3
  } from "../chunk-IEA53J7P.mjs";
4
- import "../chunk-2MM5EJJX.mjs";
4
+ import "../chunk-424M7IR7.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-424M7IR7.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-424M7IR7.mjs";
5
5
  export {
6
6
  head
7
7
  };
@@ -9,6 +9,7 @@ export { dropRight } from './dropRight.mjs';
9
9
  export { dropRightWhile } from './dropRightWhile.mjs';
10
10
  export { dropWhile } from './dropWhile.mjs';
11
11
  export { fill } from './fill.mjs';
12
+ export { flatMap } from './flatMap.mjs';
12
13
  export { flatten } from './flatten.mjs';
13
14
  export { flattenDeep } from './flattenDeep.mjs';
14
15
  export { forEachRight } from './forEachRight.mjs';
@@ -9,6 +9,7 @@ export { dropRight } from './dropRight.js';
9
9
  export { dropRightWhile } from './dropRightWhile.js';
10
10
  export { dropWhile } from './dropWhile.js';
11
11
  export { fill } from './fill.js';
12
+ export { flatMap } from './flatMap.js';
12
13
  export { flatten } from './flatten.js';
13
14
  export { flattenDeep } from './flattenDeep.js';
14
15
  export { forEachRight } from './forEachRight.js';
@@ -31,6 +31,7 @@ __export(array_exports, {
31
31
  dropRightWhile: () => dropRightWhile,
32
32
  dropWhile: () => dropWhile,
33
33
  fill: () => fill,
34
+ flatMap: () => flatMap,
34
35
  flatten: () => flatten,
35
36
  flattenDeep: () => flattenDeep,
36
37
  forEachRight: () => forEachRight,
@@ -135,12 +136,27 @@ function differenceWith(firstArr, secondArr, areItemsEqual) {
135
136
 
136
137
  // src/array/drop.ts
137
138
  function drop(arr, itemsCount) {
139
+ itemsCount = Math.max(itemsCount, 0);
138
140
  return arr.slice(itemsCount);
139
141
  }
140
142
 
141
143
  // src/array/dropRight.ts
142
144
  function dropRight(arr, itemsCount) {
143
- return arr.slice(0, -itemsCount);
145
+ itemsCount = Math.min(-itemsCount, 0);
146
+ if (itemsCount === 0) {
147
+ return arr.slice();
148
+ }
149
+ return arr.slice(0, itemsCount);
150
+ }
151
+
152
+ // src/array/dropRightWhile.ts
153
+ function dropRightWhile(arr, canContinueDropping) {
154
+ for (let i = arr.length - 1; i >= 0; i--) {
155
+ if (!canContinueDropping(arr[i])) {
156
+ return arr.slice(0, i + 1);
157
+ }
158
+ }
159
+ return [];
144
160
  }
145
161
 
146
162
  // src/array/dropWhile.ts
@@ -152,21 +168,15 @@ function dropWhile(arr, canContinueDropping) {
152
168
  return arr.slice(dropEndIndex);
153
169
  }
154
170
 
155
- // src/array/dropRightWhile.ts
156
- function dropRightWhile(arr, canContinueDropping) {
157
- const reversed = arr.slice().reverse();
158
- const dropped = dropWhile(reversed, canContinueDropping);
159
- return dropped.slice().reverse();
160
- }
161
-
162
171
  // src/array/fill.ts
163
- function fill(arr, value, start = 0, end = arr.length) {
164
- start = Math.max(start, 0);
165
- end = Math.min(end, arr.length);
166
- for (let i = start; i < end; i++) {
167
- arr[i] = value;
172
+ function fill(array, value, start = 0, end = array.length) {
173
+ const length = array.length;
174
+ const finalStart = Math.max(start >= 0 ? start : length + start, 0);
175
+ const finalEnd = Math.min(end >= 0 ? end : length + end, length);
176
+ for (let i = finalStart; i < finalEnd; i++) {
177
+ array[i] = value;
168
178
  }
169
- return arr;
179
+ return array;
170
180
  }
171
181
 
172
182
  // src/array/flatten.ts
@@ -186,6 +196,11 @@ function flatten(arr, depth = 1) {
186
196
  return result;
187
197
  }
188
198
 
199
+ // src/array/flatMap.ts
200
+ function flatMap(arr, iteratee, depth = 1) {
201
+ return flatten(arr.map((item) => iteratee(item)), depth);
202
+ }
203
+
189
204
  // src/array/flattenDeep.ts
190
205
  function flattenDeep(arr) {
191
206
  return flatten(arr, Infinity);
@@ -597,6 +612,7 @@ function initial(arr) {
597
612
  dropRightWhile,
598
613
  dropWhile,
599
614
  fill,
615
+ flatMap,
600
616
  flatten,
601
617
  flattenDeep,
602
618
  forEachRight,