es-toolkit 1.0.3 → 1.0.4-dev.39

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 (471) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/{esm/array/chunk.mjs → dist/array/chunk.d.mts} +1 -13
  3. package/dist/array/chunk.d.ts +3 -1
  4. package/dist/array/chunk.js +43 -0
  5. package/dist/array/chunk.js.map +1 -0
  6. package/dist/array/chunk.mjs +8 -0
  7. package/dist/array/chunk.mjs.map +1 -0
  8. package/{esm/array/difference.mjs → dist/array/difference.d.mts} +8 -12
  9. package/dist/array/difference.d.ts +3 -1
  10. package/dist/array/difference.js +35 -0
  11. package/dist/array/difference.js.map +1 -0
  12. package/dist/array/difference.mjs +8 -0
  13. package/dist/array/difference.mjs.map +1 -0
  14. package/{esm/array/differenceBy.mjs → dist/array/differenceBy.d.mts} +10 -17
  15. package/dist/array/differenceBy.d.ts +3 -1
  16. package/dist/array/differenceBy.js +36 -0
  17. package/dist/array/differenceBy.js.map +1 -0
  18. package/dist/array/differenceBy.mjs +8 -0
  19. package/dist/array/differenceBy.mjs.map +1 -0
  20. package/{esm/array/differenceWith.mjs → dist/array/differenceWith.d.mts} +6 -12
  21. package/dist/array/differenceWith.d.ts +3 -1
  22. package/dist/array/differenceWith.js +37 -0
  23. package/dist/array/differenceWith.js.map +1 -0
  24. package/dist/array/differenceWith.mjs +8 -0
  25. package/dist/array/differenceWith.mjs.map +1 -0
  26. package/{esm/array/drop.mjs → dist/array/drop.d.mts} +4 -6
  27. package/dist/array/drop.d.ts +3 -1
  28. package/dist/array/drop.js +33 -0
  29. package/dist/array/drop.js.map +1 -0
  30. package/dist/array/drop.mjs +8 -0
  31. package/dist/array/drop.mjs.map +1 -0
  32. package/{esm/array/dropRight.mjs → dist/array/dropRight.d.mts} +3 -5
  33. package/dist/array/dropRight.d.ts +3 -1
  34. package/dist/array/dropRight.js +33 -0
  35. package/dist/array/dropRight.js.map +1 -0
  36. package/dist/array/dropRight.mjs +8 -0
  37. package/dist/array/dropRight.mjs.map +1 -0
  38. package/{esm/array/dropRightWhile.mjs → dist/array/dropRightWhile.d.mts} +5 -11
  39. package/dist/array/dropRightWhile.d.ts +3 -1
  40. package/dist/array/dropRightWhile.js +43 -0
  41. package/dist/array/dropRightWhile.js.map +1 -0
  42. package/dist/array/dropRightWhile.mjs +9 -0
  43. package/dist/array/dropRightWhile.mjs.map +1 -0
  44. package/{esm/array/dropWhile.mjs → dist/array/dropWhile.d.mts} +5 -10
  45. package/dist/array/dropWhile.d.ts +3 -1
  46. package/dist/array/dropWhile.js +34 -0
  47. package/dist/array/dropWhile.js.map +1 -0
  48. package/dist/array/dropWhile.mjs +8 -0
  49. package/dist/array/dropWhile.mjs.map +1 -0
  50. package/{esm/array/groupBy.mjs → dist/array/groupBy.d.mts} +5 -26
  51. package/dist/array/groupBy.d.ts +3 -1
  52. package/dist/array/groupBy.js +41 -0
  53. package/dist/array/groupBy.js.map +1 -0
  54. package/dist/array/groupBy.mjs +8 -0
  55. package/dist/array/groupBy.mjs.map +1 -0
  56. package/dist/array/index.d.ts +30 -30
  57. package/dist/array/index.js +199 -842
  58. package/dist/array/index.js.map +1 -0
  59. package/dist/array/index.mjs +125 -0
  60. package/dist/array/index.mjs.map +1 -0
  61. package/{esm/array/intersection.mjs → dist/array/intersection.d.mts} +4 -8
  62. package/dist/array/intersection.d.ts +3 -1
  63. package/dist/array/intersection.js +35 -0
  64. package/dist/array/intersection.js.map +1 -0
  65. package/dist/array/intersection.mjs +8 -0
  66. package/dist/array/intersection.mjs.map +1 -0
  67. package/{esm/array/intersectionBy.mjs → dist/array/intersectionBy.d.mts} +5 -12
  68. package/dist/array/intersectionBy.d.ts +3 -1
  69. package/dist/array/intersectionBy.js +36 -0
  70. package/dist/array/intersectionBy.js.map +1 -0
  71. package/dist/array/intersectionBy.mjs +8 -0
  72. package/dist/array/intersectionBy.mjs.map +1 -0
  73. package/{esm/array/intersectionWith.mjs → dist/array/intersectionWith.d.mts} +6 -12
  74. package/dist/array/intersectionWith.d.ts +3 -1
  75. package/dist/array/intersectionWith.js +37 -0
  76. package/dist/array/intersectionWith.js.map +1 -0
  77. package/dist/array/intersectionWith.mjs +8 -0
  78. package/dist/array/intersectionWith.mjs.map +1 -0
  79. package/{esm/array/partition.mjs → dist/array/partition.d.mts} +8 -30
  80. package/dist/array/partition.d.ts +3 -1
  81. package/dist/array/partition.js +42 -0
  82. package/dist/array/partition.js.map +1 -0
  83. package/dist/array/partition.mjs +8 -0
  84. package/dist/array/partition.mjs.map +1 -0
  85. package/{esm/array/sample.mjs → dist/array/sample.d.mts} +2 -5
  86. package/dist/array/sample.d.ts +3 -1
  87. package/dist/array/sample.js +34 -0
  88. package/dist/array/sample.js.map +1 -0
  89. package/dist/array/sample.mjs +8 -0
  90. package/dist/array/sample.mjs.map +1 -0
  91. package/{esm/array/shuffle.mjs → dist/array/shuffle.d.mts} +2 -13
  92. package/dist/array/shuffle.d.ts +3 -1
  93. package/dist/array/shuffle.js +37 -0
  94. package/dist/array/shuffle.js.map +1 -0
  95. package/dist/array/shuffle.mjs +8 -0
  96. package/dist/array/shuffle.mjs.map +1 -0
  97. package/{esm/array/take.mjs → dist/array/take.d.mts} +5 -7
  98. package/dist/array/take.d.ts +3 -1
  99. package/dist/array/take.js +33 -0
  100. package/dist/array/take.js.map +1 -0
  101. package/dist/array/take.mjs +8 -0
  102. package/dist/array/take.mjs.map +1 -0
  103. package/{esm/array/takeRight.mjs → dist/array/takeRight.d.mts} +5 -10
  104. package/dist/array/takeRight.d.ts +3 -1
  105. package/dist/array/takeRight.js +36 -0
  106. package/dist/array/takeRight.js.map +1 -0
  107. package/dist/array/takeRight.mjs +8 -0
  108. package/dist/array/takeRight.mjs.map +1 -0
  109. package/{esm/array/takeRightWhile.mjs → dist/array/takeRightWhile.d.mts} +5 -12
  110. package/dist/array/takeRightWhile.d.ts +3 -1
  111. package/dist/array/takeRightWhile.js +38 -0
  112. package/dist/array/takeRightWhile.js.map +1 -0
  113. package/dist/array/takeRightWhile.mjs +8 -0
  114. package/dist/array/takeRightWhile.mjs.map +1 -0
  115. package/{esm/array/takeWhile.mjs → dist/array/takeWhile.d.mts} +1 -21
  116. package/dist/array/takeWhile.d.ts +3 -1
  117. package/dist/array/takeWhile.js +40 -0
  118. package/dist/array/takeWhile.js.map +1 -0
  119. package/dist/array/takeWhile.mjs +8 -0
  120. package/dist/array/takeWhile.mjs.map +1 -0
  121. package/{esm/array/union.mjs → dist/array/union.d.mts} +3 -7
  122. package/dist/array/union.d.ts +3 -1
  123. package/dist/array/union.js +47 -0
  124. package/dist/array/union.js.map +1 -0
  125. package/dist/array/union.mjs +9 -0
  126. package/dist/array/union.mjs.map +1 -0
  127. package/{esm/array/unionBy.mjs → dist/array/unionBy.d.mts} +4 -16
  128. package/dist/array/unionBy.d.ts +3 -1
  129. package/dist/array/unionBy.js +40 -0
  130. package/dist/array/unionBy.js.map +1 -0
  131. package/dist/array/unionBy.mjs +8 -0
  132. package/dist/array/unionBy.mjs.map +1 -0
  133. package/{esm/array/unionWith.mjs → dist/array/unionWith.d.mts} +4 -8
  134. package/dist/array/unionWith.d.ts +3 -1
  135. package/dist/array/unionWith.js +47 -0
  136. package/dist/array/unionWith.js.map +1 -0
  137. package/dist/array/unionWith.mjs +9 -0
  138. package/dist/array/unionWith.mjs.map +1 -0
  139. package/dist/array/uniq.d.mts +17 -0
  140. package/dist/array/uniq.d.ts +3 -1
  141. package/dist/array/uniq.js +40 -0
  142. package/dist/array/uniq.js.map +1 -0
  143. package/dist/array/uniq.mjs +8 -0
  144. package/dist/array/uniq.mjs.map +1 -0
  145. package/{esm/array/uniqBy.mjs → dist/array/uniqBy.d.mts} +1 -7
  146. package/dist/array/uniqBy.d.ts +3 -1
  147. package/dist/array/uniqBy.js +47 -0
  148. package/dist/array/uniqBy.js.map +1 -0
  149. package/dist/array/uniqBy.mjs +9 -0
  150. package/dist/array/uniqBy.mjs.map +1 -0
  151. package/dist/array/uniqWith.d.mts +14 -0
  152. package/dist/array/uniqWith.d.ts +3 -1
  153. package/dist/array/uniqWith.js +40 -0
  154. package/dist/array/uniqWith.js.map +1 -0
  155. package/dist/array/uniqWith.mjs +8 -0
  156. package/dist/array/uniqWith.mjs.map +1 -0
  157. package/{esm/array/xor.mjs → dist/array/xor.d.mts} +4 -10
  158. package/dist/array/xor.d.ts +3 -1
  159. package/dist/array/xor.js +66 -0
  160. package/dist/array/xor.js.map +1 -0
  161. package/dist/array/xor.mjs +12 -0
  162. package/dist/array/xor.mjs.map +1 -0
  163. package/{esm/array/xorBy.mjs → dist/array/xorBy.d.mts} +5 -13
  164. package/dist/array/xorBy.d.ts +3 -1
  165. package/dist/array/xorBy.js +65 -0
  166. package/dist/array/xorBy.js.map +1 -0
  167. package/dist/array/xorBy.mjs +11 -0
  168. package/dist/array/xorBy.mjs.map +1 -0
  169. package/{esm/array/xorWith.mjs → dist/array/xorWith.d.mts} +5 -13
  170. package/dist/array/xorWith.d.ts +3 -1
  171. package/dist/array/xorWith.js +72 -0
  172. package/dist/array/xorWith.js.map +1 -0
  173. package/dist/array/xorWith.mjs +12 -0
  174. package/dist/array/xorWith.mjs.map +1 -0
  175. package/dist/array/zip.d.mts +27 -0
  176. package/dist/array/zip.d.ts +6 -4
  177. package/dist/array/zip.js +42 -0
  178. package/dist/array/zip.js.map +1 -0
  179. package/dist/array/zip.mjs +8 -0
  180. package/dist/array/zip.mjs.map +1 -0
  181. package/{esm/array/zipWith.mjs → dist/array/zipWith.d.mts} +6 -26
  182. package/dist/array/zipWith.d.ts +6 -4
  183. package/dist/array/zipWith.js +41 -0
  184. package/dist/array/zipWith.js.map +1 -0
  185. package/dist/array/zipWith.mjs +8 -0
  186. package/dist/array/zipWith.mjs.map +1 -0
  187. package/dist/chunk-2KXLTAVK.mjs +16 -0
  188. package/dist/chunk-2KXLTAVK.mjs.map +1 -0
  189. package/dist/chunk-2MM5EJJX.mjs +21 -0
  190. package/dist/chunk-2MM5EJJX.mjs.map +1 -0
  191. package/dist/chunk-2VB6XU3I.mjs +12 -0
  192. package/dist/chunk-2VB6XU3I.mjs.map +1 -0
  193. package/dist/chunk-35TWSMYS.mjs +19 -0
  194. package/dist/chunk-35TWSMYS.mjs.map +1 -0
  195. package/dist/chunk-5JWSGT4R.mjs +18 -0
  196. package/dist/chunk-5JWSGT4R.mjs.map +1 -0
  197. package/dist/chunk-724PNXPR.mjs +13 -0
  198. package/dist/chunk-724PNXPR.mjs.map +1 -0
  199. package/dist/chunk-7GWOR247.mjs +11 -0
  200. package/dist/chunk-7GWOR247.mjs.map +1 -0
  201. package/dist/chunk-7OZZODAE.mjs +19 -0
  202. package/dist/chunk-7OZZODAE.mjs.map +1 -0
  203. package/dist/chunk-7PPND7QY.mjs +16 -0
  204. package/dist/chunk-7PPND7QY.mjs.map +1 -0
  205. package/dist/chunk-7SJHJHBN.mjs +11 -0
  206. package/dist/chunk-7SJHJHBN.mjs.map +1 -0
  207. package/dist/chunk-ARWKEQMQ.mjs +19 -0
  208. package/dist/chunk-ARWKEQMQ.mjs.map +1 -0
  209. package/dist/chunk-ARZ5BDR6.mjs +1 -0
  210. package/dist/chunk-ARZ5BDR6.mjs.map +1 -0
  211. package/dist/chunk-BAJC3BM7.mjs +12 -0
  212. package/dist/chunk-BAJC3BM7.mjs.map +1 -0
  213. package/dist/chunk-EAI4DDCQ.mjs +16 -0
  214. package/dist/chunk-EAI4DDCQ.mjs.map +1 -0
  215. package/dist/chunk-EAI6NLXI.mjs +12 -0
  216. package/dist/chunk-EAI6NLXI.mjs.map +1 -0
  217. package/dist/chunk-EJGAXTF7.mjs +1 -0
  218. package/dist/chunk-EJGAXTF7.mjs.map +1 -0
  219. package/dist/chunk-FUWEG5ZM.mjs +9 -0
  220. package/dist/chunk-FUWEG5ZM.mjs.map +1 -0
  221. package/dist/chunk-GJM7F3TH.mjs +13 -0
  222. package/dist/chunk-GJM7F3TH.mjs.map +1 -0
  223. package/dist/chunk-HQF6OFGM.mjs +9 -0
  224. package/dist/chunk-HQF6OFGM.mjs.map +1 -0
  225. package/dist/chunk-IJLQVGW4.mjs +1 -0
  226. package/dist/chunk-IJLQVGW4.mjs.map +1 -0
  227. package/dist/chunk-J3NTLMAE.mjs +10 -0
  228. package/dist/chunk-J3NTLMAE.mjs.map +1 -0
  229. package/dist/chunk-JMLFPGZ3.mjs +13 -0
  230. package/dist/chunk-JMLFPGZ3.mjs.map +1 -0
  231. package/dist/chunk-L4Y3G6AJ.mjs +23 -0
  232. package/dist/chunk-L4Y3G6AJ.mjs.map +1 -0
  233. package/dist/chunk-LAZNLIBJ.mjs +10 -0
  234. package/dist/chunk-LAZNLIBJ.mjs.map +1 -0
  235. package/dist/chunk-MAJSPFA6.mjs +1 -0
  236. package/dist/chunk-MAJSPFA6.mjs.map +1 -0
  237. package/dist/chunk-NEMQJ2GF.mjs +18 -0
  238. package/dist/chunk-NEMQJ2GF.mjs.map +1 -0
  239. package/dist/chunk-NK2262VG.mjs +9 -0
  240. package/dist/chunk-NK2262VG.mjs.map +1 -0
  241. package/dist/chunk-NSYWEYWT.mjs +13 -0
  242. package/dist/chunk-NSYWEYWT.mjs.map +1 -0
  243. package/dist/chunk-NYVT33DR.mjs +9 -0
  244. package/dist/chunk-NYVT33DR.mjs.map +1 -0
  245. package/dist/chunk-OBMK7JO2.mjs +13 -0
  246. package/dist/chunk-OBMK7JO2.mjs.map +1 -0
  247. package/dist/chunk-PTQLD7TG.mjs +11 -0
  248. package/dist/chunk-PTQLD7TG.mjs.map +1 -0
  249. package/dist/chunk-PWMHSN27.mjs +14 -0
  250. package/dist/chunk-PWMHSN27.mjs.map +1 -0
  251. package/dist/chunk-QRQPLMV4.mjs +16 -0
  252. package/dist/chunk-QRQPLMV4.mjs.map +1 -0
  253. package/dist/chunk-R5DNKXDI.mjs +21 -0
  254. package/dist/chunk-R5DNKXDI.mjs.map +1 -0
  255. package/dist/chunk-RK6PRCEJ.mjs +12 -0
  256. package/dist/chunk-RK6PRCEJ.mjs.map +1 -0
  257. package/dist/chunk-RLDY4N3Q.mjs +13 -0
  258. package/dist/chunk-RLDY4N3Q.mjs.map +1 -0
  259. package/dist/chunk-RU3RXBUC.mjs +17 -0
  260. package/dist/chunk-RU3RXBUC.mjs.map +1 -0
  261. package/dist/chunk-S767XFOS.mjs +10 -0
  262. package/dist/chunk-S767XFOS.mjs.map +1 -0
  263. package/dist/chunk-SGSQKXDO.mjs +15 -0
  264. package/dist/chunk-SGSQKXDO.mjs.map +1 -0
  265. package/dist/chunk-SYQTG4N4.mjs +1 -0
  266. package/dist/chunk-SYQTG4N4.mjs.map +1 -0
  267. package/dist/chunk-T5JCRGXA.mjs +1 -0
  268. package/dist/chunk-T5JCRGXA.mjs.map +1 -0
  269. package/dist/chunk-TOLR2FNF.mjs +13 -0
  270. package/dist/chunk-TOLR2FNF.mjs.map +1 -0
  271. package/dist/chunk-UNX3KZO2.mjs +17 -0
  272. package/dist/chunk-UNX3KZO2.mjs.map +1 -0
  273. package/dist/chunk-UZP4YX7I.mjs +17 -0
  274. package/dist/chunk-UZP4YX7I.mjs.map +1 -0
  275. package/dist/chunk-VACGGQOL.mjs +9 -0
  276. package/dist/chunk-VACGGQOL.mjs.map +1 -0
  277. package/dist/chunk-VAKCSKGR.mjs +17 -0
  278. package/dist/chunk-VAKCSKGR.mjs.map +1 -0
  279. package/dist/chunk-VJGGYY4Y.mjs +13 -0
  280. package/dist/chunk-VJGGYY4Y.mjs.map +1 -0
  281. package/dist/chunk-WFQ3LAHQ.mjs +9 -0
  282. package/dist/chunk-WFQ3LAHQ.mjs.map +1 -0
  283. package/dist/chunk-XS4ZPJMT.mjs +21 -0
  284. package/dist/chunk-XS4ZPJMT.mjs.map +1 -0
  285. package/dist/chunk-XW452I77.mjs +16 -0
  286. package/dist/chunk-XW452I77.mjs.map +1 -0
  287. package/dist/chunk-YMNXRH52.mjs +9 -0
  288. package/dist/chunk-YMNXRH52.mjs.map +1 -0
  289. package/dist/chunk-Z4IO7EIH.mjs +16 -0
  290. package/dist/chunk-Z4IO7EIH.mjs.map +1 -0
  291. package/{esm/function/debounce.mjs → dist/function/debounce.d.mts} +5 -18
  292. package/dist/function/debounce.d.ts +3 -1
  293. package/dist/function/debounce.js +47 -0
  294. package/dist/function/debounce.js.map +1 -0
  295. package/dist/function/debounce.mjs +8 -0
  296. package/dist/function/debounce.mjs.map +1 -0
  297. package/dist/function/index.d.ts +3 -3
  298. package/dist/function/index.js +47 -78
  299. package/dist/function/index.js.map +1 -0
  300. package/dist/function/index.mjs +17 -0
  301. package/dist/function/index.mjs.map +1 -0
  302. package/{esm/function/once.mjs → dist/function/once.d.mts} +2 -14
  303. package/dist/function/once.d.ts +3 -1
  304. package/dist/function/once.js +43 -0
  305. package/dist/function/once.js.map +1 -0
  306. package/dist/function/once.mjs +8 -0
  307. package/dist/function/once.mjs.map +1 -0
  308. package/{esm/function/throttle.mjs → dist/function/throttle.d.mts} +3 -13
  309. package/dist/function/throttle.d.ts +3 -1
  310. package/dist/function/throttle.js +41 -0
  311. package/dist/function/throttle.js.map +1 -0
  312. package/dist/function/throttle.mjs +8 -0
  313. package/dist/function/throttle.mjs.map +1 -0
  314. package/dist/index.d.ts +45 -6
  315. package/dist/index.js +288 -1271
  316. package/dist/index.js.map +1 -0
  317. package/dist/index.mjs +190 -0
  318. package/dist/index.mjs.map +1 -0
  319. package/{esm/math/clamp.mjs → dist/math/clamp.d.mts} +2 -7
  320. package/dist/math/clamp.d.ts +4 -2
  321. package/dist/math/clamp.js +36 -0
  322. package/dist/math/clamp.js.map +1 -0
  323. package/dist/math/clamp.mjs +8 -0
  324. package/dist/math/clamp.mjs.map +1 -0
  325. package/dist/math/index.d.ts +3 -3
  326. package/dist/math/index.js +41 -132
  327. package/dist/math/index.js.map +1 -0
  328. package/dist/math/index.mjs +17 -0
  329. package/dist/math/index.mjs.map +1 -0
  330. package/{esm/math/round.mjs → dist/math/round.d.mts} +3 -7
  331. package/dist/math/round.d.ts +3 -1
  332. package/dist/math/round.js +34 -0
  333. package/dist/math/round.js.map +1 -0
  334. package/dist/math/round.mjs +8 -0
  335. package/dist/math/round.mjs.map +1 -0
  336. package/dist/math/sum.d.mts +16 -0
  337. package/dist/math/sum.d.ts +3 -1
  338. package/dist/math/sum.js +37 -0
  339. package/dist/math/sum.js.map +1 -0
  340. package/dist/math/sum.mjs +8 -0
  341. package/dist/math/sum.mjs.map +1 -0
  342. package/dist/object/index.d.ts +4 -4
  343. package/dist/object/index.js +62 -256
  344. package/dist/object/index.js.map +1 -0
  345. package/dist/object/index.mjs +21 -0
  346. package/dist/object/index.mjs.map +1 -0
  347. package/{esm/object/omit.mjs → dist/object/omit.d.mts} +2 -19
  348. package/dist/object/omit.d.ts +3 -1
  349. package/dist/object/omit.js +51 -0
  350. package/dist/object/omit.js.map +1 -0
  351. package/dist/object/omit.mjs +8 -0
  352. package/dist/object/omit.mjs.map +1 -0
  353. package/{esm/object/omitBy.mjs → dist/object/omitBy.d.mts} +4 -18
  354. package/dist/object/omitBy.d.ts +3 -1
  355. package/dist/object/omitBy.js +40 -0
  356. package/dist/object/omitBy.js.map +1 -0
  357. package/dist/object/omitBy.mjs +8 -0
  358. package/dist/object/omitBy.mjs.map +1 -0
  359. package/{esm/object/pick.mjs → dist/object/pick.d.mts} +2 -19
  360. package/dist/object/pick.d.ts +3 -1
  361. package/dist/object/pick.js +37 -0
  362. package/dist/object/pick.js.map +1 -0
  363. package/dist/object/pick.mjs +8 -0
  364. package/dist/object/pick.mjs.map +1 -0
  365. package/{esm/object/pickBy.mjs → dist/object/pickBy.d.mts} +4 -18
  366. package/dist/object/pickBy.d.ts +3 -1
  367. package/dist/object/pickBy.js +40 -0
  368. package/dist/object/pickBy.js.map +1 -0
  369. package/dist/object/pickBy.mjs +8 -0
  370. package/dist/object/pickBy.mjs.map +1 -0
  371. package/dist/predicate/index.d.ts +4 -4
  372. package/dist/predicate/index.js +42 -84
  373. package/dist/predicate/index.js.map +1 -0
  374. package/dist/predicate/index.mjs +21 -0
  375. package/dist/predicate/index.mjs.map +1 -0
  376. package/{esm/predicate/isNil.mjs → dist/predicate/isNil.d.mts} +4 -6
  377. package/dist/predicate/isNil.d.ts +3 -1
  378. package/dist/predicate/isNil.js +33 -0
  379. package/dist/predicate/isNil.js.map +1 -0
  380. package/dist/predicate/isNil.mjs +8 -0
  381. package/dist/predicate/isNil.mjs.map +1 -0
  382. package/{esm/predicate/isNotNil.mjs → dist/predicate/isNotNil.d.mts} +2 -4
  383. package/dist/predicate/isNotNil.d.ts +3 -1
  384. package/dist/predicate/isNotNil.js +33 -0
  385. package/dist/predicate/isNotNil.js.map +1 -0
  386. package/dist/predicate/isNotNil.mjs +8 -0
  387. package/dist/predicate/isNotNil.mjs.map +1 -0
  388. package/{esm/predicate/isNull.mjs → dist/predicate/isNull.d.mts} +4 -6
  389. package/dist/predicate/isNull.d.ts +3 -1
  390. package/dist/predicate/isNull.js +33 -0
  391. package/dist/predicate/isNull.js.map +1 -0
  392. package/dist/predicate/isNull.mjs +8 -0
  393. package/dist/predicate/isNull.mjs.map +1 -0
  394. package/{esm/predicate/isUndefined.mjs → dist/predicate/isUndefined.d.mts} +4 -6
  395. package/dist/predicate/isUndefined.d.ts +3 -1
  396. package/dist/predicate/isUndefined.js +33 -0
  397. package/dist/predicate/isUndefined.js.map +1 -0
  398. package/dist/predicate/isUndefined.mjs +8 -0
  399. package/dist/predicate/isUndefined.mjs.map +1 -0
  400. package/{esm/promise/delay.mjs → dist/promise/delay.d.mts} +4 -8
  401. package/dist/promise/delay.d.ts +3 -1
  402. package/dist/promise/delay.js +35 -0
  403. package/dist/promise/delay.js.map +1 -0
  404. package/dist/promise/delay.mjs +8 -0
  405. package/dist/promise/delay.mjs.map +1 -0
  406. package/dist/promise/index.d.ts +1 -1
  407. package/dist/promise/index.js +31 -23
  408. package/dist/promise/index.js.map +1 -0
  409. package/dist/promise/index.mjs +9 -0
  410. package/dist/promise/index.mjs.map +1 -0
  411. package/package.json +120 -49
  412. package/dist/array/chunk.spec.d.ts +0 -1
  413. package/dist/array/difference.spec.d.ts +0 -1
  414. package/dist/array/differenceBy.spec.d.ts +0 -1
  415. package/dist/array/differenceWith.spec.d.ts +0 -1
  416. package/dist/array/drop.spec.d.ts +0 -1
  417. package/dist/array/dropRight.spec.d.ts +0 -1
  418. package/dist/array/dropRightWhile.spec.d.ts +0 -1
  419. package/dist/array/dropWhile.spec.d.ts +0 -1
  420. package/dist/array/groupBy.spec.d.ts +0 -1
  421. package/dist/array/intersection.spec.d.ts +0 -1
  422. package/dist/array/intersectionBy.spec.d.ts +0 -1
  423. package/dist/array/intersectionWith.spec.d.ts +0 -1
  424. package/dist/array/partition.spec.d.ts +0 -1
  425. package/dist/array/sample.spec.d.ts +0 -1
  426. package/dist/array/shuffle.spec.d.ts +0 -1
  427. package/dist/array/take.spec.d.ts +0 -1
  428. package/dist/array/takeRight.spec.d.ts +0 -1
  429. package/dist/array/takeRightWhile.spec.d.ts +0 -1
  430. package/dist/array/takeWhile.spec.d.ts +0 -1
  431. package/dist/array/union.spec.d.ts +0 -1
  432. package/dist/array/unionBy.spec.d.ts +0 -1
  433. package/dist/array/unionWith.spec.d.ts +0 -1
  434. package/dist/array/uniq.spec.d.ts +0 -1
  435. package/dist/array/uniqBy.spec.d.ts +0 -1
  436. package/dist/array/uniqWith.spec.d.ts +0 -1
  437. package/dist/array/xor.spec.d.ts +0 -1
  438. package/dist/array/xorBy.spec.d.ts +0 -1
  439. package/dist/array/xorWith.spec.d.ts +0 -1
  440. package/dist/array/zip.spec.d.ts +0 -1
  441. package/dist/array/zipWith.spec.d.ts +0 -1
  442. package/dist/function/debounce.spec.d.ts +0 -1
  443. package/dist/function/once.spec.d.ts +0 -1
  444. package/dist/function/throttle.spec.d.ts +0 -1
  445. package/dist/math/clamp.spec.d.ts +0 -1
  446. package/dist/math/round.spec.d.ts +0 -1
  447. package/dist/math/sum.spec.d.ts +0 -1
  448. package/dist/object/omit.spec.d.ts +0 -1
  449. package/dist/object/omitBy.spec.d.ts +0 -1
  450. package/dist/object/pick.spec.d.ts +0 -1
  451. package/dist/object/pickBy.spec.d.ts +0 -1
  452. package/dist/predicate/isNil.spec.d.ts +0 -1
  453. package/dist/predicate/isNotNil.spec.d.ts +0 -1
  454. package/dist/predicate/isNull.spec.d.ts +0 -1
  455. package/dist/predicate/isUndefined.spec.d.ts +0 -1
  456. package/dist/promise/delay.spec.d.ts +0 -1
  457. package/esm/_virtual/_rollupPluginBabelHelpers.mjs +0 -163
  458. package/esm/array/_virtual/_rollupPluginBabelHelpers.mjs +0 -78
  459. package/esm/array/uniq.mjs +0 -37
  460. package/esm/array/uniqWith.mjs +0 -39
  461. package/esm/array/zip.mjs +0 -52
  462. package/esm/math/_virtual/_rollupPluginBabelHelpers.mjs +0 -66
  463. package/esm/math/sum.mjs +0 -33
  464. package/esm/object/_virtual/_rollupPluginBabelHelpers.mjs +0 -151
  465. /package/{esm/array/index.mjs → dist/array/index.d.mts} +0 -0
  466. /package/{esm/function/index.mjs → dist/function/index.d.mts} +0 -0
  467. /package/{esm/index.mjs → dist/index.d.mts} +0 -0
  468. /package/{esm/math/index.mjs → dist/math/index.d.mts} +0 -0
  469. /package/{esm/object/index.mjs → dist/object/index.d.mts} +0 -0
  470. /package/{esm/predicate/index.mjs → dist/predicate/index.d.mts} +0 -0
  471. /package/{esm/promise/index.mjs → dist/promise/index.d.mts} +0 -0
@@ -1,562 +1,192 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /**
6
- * Splits an array into smaller arrays of a specified length.
7
- *
8
- * This function takes an input array and divides it into multiple smaller arrays,
9
- * each of a specified length. If the input array cannot be evenly divided,
10
- * the final sub-array will contain the remaining elements.
11
- *
12
- * @template T The type of elements in the array.
13
- * @param {T[]} arr - The array to be chunked into smaller arrays.
14
- * @param {number} size - The size of each smaller array. Must be a positive integer.
15
- * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
16
- * @throws {Error} Throws an error if `size` is not a positive integer.
17
- *
18
- * @example
19
- * // Splits an array of numbers into sub-arrays of length 2
20
- * chunk([1, 2, 3, 4, 5], 2);
21
- * // Returns: [[1, 2], [3, 4], [5]]
22
- *
23
- * @example
24
- * // Splits an array of strings into sub-arrays of length 3
25
- * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
26
- * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
27
- */
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/index.ts
21
+ var array_exports = {};
22
+ __export(array_exports, {
23
+ chunk: () => chunk,
24
+ difference: () => difference,
25
+ differenceBy: () => differenceBy,
26
+ differenceWith: () => differenceWith,
27
+ drop: () => drop,
28
+ dropRight: () => dropRight,
29
+ dropRightWhile: () => dropRightWhile,
30
+ dropWhile: () => dropWhile,
31
+ groupBy: () => groupBy,
32
+ intersection: () => intersection,
33
+ intersectionBy: () => intersectionBy,
34
+ intersectionWith: () => intersectionWith,
35
+ partition: () => partition,
36
+ sample: () => sample,
37
+ shuffle: () => shuffle,
38
+ take: () => take,
39
+ takeRight: () => takeRight,
40
+ takeRightWhile: () => takeRightWhile,
41
+ takeWhile: () => takeWhile,
42
+ union: () => union,
43
+ unionBy: () => unionBy,
44
+ unionWith: () => unionWith,
45
+ uniq: () => uniq,
46
+ uniqBy: () => uniqBy,
47
+ uniqWith: () => uniqWith,
48
+ xor: () => xor,
49
+ xorBy: () => xorBy,
50
+ xorWith: () => xorWith,
51
+ zip: () => zip,
52
+ zipWith: () => zipWith
53
+ });
54
+ module.exports = __toCommonJS(array_exports);
55
+
56
+ // src/array/chunk.ts
28
57
  function chunk(arr, size) {
29
58
  if (!Number.isInteger(size) || size <= 0) {
30
- throw new Error('Size must be an integer greater than zero.');
59
+ throw new Error("Size must be an integer greater than zero.");
31
60
  }
32
- var chunkLength = Math.ceil(arr.length / size);
33
- var result = Array(chunkLength);
34
- for (var index = 0; index < chunkLength; index++) {
35
- var start = index * size;
36
- var end = start + size;
61
+ const chunkLength = Math.ceil(arr.length / size);
62
+ const result = Array(chunkLength);
63
+ for (let index = 0; index < chunkLength; index++) {
64
+ const start = index * size;
65
+ const end = start + size;
37
66
  result[index] = arr.slice(start, end);
38
67
  }
39
68
  return result;
40
69
  }
41
70
 
42
- /**
43
- * Computes the difference between two arrays.
44
- *
45
- * This function takes two arrays and returns a new array containing the elements
46
- * that are present in the first array but not in the second array. It effectively
47
- * filters out any elements from the first array that also appear in the second array.
48
- *
49
- * @template T
50
- * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
51
- * from which elements will be compared and filtered.
52
- * @param {T[]} secondArr - The array containing elements to be excluded from the first array.
53
- * Each element in this array will be checked against the first array, and if a match is found,
54
- * that element will be excluded from the result.
55
- * @returns {T[]} A new array containing the elements that are present in the first array but not
56
- * in the second array.
57
- *
58
- * @example
59
- * * const array1 = [1, 2, 3, 4, 5];
60
- * const array2 = [2, 4];
61
- * const result = difference(array1, array2);
62
- * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
63
- */
71
+ // src/array/difference.ts
64
72
  function difference(firstArr, secondArr) {
65
- return firstArr.filter(function (item) {
73
+ return firstArr.filter((item) => {
66
74
  return !secondArr.includes(item);
67
75
  });
68
76
  }
69
77
 
70
- /**
71
- * Computes the difference between two arrays after mapping their elements through a provided function.
72
- *
73
- * This function takes two arrays and a mapper function. It returns a new array containing the elements
74
- * that are present in the first array but not in the second array, based on the identity calculated
75
- * by the mapper function.
76
- *
77
- * Essentially, it filters out any elements from the first array that, when
78
- * mapped, match an element in the mapped version of the second array.
79
- *
80
- * @template T, U
81
- * @param {T[]} firstArr - The primary array from which to derive the difference.
82
- * @param {T[]} secondArr - The array containing elements to be excluded from the first array.
83
- * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function
84
- * is applied to each element in both arrays, and the comparison is made based on the mapped values.
85
- * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding
86
- * mapped identity in the second array.
87
- *
88
- * @example
89
- * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
90
- * const array2 = [{ id: 2 }, { id: 4 }];
91
- * const mapper = item => item.id;
92
- * const result = differenceBy(array1, array2, mapper);
93
- * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
94
- */
78
+ // src/array/differenceBy.ts
95
79
  function differenceBy(firstArr, secondArr, mapper) {
96
- var mappedSecondArr = secondArr.map(function (item) {
97
- return mapper(item);
98
- });
99
- return firstArr.filter(function (item) {
80
+ const mappedSecondArr = secondArr.map((item) => mapper(item));
81
+ return firstArr.filter((item) => {
100
82
  return !mappedSecondArr.includes(mapper(item));
101
83
  });
102
84
  }
103
85
 
104
- /**
105
- * Computes the difference between two arrays based on a custom equality function.
106
- *
107
- * This function takes two arrays and a custom comparison function. It returns a new array containing
108
- * the elements that are present in the first array but not in the second array. The comparison to determine
109
- * if elements are equal is made using the provided custom function.
110
- *
111
- * @template T
112
- * @param {T[]} firstArr - The array from which to get the difference.
113
- * @param {T[]} secondArr - The array containing elements to exclude from the first array.
114
- * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
115
- * @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array
116
- * according to the custom equality function.
117
- *
118
- * @example
119
- * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
120
- * const array2 = [{ id: 2 }, { id: 4 }];
121
- * const areItemsEqual = (a, b) => a.id === b.id;
122
- * const result = differenceWith(array1, array2, areItemsEqual);
123
- * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
124
- */
86
+ // src/array/differenceWith.ts
125
87
  function differenceWith(firstArr, secondArr, areItemsEqual) {
126
- return firstArr.filter(function (firstItem) {
127
- return secondArr.every(function (secondItem) {
88
+ return firstArr.filter((firstItem) => {
89
+ return secondArr.every((secondItem) => {
128
90
  return !areItemsEqual(firstItem, secondItem);
129
91
  });
130
92
  });
131
93
  }
132
94
 
133
- /**
134
- * Removes a specified number of elements from the beginning of an array and returns the rest.
135
- *
136
- * This function takes an array and a number, and returns a new array with the specified number
137
- * of elements removed from the start.
138
- *
139
- * @param {T[]} arr - The array from which to drop elements.
140
- * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
141
- * @returns {T[]} A new array with the specified number of elements removed from the start.
142
- *
143
- * @example
144
- * * const array = [1, 2, 3, 4, 5];
145
- * const result = drop(array, 2);
146
- * // result will be [3, 4, 5] since the first two elements are dropped.
147
- */
95
+ // src/array/drop.ts
148
96
  function drop(arr, itemsCount) {
149
97
  return arr.slice(itemsCount);
150
98
  }
151
99
 
152
- /**
153
- * Removes a specified number of elements from the end of an array and returns the rest.
154
- *
155
- * This function takes an array and a number, and returns a new array with the specified number
156
- * of elements removed from the end.
157
- *
158
- * @param {T[]} arr - The array from which to drop elements.
159
- * @param {number} itemsCount - The number of elements to drop from the end of the array.
160
- * @returns {T[]} A new array with the specified number of elements removed from the end.
161
- *
162
- * @example
163
- * * const array = [1, 2, 3, 4, 5];
164
- * const result = dropRight(array, 2);
165
- * // result will be [1, 2, 3] since the last two elements are dropped.
166
- */
100
+ // src/array/dropRight.ts
167
101
  function dropRight(arr, itemsCount) {
168
102
  return arr.slice(0, -itemsCount);
169
103
  }
170
104
 
171
- /**
172
- * Removes elements from the beginning of an array until the predicate returns false.
173
- *
174
- * This function iterates over an array and drops elements from the start until the provided
175
- * predicate function returns false. It then returns a new array with the remaining elements.
176
- *
177
- * @param {T[]} arr - The array from which to drop elements.
178
- * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
179
- * whether to continue dropping elements. The function is called with each element, and dropping
180
- * continues as long as it returns true.
181
- * @returns {T[]} A new array with the elements remaining after the predicate returns false.
182
- *
183
- * @example
184
- * const array = [1, 2, 3, 4, 5];
185
- * const result = dropWhile(array, x => x < 3);
186
- * // result will be [3, 4, 5] since elements less than 3 are dropped.
187
- */
105
+ // src/array/dropWhile.ts
188
106
  function dropWhile(arr, canContinueDropping) {
189
- var dropEndIndex = arr.findIndex(function (item) {
190
- return !canContinueDropping(item);
191
- });
107
+ const dropEndIndex = arr.findIndex((item) => !canContinueDropping(item));
192
108
  return arr.slice(dropEndIndex);
193
109
  }
194
110
 
195
- /**
196
- * Removes elements from the end of an array until the predicate returns false.
197
- *
198
- * This function iterates over an array from the end and drops elements until the provided
199
- * predicate function returns false. It then returns a new array with the remaining elements.
200
- *
201
- * @param {T[]} arr - The array from which to drop elements.
202
- * @param {function(item: T): boolean} canContinueDropping - A predicate function that determines
203
- * whether to continue dropping elements. The function is called with each element from the end,
204
- * and dropping continues as long as it returns true.
205
- * @returns {T[]} A new array with the elements remaining after the predicate returns false.
206
- *
207
- * @example
208
- * const array = [1, 2, 3, 4, 5];
209
- * const result = dropRightWhile(array, x => x > 3);
210
- * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
211
- */
111
+ // src/array/dropRightWhile.ts
212
112
  function dropRightWhile(arr, canContinueDropping) {
213
- var reversed = arr.slice().reverse();
214
- var dropped = dropWhile(reversed, canContinueDropping);
113
+ const reversed = arr.slice().reverse();
114
+ const dropped = dropWhile(reversed, canContinueDropping);
215
115
  return dropped.slice().reverse();
216
116
  }
217
117
 
218
- function _toConsumableArray(arr) {
219
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
220
- }
221
- function _arrayWithoutHoles(arr) {
222
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
223
- }
224
- function _iterableToArray(iter) {
225
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
226
- }
227
- function _unsupportedIterableToArray(o, minLen) {
228
- if (!o) return;
229
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
230
- var n = Object.prototype.toString.call(o).slice(8, -1);
231
- if (n === "Object" && o.constructor) n = o.constructor.name;
232
- if (n === "Map" || n === "Set") return Array.from(o);
233
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
234
- }
235
- function _arrayLikeToArray(arr, len) {
236
- if (len == null || len > arr.length) len = arr.length;
237
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
238
- return arr2;
239
- }
240
- function _nonIterableSpread() {
241
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
242
- }
243
- function _createForOfIteratorHelper(o, allowArrayLike) {
244
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
245
- if (!it) {
246
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
247
- if (it) o = it;
248
- var i = 0;
249
- var F = function () {};
250
- return {
251
- s: F,
252
- n: function () {
253
- if (i >= o.length) return {
254
- done: true
255
- };
256
- return {
257
- done: false,
258
- value: o[i++]
259
- };
260
- },
261
- e: function (e) {
262
- throw e;
263
- },
264
- f: F
265
- };
266
- }
267
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
268
- }
269
- var normalCompletion = true,
270
- didErr = false,
271
- err;
272
- return {
273
- s: function () {
274
- it = it.call(o);
275
- },
276
- n: function () {
277
- var step = it.next();
278
- normalCompletion = step.done;
279
- return step;
280
- },
281
- e: function (e) {
282
- didErr = true;
283
- err = e;
284
- },
285
- f: function () {
286
- try {
287
- if (!normalCompletion && it.return != null) it.return();
288
- } finally {
289
- if (didErr) throw err;
290
- }
291
- }
292
- };
293
- }
294
-
295
- /**
296
- * Groups the elements of an array based on a provided key-generating function.
297
- *
298
- * This function takes an array and a function that generates a key from each element. It returns
299
- * an object where the keys are the generated keys and the values are arrays of elements that share
300
- * the same key.
301
- *
302
- * @param {T[]} arr - The array to group.
303
- * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
304
- * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
305
- * share that key.
306
- *
307
- * @example
308
- * const array = [
309
- * { category: 'fruit', name: 'apple' },
310
- * { category: 'fruit', name: 'banana' },
311
- * { category: 'vegetable', name: 'carrot' }
312
- * ];
313
- * const result = groupBy(array, item => item.category);
314
- * // result will be:
315
- * // {
316
- * // fruit: [
317
- * // { category: 'fruit', name: 'apple' },
318
- * // { category: 'fruit', name: 'banana' }
319
- * // ],
320
- * // vegetable: [
321
- * // { category: 'vegetable', name: 'carrot' }
322
- * // ]
323
- * // }
324
- */
118
+ // src/array/groupBy.ts
325
119
  function groupBy(arr, getKeyFromItem) {
326
- var result = {};
327
- var _iterator = _createForOfIteratorHelper(arr),
328
- _step;
329
- try {
330
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
331
- var item = _step.value;
332
- var key = getKeyFromItem(item);
333
- if (result[key] == null) {
334
- result[key] = [];
335
- }
336
- result[key].push(item);
120
+ const result = {};
121
+ for (const item of arr) {
122
+ const key = getKeyFromItem(item);
123
+ if (result[key] == null) {
124
+ result[key] = [];
337
125
  }
338
- } catch (err) {
339
- _iterator.e(err);
340
- } finally {
341
- _iterator.f();
126
+ result[key].push(item);
342
127
  }
343
128
  return result;
344
129
  }
345
130
 
346
- /**
347
- * Returns the intersection of two arrays.
348
- *
349
- * This function takes two arrays and returns a new array containing the elements that are
350
- * present in both arrays. It effectively filters out any elements from the first array that
351
- * are not found in the second array.
352
- *
353
- * @param {T[]} firstArr - The first array to compare.
354
- * @param {T[]} secondArr - The second array to compare.
355
- * @returns {T[]} A new array containing the elements that are present in both arrays.
356
- *
357
- * @example
358
- * const array1 = [1, 2, 3, 4, 5];
359
- * const array2 = [3, 4, 5, 6, 7];
360
- * const result = intersection(array1, array2);
361
- * // result will be [3, 4, 5] since these elements are in both arrays.
362
- */
131
+ // src/array/intersection.ts
363
132
  function intersection(firstArr, secondArr) {
364
- return firstArr.filter(function (item) {
133
+ return firstArr.filter((item) => {
365
134
  return secondArr.includes(item);
366
135
  });
367
136
  }
368
137
 
369
- /**
370
- * Returns the intersection of two arrays based on a mapping function.
371
- *
372
- * This function takes two arrays and a mapping function. It returns a new array containing
373
- * the elements from the first array that, when mapped using the provided function, have matching
374
- * mapped elements in the second array. It effectively filters out any elements from the first array
375
- * that do not have corresponding mapped values in the second array.
376
- *
377
- * @param {T[]} firstArr - The first array to compare.
378
- * @param {T[]} secondArr - The second array to compare.
379
- * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
380
- * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.
381
- *
382
- * @example
383
- * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
384
- * const array2 = [{ id: 2 }, { id: 4 }];
385
- * const mapper = item => item.id;
386
- * const result = intersectionBy(array1, array2, mapper);
387
- * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
388
- */
138
+ // src/array/intersectionBy.ts
389
139
  function intersectionBy(firstArr, secondArr, mapper) {
390
- var mappedSecondArr = secondArr.map(function (x) {
391
- return mapper(x);
392
- });
393
- return firstArr.filter(function (item) {
140
+ const mappedSecondArr = secondArr.map((x) => mapper(x));
141
+ return firstArr.filter((item) => {
394
142
  return mappedSecondArr.includes(mapper(item));
395
143
  });
396
144
  }
397
145
 
398
- /**
399
- * Returns the intersection of two arrays based on a custom equality function.
400
- *
401
- * This function takes two arrays and a custom equality function. It returns a new array containing
402
- * the elements from the first array that have matching elements in the second array, as determined
403
- * by the custom equality function. It effectively filters out any elements from the first array that
404
- * do not have corresponding matches in the second array according to the equality function.
405
- *
406
- * @param {T[]} firstArr - The first array to compare.
407
- * @param {T[]} secondArr - The second array to compare.
408
- * @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
409
- * This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.
410
- * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.
411
- *
412
- * @example
413
- * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
414
- * const array2 = [{ id: 2 }, { id: 4 }];
415
- * const areItemsEqual = (a, b) => a.id === b.id;
416
- * const result = intersectionWith(array1, array2, areItemsEqual);
417
- * // result will be [{ id: 2 }] since this element has a matching id in both arrays.
418
- */
146
+ // src/array/intersectionWith.ts
419
147
  function intersectionWith(firstArr, secondArr, areItemsEqual) {
420
- return firstArr.filter(function (firstItem) {
421
- return secondArr.some(function (secondItem) {
148
+ return firstArr.filter((firstItem) => {
149
+ return secondArr.some((secondItem) => {
422
150
  return areItemsEqual(firstItem, secondItem);
423
151
  });
424
152
  });
425
153
  }
426
154
 
427
- /**
428
- * Splits an array into two groups based on a predicate function.
429
- *
430
- * This function takes an array and a predicate function. It returns a tuple of two arrays:
431
- * the first array contains elements for which the predicate function returns true, and
432
- * the second array contains elements for which the predicate function returns false.
433
- *
434
- * @param {T[]} arr - The array to partition.
435
- * @param {(value: T) => boolean} isInTruthy - A predicate function that determines
436
- * whether an element should be placed in the truthy array. The function is called with each
437
- * element of the array.
438
- * @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for
439
- * which the predicate returned true, and the second array contains elements for which the
440
- * predicate returned false.
441
- *
442
- * @example
443
- * const array = [1, 2, 3, 4, 5];
444
- * const isEven = x => x % 2 === 0;
445
- * const [even, odd] = partition(array, isEven);
446
- * // even will be [2, 4], and odd will be [1, 3, 5]
447
- */
155
+ // src/array/partition.ts
448
156
  function partition(arr, isInTruthy) {
449
- var truthy = [];
450
- var falsy = [];
451
- var _iterator = _createForOfIteratorHelper(arr),
452
- _step;
453
- try {
454
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
455
- var item = _step.value;
456
- if (isInTruthy(item)) {
457
- truthy.push(item);
458
- } else {
459
- falsy.push(item);
460
- }
157
+ const truthy = [];
158
+ const falsy = [];
159
+ for (const item of arr) {
160
+ if (isInTruthy(item)) {
161
+ truthy.push(item);
162
+ } else {
163
+ falsy.push(item);
461
164
  }
462
- } catch (err) {
463
- _iterator.e(err);
464
- } finally {
465
- _iterator.f();
466
165
  }
467
166
  return [truthy, falsy];
468
167
  }
469
168
 
470
- /**
471
- * Returns a random element from an array.
472
- *
473
- * This function takes an array and returns a single element selected randomly from the array.
474
- *
475
- * @param {T[]} arr - The array to sample from.
476
- * @returns {T} A random element from the array.
477
- *
478
- * @example
479
- * const array = [1, 2, 3, 4, 5];
480
- * const randomElement = sample(array);
481
- * // randomElement will be one of the elements from the array, selected randomly.
482
- */
169
+ // src/array/sample.ts
483
170
  function sample(arr) {
484
- var randomIndex = Math.floor(Math.random() * arr.length);
171
+ const randomIndex = Math.floor(Math.random() * arr.length);
485
172
  return arr[randomIndex];
486
173
  }
487
174
 
488
- /**
489
- * Randomizes the order of elements in an array using the Fisher-Yates algorithm.
490
- *
491
- * This function takes an array and returns a new array with its elements shuffled in a random order.
492
- *
493
- * @param {T[]} arr - The array to shuffle.
494
- * @returns {T[]} A new array with its elements shuffled in random order.
495
- *
496
- * @example
497
- * const array = [1, 2, 3, 4, 5];
498
- * const shuffledArray = shuffle(array);
499
- * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
500
- */
175
+ // src/array/shuffle.ts
501
176
  function shuffle(arr) {
502
- /**
503
- * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
504
- */
505
- for (var i = arr.length - 1; i >= 1; i--) {
506
- var j = Math.floor(Math.random() * (i + 1));
507
- var _ref = [arr[j], arr[i]];
508
- arr[i] = _ref[0];
509
- arr[j] = _ref[1];
177
+ for (let i = arr.length - 1; i >= 1; i--) {
178
+ const j = Math.floor(Math.random() * (i + 1));
179
+ [arr[i], arr[j]] = [arr[j], arr[i]];
510
180
  }
511
181
  return arr;
512
182
  }
513
183
 
514
- /**
515
- * Returns a new array containing the first `count` elements from the input array `arr`.
516
- * If `count` is greater than the length of `arr`, the entire array is returned.
517
- *
518
- * @template T - Type of elements in the input array.
519
- *
520
- * @param {T[]} arr - The array to take elements from.
521
- * @param {number} count - The number of elements to take.
522
- * @returns {T[]} A new array containing the first `count` elements from `arr`.
523
- *
524
- * @example
525
- * // Returns [1, 2, 3]
526
- * take([1, 2, 3, 4, 5], 3);
527
- *
528
- * @example
529
- * // Returns ['a', 'b']
530
- * take(['a', 'b', 'c'], 2);
531
- *
532
- * @example
533
- * // Returns [1, 2, 3]
534
- * take([1, 2, 3], 5);
535
- */
184
+ // src/array/take.ts
536
185
  function take(arr, count) {
537
186
  return arr.slice(0, count);
538
187
  }
539
188
 
540
- /**
541
- * Returns a new array containing the last `count` elements from the input array `arr`.
542
- * If `count` is greater than the length of `arr`, the entire array is returned.
543
- *
544
- * @param {T[]} arr - The array to take elements from.
545
- * @param {number} count - The number of elements to take.
546
- * @returns {T[]} A new array containing the last `count` elements from `arr`.
547
- *
548
- * @example
549
- * // Returns [4, 5]
550
- * takeRight([1, 2, 3, 4, 5], 2);
551
- *
552
- * @example
553
- * // Returns ['b', 'c']
554
- * takeRight(['a', 'b', 'c'], 2);
555
- *
556
- * @example
557
- * // Returns [1, 2, 3]
558
- * takeRight([1, 2, 3], 5);
559
- */
189
+ // src/array/takeRight.ts
560
190
  function takeRight(arr, count) {
561
191
  if (count === 0) {
562
192
  return [];
@@ -564,25 +194,9 @@ function takeRight(arr, count) {
564
194
  return arr.slice(-count);
565
195
  }
566
196
 
567
- /**
568
- * Takes elements from the end of the array while the predicate function returns `true`.
569
- *
570
- * @template T - Type of elements in the input array.
571
- *
572
- * @param {T[]} arr - The array to take elements from.
573
- * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.
574
- * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
575
- *
576
- * @example
577
- * // Returns [3, 2, 1]
578
- * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
579
- *
580
- * @example
581
- * // Returns []
582
- * takeRightWhile([1, 2, 3], n => n > 3);
583
- */
197
+ // src/array/takeRightWhile.ts
584
198
  function takeRightWhile(arr, shouldContinueTaking) {
585
- for (var i = arr.length - 1; i >= 0; i--) {
199
+ for (let i = arr.length - 1; i >= 0; i--) {
586
200
  if (!shouldContinueTaking(arr[i])) {
587
201
  return arr.slice(i + 1);
588
202
  }
@@ -590,402 +204,145 @@ function takeRightWhile(arr, shouldContinueTaking) {
590
204
  return arr.slice();
591
205
  }
592
206
 
593
- /**
594
- * Returns a new array containing the leading elements of the provided array
595
- * that satisfy the provided predicate function. It stops taking elements as soon
596
- * as an element does not satisfy the predicate.
597
- *
598
- * @template T - The type of elements in the array.
599
- * @param {T[]} arr - The array to process.
600
- * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.
601
- * @returns {T[]} A new array containing the leading elements that satisfy the predicate.
602
- *
603
- * @example
604
- * // Returns [1, 2]
605
- * takeWhile([1, 2, 3, 4], x => x < 3);
606
- *
607
- * @example
608
- * // Returns []
609
- * takeWhile([1, 2, 3, 4], x => x > 3);
610
- */
207
+ // src/array/takeWhile.ts
611
208
  function takeWhile(arr, shouldContinueTaking) {
612
- var result = [];
613
- var _iterator = _createForOfIteratorHelper(arr),
614
- _step;
615
- try {
616
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
617
- var item = _step.value;
618
- if (!shouldContinueTaking(item)) {
619
- break;
620
- }
621
- result.push(item);
209
+ const result = [];
210
+ for (const item of arr) {
211
+ if (!shouldContinueTaking(item)) {
212
+ break;
622
213
  }
623
- } catch (err) {
624
- _iterator.e(err);
625
- } finally {
626
- _iterator.f();
214
+ result.push(item);
627
215
  }
628
216
  return result;
629
217
  }
630
218
 
631
- /**
632
- * Creates a duplicate-free version of an array.
633
- *
634
- * This function takes an array and returns a new array containing only the unique values
635
- * from the original array, preserving the order of first occurrence.
636
- *
637
- * @param {T[]} arr - The array to process.
638
- * @returns {T[]} A new array with only unique values from the original array.
639
- *
640
- * @example
641
- * * const array = [1, 2, 2, 3, 4, 4, 5];
642
- * const result = uniq(array);
643
- * // result will be [1, 2, 3, 4, 5]
644
- */
219
+ // src/array/uniq.ts
645
220
  function uniq(arr) {
646
- var result = [];
647
- var _iterator = _createForOfIteratorHelper(arr),
648
- _step;
649
- try {
650
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
651
- var item = _step.value;
652
- if (result.includes(item)) {
653
- continue;
654
- }
655
- result.push(item);
221
+ const result = [];
222
+ for (const item of arr) {
223
+ if (result.includes(item)) {
224
+ continue;
656
225
  }
657
- } catch (err) {
658
- _iterator.e(err);
659
- } finally {
660
- _iterator.f();
226
+ result.push(item);
661
227
  }
662
228
  return result;
663
229
  }
664
230
 
665
- /**
666
- * Creates an array of unique values from all given arrays.
667
- *
668
- * This function takes two arrays, merges them into a single array, and returns a new array
669
- * containing only the unique values from the merged array.
670
- *
671
- * @param {T[]} arr1 - The first array to merge and filter for unique values.
672
- * @param {T[]} arr2 - The second array to merge and filter for unique values.
673
- * @returns {T[]} A new array of unique values.
674
- *
675
- * @example
676
- * const array1 = [1, 2, 3];
677
- * const array2 = [3, 4, 5];
678
- * const result = union(array1, array2);
679
- * // result will be [1, 2, 3, 4, 5]
680
- */
231
+ // src/array/union.ts
681
232
  function union(arr1, arr2) {
682
233
  return uniq(arr1.concat(arr2));
683
234
  }
684
235
 
685
- /**
686
- * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
687
- *
688
- * @param {T[]} arr1 - The first array.
689
- * @param {T[]} arr2 - The second array.
690
- * @param {function(item: T): U} mapper - The function to map array elements to comparison values.
691
- * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.
692
- *
693
- * @example
694
- * // Custom mapping function for numbers (modulo comparison)
695
- * const moduloMapper = (x) => x % 3;
696
- * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);
697
- * // Returns [1, 2, 3]
698
- *
699
- * @example
700
- * // Custom mapping function for objects with an 'id' property
701
- * const idMapper = (obj) => obj.id;
702
- * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
703
- * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
704
- */
236
+ // src/array/unionBy.ts
705
237
  function unionBy(arr1, arr2, mapper) {
706
- var map = new Map();
707
- for (var _i = 0, _arr = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)); _i < _arr.length; _i++) {
708
- var item = _arr[_i];
709
- var key = mapper(item);
238
+ const map = /* @__PURE__ */ new Map();
239
+ for (const item of [...arr1, ...arr2]) {
240
+ const key = mapper(item);
710
241
  if (!map.has(key)) {
711
242
  map.set(key, item);
712
243
  }
713
244
  }
714
- return _toConsumableArray(map.values());
245
+ return [...map.values()];
715
246
  }
716
247
 
717
- /**
718
- * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
719
- *
720
- * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.
721
- *
722
- * @example
723
- * ```ts
724
- * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
725
- * // [1, 2, 3, 5, 7]
726
- * ```
727
- */
248
+ // src/array/uniqWith.ts
728
249
  function uniqWith(arr, areItemsEqual) {
729
- var result = [];
730
- var _iterator = _createForOfIteratorHelper(arr),
731
- _step;
732
- try {
733
- var _loop = function _loop() {
734
- var item = _step.value;
735
- var isUniq = result.every(function (v) {
736
- return !areItemsEqual(v, item);
737
- });
738
- if (isUniq) {
739
- result.push(item);
740
- }
741
- };
742
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
743
- _loop();
250
+ const result = [];
251
+ for (const item of arr) {
252
+ const isUniq = result.every((v) => !areItemsEqual(v, item));
253
+ if (isUniq) {
254
+ result.push(item);
744
255
  }
745
- } catch (err) {
746
- _iterator.e(err);
747
- } finally {
748
- _iterator.f();
749
256
  }
750
257
  return result;
751
258
  }
752
259
 
753
- /**
754
- * Creates an array of unique values from two given arrays based on a custom equality function.
755
- *
756
- * This function takes two arrays and a custom equality function, merges the arrays, and returns
757
- * a new array containing only the unique values as determined by the custom equality function.
758
- *
759
- * @param {T[]} arr1 - The first array to merge and filter for unique values.
760
- * @param {T[]} arr2 - The second array to merge and filter for unique values.
761
- * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
762
- * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.
763
- * @returns {T[]} A new array of unique values based on the custom equality function.
764
- *
765
- * @example
766
- * const array1 = [{ id: 1 }, { id: 2 }];
767
- * const array2 = [{ id: 2 }, { id: 3 }];
768
- * const areItemsEqual = (a, b) => a.id === b.id;
769
- * const result = unionWith(array1, array2, areItemsEqual);
770
- * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
771
- */
260
+ // src/array/unionWith.ts
772
261
  function unionWith(arr1, arr2, areItemsEqual) {
773
262
  return uniqWith(arr1.concat(arr2), areItemsEqual);
774
263
  }
775
264
 
776
- /**
777
- * The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
778
- *
779
- * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
780
- *
781
- * @example
782
- * ```ts
783
- * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
784
- * // [1.2, 2.1, 3.3, 5.7, 7.19]
785
- * ```
786
- */
265
+ // src/array/uniqBy.ts
787
266
  function uniqBy(arr, converter) {
788
- return uniqWith(arr, function (item1, item2) {
789
- return converter(item1) === converter(item2);
790
- });
267
+ return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));
791
268
  }
792
269
 
793
- /**
794
- * Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
795
- * which are in either of the arrays, but not in their intersection.
796
- *
797
- * @param {T[]} arr1 - The first array.
798
- * @param {T[]} arr2 - The second array.
799
- * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
800
- *
801
- * @example
802
- * // Returns [1, 2, 5, 6]
803
- * xor([1, 2, 3, 4], [3, 4, 5, 6]);
804
- *
805
- * @example
806
- * // Returns ['a', 'c']
807
- * xor(['a', 'b'], ['b', 'c']);
808
- */
270
+ // src/array/xor.ts
809
271
  function xor(arr1, arr2) {
810
272
  return difference(union(arr1, arr2), intersection(arr1, arr2));
811
273
  }
812
274
 
813
- /**
814
- * Computes the symmetric difference between two arrays using a custom mapping function.
815
- * The symmetric difference is the set of elements which are in either of the arrays,
816
- * but not in their intersection, determined by the result of the mapping function.
817
- *
818
- * @template T - Type of elements in the input arrays.
819
- * @template U - Type of the values returned by the mapping function.
820
- *
821
- * @param {T[]} arr1 - The first array.
822
- * @param {T[]} arr2 - The second array.
823
- * @param {function(item: T): U} mapper - The function to map array elements to comparison values.
824
- * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
825
- *
826
- * @example
827
- * // Custom mapping function for objects with an 'id' property
828
- * const idMapper = obj => obj.id;
829
- * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
830
- * // Returns [{ id: 1 }, { id: 3 }]
831
- */
275
+ // src/array/xorBy.ts
832
276
  function xorBy(arr1, arr2, mapper) {
833
- var union = unionBy(arr1, arr2, mapper);
834
- var intersection = intersectionBy(arr1, arr2, mapper);
835
- return differenceBy(union, intersection, mapper);
277
+ const union2 = unionBy(arr1, arr2, mapper);
278
+ const intersection2 = intersectionBy(arr1, arr2, mapper);
279
+ return differenceBy(union2, intersection2, mapper);
836
280
  }
837
281
 
838
- /**
839
- * Computes the symmetric difference between two arrays using a custom equality function.
840
- * The symmetric difference is the set of elements which are in either of the arrays,
841
- * but not in their intersection.
842
- *
843
- * @template T - Type of elements in the input arrays.
844
- *
845
- * @param {T[]} arr1 - The first array.
846
- * @param {T[]} arr2 - The second array.
847
- * @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
848
- * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
849
- *
850
- * @example
851
- * // Custom equality function for objects with an 'id' property
852
- * const areObjectsEqual = (a, b) => a.id === b.id;
853
- * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
854
- * // Returns [{ id: 1 }, { id: 3 }]
855
- */
282
+ // src/array/xorWith.ts
856
283
  function xorWith(arr1, arr2, areElementsEqual) {
857
- var union = unionWith(arr1, arr2, areElementsEqual);
858
- var intersection = intersectionWith(arr1, arr2, areElementsEqual);
859
- return differenceWith(union, intersection, areElementsEqual);
860
- }
861
-
862
- /**
863
- * Combines multiple arrays into a single array of tuples.
864
- *
865
- * This function takes multiple arrays and returns a new array where each element is a tuple
866
- * containing the corresponding elements from the input arrays. If the input arrays are of
867
- * different lengths, the resulting array will have the length of the longest input array,
868
- * with undefined values for missing elements.
869
- *
870
- * @param {...T[][]} arrs - The arrays to zip together.
871
- * @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
872
- *
873
- * @example
874
- * const arr1 = [1, 2, 3];
875
- * const arr2 = ['a', 'b', 'c'];
876
- * const result = zip(arr1, arr2);
877
- * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
878
- *
879
- * const arr3 = [true, false];
880
- * const result2 = zip(arr1, arr2, arr3);
881
- * // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
882
- */
883
-
884
- function zip() {
885
- var result = [];
886
- for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
887
- arrs[_key] = arguments[_key];
888
- }
889
- var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
890
- return x.length;
891
- })));
892
- for (var i = 0; i < maxIndex; i++) {
893
- var element = [];
894
- var _iterator = _createForOfIteratorHelper(arrs),
895
- _step;
896
- try {
897
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
898
- var arr = _step.value;
899
- element.push(arr[i]);
900
- }
901
- } catch (err) {
902
- _iterator.e(err);
903
- } finally {
904
- _iterator.f();
284
+ const union2 = unionWith(arr1, arr2, areElementsEqual);
285
+ const intersection2 = intersectionWith(arr1, arr2, areElementsEqual);
286
+ return differenceWith(union2, intersection2, areElementsEqual);
287
+ }
288
+
289
+ // src/array/zip.ts
290
+ function zip(...arrs) {
291
+ const result = [];
292
+ const maxIndex = Math.max(...arrs.map((x) => x.length));
293
+ for (let i = 0; i < maxIndex; i++) {
294
+ const element = [];
295
+ for (const arr of arrs) {
296
+ element.push(arr[i]);
905
297
  }
906
298
  result.push(element);
907
299
  }
908
300
  return result;
909
301
  }
910
302
 
911
- /**
912
- * Combines multiple arrays into a single array using a custom combiner function.
913
- *
914
- * This function takes multiple arrays and a combiner function, and returns a new array where each element
915
- * is the result of applying the combiner function to the corresponding elements of the input arrays.
916
- *
917
- * @param {T[]} arr1 - The first array to zip.
918
- * @param {U[]} [arr2] - The second array to zip (optional).
919
- * @param {V[]} [arr3] - The third array to zip (optional).
920
- * @param {W[]} [arr4] - The fourth array to zip (optional).
921
- * @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.
922
- * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
923
- *
924
- * @example
925
- * // Example usage with two arrays:
926
- * const arr1 = [1, 2, 3];
927
- * const arr2 = [4, 5, 6];
928
- * const result = zipWith(arr1, arr2, (a, b) => a + b);
929
- * // result will be [5, 7, 9]
930
- *
931
- * @example
932
- * // Example usage with three arrays:
933
- * const arr1 = [1, 2];
934
- * const arr2 = [3, 4];
935
- * const arr3 = [5, 6];
936
- * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
937
- * // result will be [`135`, `246`]
938
- */
939
-
940
- function zipWith(arr1) {
941
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
942
- rest[_key - 1] = arguments[_key];
943
- }
944
- var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
945
- var combine = rest[rest.length - 1];
946
- var result = [];
947
- var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
948
- return arr.length;
949
- })));
950
- var _loop = function _loop(i) {
951
- var elements = arrs.map(function (arr) {
952
- return arr[i];
953
- });
954
- result.push(combine.apply(void 0, _toConsumableArray(elements)));
955
- };
956
- for (var i = 0; i < maxIndex; i++) {
957
- _loop(i);
303
+ // src/array/zipWith.ts
304
+ function zipWith(arr1, ...rest) {
305
+ const arrs = [arr1, ...rest.slice(0, -1)];
306
+ const combine = rest[rest.length - 1];
307
+ const result = [];
308
+ const maxIndex = Math.max(...arrs.map((arr) => arr.length));
309
+ for (let i = 0; i < maxIndex; i++) {
310
+ const elements = arrs.map((arr) => arr[i]);
311
+ result.push(combine(...elements));
958
312
  }
959
313
  return result;
960
314
  }
961
-
962
- exports.chunk = chunk;
963
- exports.difference = difference;
964
- exports.differenceBy = differenceBy;
965
- exports.differenceWith = differenceWith;
966
- exports.drop = drop;
967
- exports.dropRight = dropRight;
968
- exports.dropRightWhile = dropRightWhile;
969
- exports.dropWhile = dropWhile;
970
- exports.groupBy = groupBy;
971
- exports.intersection = intersection;
972
- exports.intersectionBy = intersectionBy;
973
- exports.intersectionWith = intersectionWith;
974
- exports.partition = partition;
975
- exports.sample = sample;
976
- exports.shuffle = shuffle;
977
- exports.take = take;
978
- exports.takeRight = takeRight;
979
- exports.takeRightWhile = takeRightWhile;
980
- exports.takeWhile = takeWhile;
981
- exports.union = union;
982
- exports.unionBy = unionBy;
983
- exports.unionWith = unionWith;
984
- exports.uniq = uniq;
985
- exports.uniqBy = uniqBy;
986
- exports.uniqWith = uniqWith;
987
- exports.xor = xor;
988
- exports.xorBy = xorBy;
989
- exports.xorWith = xorWith;
990
- exports.zip = zip;
991
- exports.zipWith = zipWith;
315
+ // Annotate the CommonJS export names for ESM import in node:
316
+ 0 && (module.exports = {
317
+ chunk,
318
+ difference,
319
+ differenceBy,
320
+ differenceWith,
321
+ drop,
322
+ dropRight,
323
+ dropRightWhile,
324
+ dropWhile,
325
+ groupBy,
326
+ intersection,
327
+ intersectionBy,
328
+ intersectionWith,
329
+ partition,
330
+ sample,
331
+ shuffle,
332
+ take,
333
+ takeRight,
334
+ takeRightWhile,
335
+ takeWhile,
336
+ union,
337
+ unionBy,
338
+ unionWith,
339
+ uniq,
340
+ uniqBy,
341
+ uniqWith,
342
+ xor,
343
+ xorBy,
344
+ xorWith,
345
+ zip,
346
+ zipWith
347
+ });
348
+ //# sourceMappingURL=index.js.map