@vielzeug/toolkit 1.0.11

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 (422) hide show
  1. package/dist/array/aggregate.cjs +2 -0
  2. package/dist/array/aggregate.cjs.map +1 -0
  3. package/dist/array/aggregate.js +16 -0
  4. package/dist/array/aggregate.js.map +1 -0
  5. package/dist/array/alternate.cjs +2 -0
  6. package/dist/array/alternate.cjs.map +1 -0
  7. package/dist/array/alternate.js +9 -0
  8. package/dist/array/alternate.js.map +1 -0
  9. package/dist/array/chunk.cjs +2 -0
  10. package/dist/array/chunk.cjs.map +1 -0
  11. package/dist/array/chunk.js +22 -0
  12. package/dist/array/chunk.js.map +1 -0
  13. package/dist/array/compact.cjs +2 -0
  14. package/dist/array/compact.cjs.map +1 -0
  15. package/dist/array/compact.js +9 -0
  16. package/dist/array/compact.js.map +1 -0
  17. package/dist/array/contains.cjs +2 -0
  18. package/dist/array/contains.cjs.map +1 -0
  19. package/dist/array/contains.js +11 -0
  20. package/dist/array/contains.js.map +1 -0
  21. package/dist/array/every.cjs +2 -0
  22. package/dist/array/every.cjs.map +1 -0
  23. package/dist/array/every.js +14 -0
  24. package/dist/array/every.js.map +1 -0
  25. package/dist/array/filter.cjs +2 -0
  26. package/dist/array/filter.cjs.map +1 -0
  27. package/dist/array/filter.js +14 -0
  28. package/dist/array/filter.js.map +1 -0
  29. package/dist/array/find.cjs +2 -0
  30. package/dist/array/find.cjs.map +1 -0
  31. package/dist/array/find.js +14 -0
  32. package/dist/array/find.js.map +1 -0
  33. package/dist/array/findIndex.cjs +2 -0
  34. package/dist/array/findIndex.cjs.map +1 -0
  35. package/dist/array/findIndex.js +14 -0
  36. package/dist/array/findIndex.js.map +1 -0
  37. package/dist/array/findLast.cjs +2 -0
  38. package/dist/array/findLast.cjs.map +1 -0
  39. package/dist/array/findLast.js +14 -0
  40. package/dist/array/findLast.js.map +1 -0
  41. package/dist/array/flatten.cjs +2 -0
  42. package/dist/array/flatten.cjs.map +1 -0
  43. package/dist/array/flatten.js +7 -0
  44. package/dist/array/flatten.js.map +1 -0
  45. package/dist/array/group.cjs +2 -0
  46. package/dist/array/group.cjs.map +1 -0
  47. package/dist/array/group.js +16 -0
  48. package/dist/array/group.js.map +1 -0
  49. package/dist/array/list.cjs +2 -0
  50. package/dist/array/list.cjs.map +1 -0
  51. package/dist/array/list.js +70 -0
  52. package/dist/array/list.js.map +1 -0
  53. package/dist/array/map.cjs +2 -0
  54. package/dist/array/map.cjs.map +1 -0
  55. package/dist/array/map.js +18 -0
  56. package/dist/array/map.js.map +1 -0
  57. package/dist/array/pick.cjs +2 -0
  58. package/dist/array/pick.cjs.map +1 -0
  59. package/dist/array/pick.js +15 -0
  60. package/dist/array/pick.js.map +1 -0
  61. package/dist/array/reduce.cjs +2 -0
  62. package/dist/array/reduce.cjs.map +1 -0
  63. package/dist/array/reduce.js +16 -0
  64. package/dist/array/reduce.js.map +1 -0
  65. package/dist/array/search.cjs +2 -0
  66. package/dist/array/search.cjs.map +1 -0
  67. package/dist/array/search.js +14 -0
  68. package/dist/array/search.js.map +1 -0
  69. package/dist/array/select.cjs +2 -0
  70. package/dist/array/select.cjs.map +1 -0
  71. package/dist/array/select.js +16 -0
  72. package/dist/array/select.js.map +1 -0
  73. package/dist/array/shift.cjs +2 -0
  74. package/dist/array/shift.cjs.map +1 -0
  75. package/dist/array/shift.js +13 -0
  76. package/dist/array/shift.js.map +1 -0
  77. package/dist/array/some.cjs +2 -0
  78. package/dist/array/some.cjs.map +1 -0
  79. package/dist/array/some.js +14 -0
  80. package/dist/array/some.js.map +1 -0
  81. package/dist/array/sort.cjs +2 -0
  82. package/dist/array/sort.cjs.map +1 -0
  83. package/dist/array/sort.js +13 -0
  84. package/dist/array/sort.js.map +1 -0
  85. package/dist/array/sortBy.cjs +2 -0
  86. package/dist/array/sortBy.cjs.map +1 -0
  87. package/dist/array/sortBy.js +6 -0
  88. package/dist/array/sortBy.js.map +1 -0
  89. package/dist/array/substitute.cjs +2 -0
  90. package/dist/array/substitute.cjs.map +1 -0
  91. package/dist/array/substitute.js +13 -0
  92. package/dist/array/substitute.js.map +1 -0
  93. package/dist/array/uniq.cjs +2 -0
  94. package/dist/array/uniq.cjs.map +1 -0
  95. package/dist/array/uniq.js +18 -0
  96. package/dist/array/uniq.js.map +1 -0
  97. package/dist/date/expires.cjs +2 -0
  98. package/dist/date/expires.cjs.map +1 -0
  99. package/dist/date/expires.js +11 -0
  100. package/dist/date/expires.js.map +1 -0
  101. package/dist/date/interval.cjs +2 -0
  102. package/dist/date/interval.cjs.map +1 -0
  103. package/dist/date/interval.js +39 -0
  104. package/dist/date/interval.js.map +1 -0
  105. package/dist/date/timeDiff.cjs +2 -0
  106. package/dist/date/timeDiff.cjs.map +1 -0
  107. package/dist/date/timeDiff.js +29 -0
  108. package/dist/date/timeDiff.js.map +1 -0
  109. package/dist/function/assert.cjs +3 -0
  110. package/dist/function/assert.cjs.map +1 -0
  111. package/dist/function/assert.js +12 -0
  112. package/dist/function/assert.js.map +1 -0
  113. package/dist/function/assertParams.cjs +2 -0
  114. package/dist/function/assertParams.cjs.map +1 -0
  115. package/dist/function/assertParams.js +13 -0
  116. package/dist/function/assertParams.js.map +1 -0
  117. package/dist/function/attempt.cjs +2 -0
  118. package/dist/function/attempt.cjs.map +1 -0
  119. package/dist/function/attempt.js +15 -0
  120. package/dist/function/attempt.js.map +1 -0
  121. package/dist/function/compare.cjs +2 -0
  122. package/dist/function/compare.cjs.map +1 -0
  123. package/dist/function/compare.js +22 -0
  124. package/dist/function/compare.js.map +1 -0
  125. package/dist/function/compareBy.cjs +2 -0
  126. package/dist/function/compareBy.cjs.map +1 -0
  127. package/dist/function/compareBy.js +15 -0
  128. package/dist/function/compareBy.js.map +1 -0
  129. package/dist/function/compose.cjs +2 -0
  130. package/dist/function/compose.cjs.map +1 -0
  131. package/dist/function/compose.js +14 -0
  132. package/dist/function/compose.js.map +1 -0
  133. package/dist/function/curry.cjs +2 -0
  134. package/dist/function/curry.cjs.map +1 -0
  135. package/dist/function/curry.js +8 -0
  136. package/dist/function/curry.js.map +1 -0
  137. package/dist/function/debounce.cjs +2 -0
  138. package/dist/function/debounce.cjs.map +1 -0
  139. package/dist/function/debounce.js +10 -0
  140. package/dist/function/debounce.js.map +1 -0
  141. package/dist/function/delay.cjs +2 -0
  142. package/dist/function/delay.cjs.map +1 -0
  143. package/dist/function/delay.js +8 -0
  144. package/dist/function/delay.js.map +1 -0
  145. package/dist/function/fp.cjs +2 -0
  146. package/dist/function/fp.cjs.map +1 -0
  147. package/dist/function/fp.js +10 -0
  148. package/dist/function/fp.js.map +1 -0
  149. package/dist/function/memo.cjs +2 -0
  150. package/dist/function/memo.cjs.map +1 -0
  151. package/dist/function/memo.js +24 -0
  152. package/dist/function/memo.js.map +1 -0
  153. package/dist/function/once.cjs +2 -0
  154. package/dist/function/once.cjs.map +1 -0
  155. package/dist/function/once.js +11 -0
  156. package/dist/function/once.js.map +1 -0
  157. package/dist/function/pipe.cjs +2 -0
  158. package/dist/function/pipe.cjs.map +1 -0
  159. package/dist/function/pipe.js +11 -0
  160. package/dist/function/pipe.js.map +1 -0
  161. package/dist/function/predict.cjs +2 -0
  162. package/dist/function/predict.cjs.map +1 -0
  163. package/dist/function/predict.js +13 -0
  164. package/dist/function/predict.js.map +1 -0
  165. package/dist/function/proxy.cjs +2 -0
  166. package/dist/function/proxy.cjs.map +1 -0
  167. package/dist/function/proxy.js +22 -0
  168. package/dist/function/proxy.js.map +1 -0
  169. package/dist/function/retry.cjs +2 -0
  170. package/dist/function/retry.cjs.map +1 -0
  171. package/dist/function/retry.js +25 -0
  172. package/dist/function/retry.js.map +1 -0
  173. package/dist/function/sleep.cjs +2 -0
  174. package/dist/function/sleep.cjs.map +1 -0
  175. package/dist/function/sleep.js +7 -0
  176. package/dist/function/sleep.js.map +1 -0
  177. package/dist/function/throttle.cjs +2 -0
  178. package/dist/function/throttle.cjs.map +1 -0
  179. package/dist/function/throttle.js +11 -0
  180. package/dist/function/throttle.js.map +1 -0
  181. package/dist/function/worker.cjs +14 -0
  182. package/dist/function/worker.cjs.map +1 -0
  183. package/dist/function/worker.js +29 -0
  184. package/dist/function/worker.js.map +1 -0
  185. package/dist/index.cjs +2 -0
  186. package/dist/index.cjs.map +1 -0
  187. package/dist/index.d.ts +2278 -0
  188. package/dist/index.js +217 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/logit/dist/logit.cjs +2 -0
  191. package/dist/logit/dist/logit.cjs.map +1 -0
  192. package/dist/logit/dist/logit.js +178 -0
  193. package/dist/logit/dist/logit.js.map +1 -0
  194. package/dist/math/average.cjs +2 -0
  195. package/dist/math/average.cjs.map +1 -0
  196. package/dist/math/average.js +19 -0
  197. package/dist/math/average.js.map +1 -0
  198. package/dist/math/boil.cjs +2 -0
  199. package/dist/math/boil.cjs.map +1 -0
  200. package/dist/math/boil.js +17 -0
  201. package/dist/math/boil.js.map +1 -0
  202. package/dist/math/clamp.cjs +2 -0
  203. package/dist/math/clamp.cjs.map +1 -0
  204. package/dist/math/clamp.js +7 -0
  205. package/dist/math/clamp.js.map +1 -0
  206. package/dist/math/max.cjs +2 -0
  207. package/dist/math/max.cjs.map +1 -0
  208. package/dist/math/max.js +12 -0
  209. package/dist/math/max.js.map +1 -0
  210. package/dist/math/median.cjs +2 -0
  211. package/dist/math/median.cjs.map +1 -0
  212. package/dist/math/median.js +11 -0
  213. package/dist/math/median.js.map +1 -0
  214. package/dist/math/min.cjs +2 -0
  215. package/dist/math/min.cjs.map +1 -0
  216. package/dist/math/min.js +12 -0
  217. package/dist/math/min.js.map +1 -0
  218. package/dist/math/range.cjs +2 -0
  219. package/dist/math/range.cjs.map +1 -0
  220. package/dist/math/range.js +10 -0
  221. package/dist/math/range.js.map +1 -0
  222. package/dist/math/rate.cjs +2 -0
  223. package/dist/math/rate.cjs.map +1 -0
  224. package/dist/math/rate.js +9 -0
  225. package/dist/math/rate.js.map +1 -0
  226. package/dist/math/round.cjs +2 -0
  227. package/dist/math/round.cjs.map +1 -0
  228. package/dist/math/round.js +9 -0
  229. package/dist/math/round.js.map +1 -0
  230. package/dist/math/sum.cjs +2 -0
  231. package/dist/math/sum.cjs.map +1 -0
  232. package/dist/math/sum.js +22 -0
  233. package/dist/math/sum.js.map +1 -0
  234. package/dist/object/clone.cjs +2 -0
  235. package/dist/object/clone.cjs.map +1 -0
  236. package/dist/object/clone.js +7 -0
  237. package/dist/object/clone.js.map +1 -0
  238. package/dist/object/diff.cjs +2 -0
  239. package/dist/object/diff.cjs.map +1 -0
  240. package/dist/object/diff.js +18 -0
  241. package/dist/object/diff.js.map +1 -0
  242. package/dist/object/entries.cjs +2 -0
  243. package/dist/object/entries.cjs.map +1 -0
  244. package/dist/object/entries.js +9 -0
  245. package/dist/object/entries.js.map +1 -0
  246. package/dist/object/keys.cjs +2 -0
  247. package/dist/object/keys.cjs.map +1 -0
  248. package/dist/object/keys.js +9 -0
  249. package/dist/object/keys.js.map +1 -0
  250. package/dist/object/merge.cjs +2 -0
  251. package/dist/object/merge.cjs.map +1 -0
  252. package/dist/object/merge.js +29 -0
  253. package/dist/object/merge.js.map +1 -0
  254. package/dist/object/parseJSON.cjs +2 -0
  255. package/dist/object/parseJSON.cjs.map +1 -0
  256. package/dist/object/parseJSON.js +19 -0
  257. package/dist/object/parseJSON.js.map +1 -0
  258. package/dist/object/path.cjs +2 -0
  259. package/dist/object/path.cjs.map +1 -0
  260. package/dist/object/path.js +24 -0
  261. package/dist/object/path.js.map +1 -0
  262. package/dist/object/seek.cjs +2 -0
  263. package/dist/object/seek.cjs.map +1 -0
  264. package/dist/object/seek.js +11 -0
  265. package/dist/object/seek.js.map +1 -0
  266. package/dist/object/values.cjs +2 -0
  267. package/dist/object/values.cjs.map +1 -0
  268. package/dist/object/values.js +9 -0
  269. package/dist/object/values.js.map +1 -0
  270. package/dist/random/draw.cjs +2 -0
  271. package/dist/random/draw.cjs.map +1 -0
  272. package/dist/random/draw.js +11 -0
  273. package/dist/random/draw.js.map +1 -0
  274. package/dist/random/random.cjs +2 -0
  275. package/dist/random/random.cjs.map +1 -0
  276. package/dist/random/random.js +10 -0
  277. package/dist/random/random.js.map +1 -0
  278. package/dist/random/shuffle.cjs +2 -0
  279. package/dist/random/shuffle.cjs.map +1 -0
  280. package/dist/random/shuffle.js +15 -0
  281. package/dist/random/shuffle.js.map +1 -0
  282. package/dist/random/uuid.cjs +2 -0
  283. package/dist/random/uuid.cjs.map +1 -0
  284. package/dist/random/uuid.js +7 -0
  285. package/dist/random/uuid.js.map +1 -0
  286. package/dist/string/_caseUtils.cjs +2 -0
  287. package/dist/string/_caseUtils.cjs.map +1 -0
  288. package/dist/string/_caseUtils.js +9 -0
  289. package/dist/string/_caseUtils.js.map +1 -0
  290. package/dist/string/camelCase.cjs +2 -0
  291. package/dist/string/camelCase.cjs.map +1 -0
  292. package/dist/string/camelCase.js +8 -0
  293. package/dist/string/camelCase.js.map +1 -0
  294. package/dist/string/kebabCase.cjs +2 -0
  295. package/dist/string/kebabCase.cjs.map +1 -0
  296. package/dist/string/kebabCase.js +8 -0
  297. package/dist/string/kebabCase.js.map +1 -0
  298. package/dist/string/pascalCase.cjs +2 -0
  299. package/dist/string/pascalCase.cjs.map +1 -0
  300. package/dist/string/pascalCase.js +8 -0
  301. package/dist/string/pascalCase.js.map +1 -0
  302. package/dist/string/similarity.cjs +2 -0
  303. package/dist/string/similarity.cjs.map +1 -0
  304. package/dist/string/similarity.js +34 -0
  305. package/dist/string/similarity.js.map +1 -0
  306. package/dist/string/snakeCase.cjs +2 -0
  307. package/dist/string/snakeCase.cjs.map +1 -0
  308. package/dist/string/snakeCase.js +8 -0
  309. package/dist/string/snakeCase.js.map +1 -0
  310. package/dist/string/truncate.cjs +2 -0
  311. package/dist/string/truncate.cjs.map +1 -0
  312. package/dist/string/truncate.js +9 -0
  313. package/dist/string/truncate.js.map +1 -0
  314. package/dist/typed/ge.cjs +2 -0
  315. package/dist/typed/ge.cjs.map +1 -0
  316. package/dist/typed/ge.js +7 -0
  317. package/dist/typed/ge.js.map +1 -0
  318. package/dist/typed/gt.cjs +2 -0
  319. package/dist/typed/gt.cjs.map +1 -0
  320. package/dist/typed/gt.js +7 -0
  321. package/dist/typed/gt.js.map +1 -0
  322. package/dist/typed/is.cjs +2 -0
  323. package/dist/typed/is.cjs.map +1 -0
  324. package/dist/typed/is.js +44 -0
  325. package/dist/typed/is.js.map +1 -0
  326. package/dist/typed/isArray.cjs +2 -0
  327. package/dist/typed/isArray.cjs.map +1 -0
  328. package/dist/typed/isArray.js +9 -0
  329. package/dist/typed/isArray.js.map +1 -0
  330. package/dist/typed/isBoolean.cjs +2 -0
  331. package/dist/typed/isBoolean.cjs.map +1 -0
  332. package/dist/typed/isBoolean.js +7 -0
  333. package/dist/typed/isBoolean.js.map +1 -0
  334. package/dist/typed/isDate.cjs +2 -0
  335. package/dist/typed/isDate.cjs.map +1 -0
  336. package/dist/typed/isDate.js +9 -0
  337. package/dist/typed/isDate.js.map +1 -0
  338. package/dist/typed/isDefined.cjs +2 -0
  339. package/dist/typed/isDefined.cjs.map +1 -0
  340. package/dist/typed/isDefined.js +7 -0
  341. package/dist/typed/isDefined.js.map +1 -0
  342. package/dist/typed/isEmpty.cjs +2 -0
  343. package/dist/typed/isEmpty.cjs.map +1 -0
  344. package/dist/typed/isEmpty.js +12 -0
  345. package/dist/typed/isEmpty.js.map +1 -0
  346. package/dist/typed/isEqual.cjs +2 -0
  347. package/dist/typed/isEqual.cjs.map +1 -0
  348. package/dist/typed/isEqual.js +25 -0
  349. package/dist/typed/isEqual.js.map +1 -0
  350. package/dist/typed/isEven.cjs +2 -0
  351. package/dist/typed/isEven.cjs.map +1 -0
  352. package/dist/typed/isEven.js +7 -0
  353. package/dist/typed/isEven.js.map +1 -0
  354. package/dist/typed/isFunction.cjs +2 -0
  355. package/dist/typed/isFunction.cjs.map +1 -0
  356. package/dist/typed/isFunction.js +9 -0
  357. package/dist/typed/isFunction.js.map +1 -0
  358. package/dist/typed/isMatch.cjs +2 -0
  359. package/dist/typed/isMatch.cjs.map +1 -0
  360. package/dist/typed/isMatch.js +19 -0
  361. package/dist/typed/isMatch.js.map +1 -0
  362. package/dist/typed/isNegative.cjs +2 -0
  363. package/dist/typed/isNegative.cjs.map +1 -0
  364. package/dist/typed/isNegative.js +7 -0
  365. package/dist/typed/isNegative.js.map +1 -0
  366. package/dist/typed/isNil.cjs +2 -0
  367. package/dist/typed/isNil.cjs.map +1 -0
  368. package/dist/typed/isNil.js +9 -0
  369. package/dist/typed/isNil.js.map +1 -0
  370. package/dist/typed/isNumber.cjs +2 -0
  371. package/dist/typed/isNumber.cjs.map +1 -0
  372. package/dist/typed/isNumber.js +9 -0
  373. package/dist/typed/isNumber.js.map +1 -0
  374. package/dist/typed/isObject.cjs +2 -0
  375. package/dist/typed/isObject.cjs.map +1 -0
  376. package/dist/typed/isObject.js +9 -0
  377. package/dist/typed/isObject.js.map +1 -0
  378. package/dist/typed/isOdd.cjs +2 -0
  379. package/dist/typed/isOdd.cjs.map +1 -0
  380. package/dist/typed/isOdd.js +7 -0
  381. package/dist/typed/isOdd.js.map +1 -0
  382. package/dist/typed/isPositive.cjs +2 -0
  383. package/dist/typed/isPositive.cjs.map +1 -0
  384. package/dist/typed/isPositive.js +7 -0
  385. package/dist/typed/isPositive.js.map +1 -0
  386. package/dist/typed/isPrimitive.cjs +2 -0
  387. package/dist/typed/isPrimitive.cjs.map +1 -0
  388. package/dist/typed/isPrimitive.js +10 -0
  389. package/dist/typed/isPrimitive.js.map +1 -0
  390. package/dist/typed/isPromise.cjs +2 -0
  391. package/dist/typed/isPromise.cjs.map +1 -0
  392. package/dist/typed/isPromise.js +10 -0
  393. package/dist/typed/isPromise.js.map +1 -0
  394. package/dist/typed/isRegex.cjs +2 -0
  395. package/dist/typed/isRegex.cjs.map +1 -0
  396. package/dist/typed/isRegex.js +7 -0
  397. package/dist/typed/isRegex.js.map +1 -0
  398. package/dist/typed/isString.cjs +2 -0
  399. package/dist/typed/isString.cjs.map +1 -0
  400. package/dist/typed/isString.js +9 -0
  401. package/dist/typed/isString.js.map +1 -0
  402. package/dist/typed/isWithin.cjs +2 -0
  403. package/dist/typed/isWithin.cjs.map +1 -0
  404. package/dist/typed/isWithin.js +10 -0
  405. package/dist/typed/isWithin.js.map +1 -0
  406. package/dist/typed/isZero.cjs +2 -0
  407. package/dist/typed/isZero.cjs.map +1 -0
  408. package/dist/typed/isZero.js +7 -0
  409. package/dist/typed/isZero.js.map +1 -0
  410. package/dist/typed/le.cjs +2 -0
  411. package/dist/typed/le.cjs.map +1 -0
  412. package/dist/typed/le.js +7 -0
  413. package/dist/typed/le.js.map +1 -0
  414. package/dist/typed/lt.cjs +2 -0
  415. package/dist/typed/lt.cjs.map +1 -0
  416. package/dist/typed/lt.js +7 -0
  417. package/dist/typed/lt.js.map +1 -0
  418. package/dist/typed/typeOf.cjs +2 -0
  419. package/dist/typed/typeOf.cjs.map +1 -0
  420. package/dist/typed/typeOf.js +14 -0
  421. package/dist/typed/typeOf.js.map +1 -0
  422. package/package.json +38 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../function/assert.cjs"),s=require("../typed/isArray.cjs");function n(t,r){u.assert(s.isArray(t),s.IS_ARRAY_ERROR_MSG,{args:{array:t},type:TypeError});const o={},g=typeof r=="function"?r:e=>e[r];for(const e of t){const i=g(e);o[i]=e}return o}n.fp=!0;exports.aggregate=n;
2
+ //# sourceMappingURL=aggregate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate.cjs","sources":["../../src/array/aggregate.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Selector } from '../types';\n\n/**\n * Aggregates an array of objects into an object based on a key generated by a selector function.\n *\n * @example\n * ```ts\n * const data = [{ a: 1 }, { a: 2 }, { a: 1 }];\n * aggregate(data, 'a') // { '1': { a: 1 }, '2': { a: 2 } };\n * ```\n *\n * @param array - The array to key.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns An object with keys as the generated values and values as the last element responsible for generating the key.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function aggregate<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(\n array: T[],\n selector: Selector<T>,\n): Record<R, T> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = {} as Record<R, T>;\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = getKey(item) as R;\n\n result[key] = item;\n }\n\n return result;\n}\n\naggregate.fp = true;\n"],"names":["aggregate","array","selector","assert","isArray","IS_ARRAY_ERROR_MSG","result","getKey","item","key"],"mappings":"4JAoBO,SAASA,EACdC,EACAC,EACc,CACdC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAE/E,MAAMK,EAAS,CAAA,EACTC,EAAS,OAAOL,GAAa,WAAaA,EAAYM,GAAYA,EAAKN,CAAQ,EAErF,UAAWM,KAAQP,EAAO,CACxB,MAAMQ,EAAMF,EAAOC,CAAI,EAEvBF,EAAOG,CAAG,EAAID,CAChB,CAEA,OAAOF,CACT,CAEAN,EAAU,GAAK"}
@@ -0,0 +1,16 @@
1
+ import { assert as p } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as s, isArray as i } from "../typed/isArray.js";
3
+ function g(o, r) {
4
+ p(i(o), s, { args: { array: o }, type: TypeError });
5
+ const e = {}, n = typeof r == "function" ? r : (t) => t[r];
6
+ for (const t of o) {
7
+ const f = n(t);
8
+ e[f] = t;
9
+ }
10
+ return e;
11
+ }
12
+ g.fp = !0;
13
+ export {
14
+ g as aggregate
15
+ };
16
+ //# sourceMappingURL=aggregate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate.js","sources":["../../src/array/aggregate.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Selector } from '../types';\n\n/**\n * Aggregates an array of objects into an object based on a key generated by a selector function.\n *\n * @example\n * ```ts\n * const data = [{ a: 1 }, { a: 2 }, { a: 1 }];\n * aggregate(data, 'a') // { '1': { a: 1 }, '2': { a: 2 } };\n * ```\n *\n * @param array - The array to key.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns An object with keys as the generated values and values as the last element responsible for generating the key.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function aggregate<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(\n array: T[],\n selector: Selector<T>,\n): Record<R, T> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = {} as Record<R, T>;\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = getKey(item) as R;\n\n result[key] = item;\n }\n\n return result;\n}\n\naggregate.fp = true;\n"],"names":["aggregate","array","selector","assert","isArray","IS_ARRAY_ERROR_MSG","result","getKey","item","key"],"mappings":";;AAoBO,SAASA,EACdC,GACAC,GACc;AACd,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW;AAE/E,QAAMK,IAAS,CAAA,GACTC,IAAS,OAAOL,KAAa,aAAaA,IAAW,CAACM,MAAYA,EAAKN,CAAQ;AAErF,aAAWM,KAAQP,GAAO;AACxB,UAAMQ,IAAMF,EAAOC,CAAI;AAEvB,IAAAF,EAAOG,CAAG,IAAID;AAAA,EAChB;AAEA,SAAOF;AACT;AAEAN,EAAU,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(n,e,t,p={}){const{strategy:u="append"}=p,i=t?d=>t(d)===t(e):d=>d===e,c=n.findIndex(i);return c!==-1?[...n.slice(0,c),...n.slice(c+1)]:u==="prepend"?[e,...n]:[...n,e]}o.fp=!0;exports.alternate=o;
2
+ //# sourceMappingURL=alternate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alternate.cjs","sources":["../../src/array/alternate.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already exists in the array.\n *\n * @example\n * ```ts\n * alternate([1, 2, 3], 4) // [1, 2, 3, 4]\n * alternate([1, 2, 3], 2) // [1, 3]\n *\n * alternate(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine the uniqueness of the item.\n * @param [options] - Options for the alternate operation.\n * @param [options.strategy] - The strategy to use when adding the item ('prepend' or 'append').\n *\n * @returns A new array with the item added or removed.\n */\nexport function alternate<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n\nalternate.fp = true;\n"],"names":["alternate","array","item","selector","options","strategy","compareFn","el","index"],"mappings":"gFA0BO,SAASA,EACdC,EACAC,EACAC,EACAC,EAA+C,CAAA,EAC1C,CACL,KAAM,CAAE,SAAAC,EAAW,QAAA,EAAaD,EAC1BE,EAAYH,EAAYI,GAAUJ,EAASI,CAAE,IAAMJ,EAASD,CAAI,EAAKK,GAAUA,IAAOL,EAEtFM,EAAQP,EAAM,UAAUK,CAAS,EAEvC,OAAIE,IAAU,GACL,CAAC,GAAGP,EAAM,MAAM,EAAGO,CAAK,EAAG,GAAGP,EAAM,MAAMO,EAAQ,CAAC,CAAC,EAGtDH,IAAa,UAAY,CAACH,EAAM,GAAGD,CAAK,EAAI,CAAC,GAAGA,EAAOC,CAAI,CACpE,CAEAF,EAAU,GAAK"}
@@ -0,0 +1,9 @@
1
+ function s(n, e, p, d = {}) {
2
+ const { strategy: f = "append" } = d, o = p ? (c) => p(c) === p(e) : (c) => c === e, t = n.findIndex(o);
3
+ return t !== -1 ? [...n.slice(0, t), ...n.slice(t + 1)] : f === "prepend" ? [e, ...n] : [...n, e];
4
+ }
5
+ s.fp = !0;
6
+ export {
7
+ s as alternate
8
+ };
9
+ //# sourceMappingURL=alternate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alternate.js","sources":["../../src/array/alternate.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already exists in the array.\n *\n * @example\n * ```ts\n * alternate([1, 2, 3], 4) // [1, 2, 3, 4]\n * alternate([1, 2, 3], 2) // [1, 3]\n *\n * alternate(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine the uniqueness of the item.\n * @param [options] - Options for the alternate operation.\n * @param [options.strategy] - The strategy to use when adding the item ('prepend' or 'append').\n *\n * @returns A new array with the item added or removed.\n */\nexport function alternate<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n\nalternate.fp = true;\n"],"names":["alternate","array","item","selector","options","strategy","compareFn","el","index"],"mappings":"AA0BO,SAASA,EACdC,GACAC,GACAC,GACAC,IAA+C,CAAA,GAC1C;AACL,QAAM,EAAE,UAAAC,IAAW,SAAA,IAAaD,GAC1BE,IAAYH,IAAW,CAACI,MAAUJ,EAASI,CAAE,MAAMJ,EAASD,CAAI,IAAI,CAACK,MAAUA,MAAOL,GAEtFM,IAAQP,EAAM,UAAUK,CAAS;AAEvC,SAAIE,MAAU,KACL,CAAC,GAAGP,EAAM,MAAM,GAAGO,CAAK,GAAG,GAAGP,EAAM,MAAMO,IAAQ,CAAC,CAAC,IAGtDH,MAAa,YAAY,CAACH,GAAM,GAAGD,CAAK,IAAI,CAAC,GAAGA,GAAOC,CAAI;AACpE;AAEAF,EAAU,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../function/assert.cjs"),y=require("../typed/isArray.cjs"),o=require("../typed/isString.cjs");function h(r,e=2,c={}){l.assert(y.isArray(r)||o.isString(r),"Argument must be an array or string.",{args:{input:r},type:TypeError});const{overlap:g=!1,pad:n=" "}=c;if(o.isString(r)&&g){const t=`${n}${r}${n}`;return Array.from({length:t.length-e+1},(a,s)=>t.slice(s,s+e))}return Array.from({length:Math.ceil(r.length/e)},(t,a)=>r.slice(a*e,a*e+e))}exports.chunk=h;
2
+ //# sourceMappingURL=chunk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.cjs","sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = `${pad}${input}${pad}`;\n return Array.from({ length: padded.length - size + 1 }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"names":["chunk","input","size","options","assert","isArray","isString","overlap","pad","padded","_","i"],"mappings":"+LAgCO,SAASA,EAASC,EAAqBC,EAAO,EAAGC,EAAwB,CAAA,EAAoB,CAClGC,EAAAA,OAAOC,EAAAA,QAAQJ,CAAY,GAAKK,EAAAA,SAASL,CAAK,EAAG,uCAAwC,CACvF,KAAM,CAAE,MAAAA,CAAA,EACR,KAAM,SAAA,CACP,EAED,KAAM,CAAE,QAAAM,EAAU,GAAO,IAAAC,EAAM,KAAQL,EAEvC,GAAIG,EAAAA,SAASL,CAAK,GAAKM,EAAS,CAC9B,MAAME,EAAS,GAAGD,CAAG,GAAGP,CAAK,GAAGO,CAAG,GACnC,OAAO,MAAM,KAAK,CAAE,OAAQC,EAAO,OAASP,EAAO,CAAA,EAAK,CAACQ,EAAGC,IAAMF,EAAO,MAAME,EAAGA,EAAIT,CAAI,CAAC,CAC7F,CAEA,OAAO,MAAM,KAAK,CAAE,OAAQ,KAAK,KAAKD,EAAM,OAASC,CAAI,CAAA,EAAK,CAACQ,EAAGC,IAChEV,EAAM,MAAMU,EAAIT,EAAMS,EAAIT,EAAOA,CAAI,CAAA,CAEzC"}
@@ -0,0 +1,22 @@
1
+ import { assert as g } from "../function/assert.js";
2
+ import { isArray as c } from "../typed/isArray.js";
3
+ import { isString as l } from "../typed/isString.js";
4
+ function d(r, o = 2, n = {}) {
5
+ g(c(r) || l(r), "Argument must be an array or string.", {
6
+ args: { input: r },
7
+ type: TypeError
8
+ });
9
+ const { overlap: f = !1, pad: e = " " } = n;
10
+ if (l(r) && f) {
11
+ const t = `${e}${r}${e}`;
12
+ return Array.from({ length: t.length - o + 1 }, (a, m) => t.slice(m, m + o));
13
+ }
14
+ return Array.from(
15
+ { length: Math.ceil(r.length / o) },
16
+ (t, a) => r.slice(a * o, a * o + o)
17
+ );
18
+ }
19
+ export {
20
+ d as chunk
21
+ };
22
+ //# sourceMappingURL=chunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.js","sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = `${pad}${input}${pad}`;\n return Array.from({ length: padded.length - size + 1 }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"names":["chunk","input","size","options","assert","isArray","isString","overlap","pad","padded","_","i"],"mappings":";;;AAgCO,SAASA,EAASC,GAAqBC,IAAO,GAAGC,IAAwB,CAAA,GAAoB;AAClG,EAAAC,EAAOC,EAAQJ,CAAY,KAAKK,EAASL,CAAK,GAAG,wCAAwC;AAAA,IACvF,MAAM,EAAE,OAAAA,EAAA;AAAA,IACR,MAAM;AAAA,EAAA,CACP;AAED,QAAM,EAAE,SAAAM,IAAU,IAAO,KAAAC,IAAM,QAAQL;AAEvC,MAAIG,EAASL,CAAK,KAAKM,GAAS;AAC9B,UAAME,IAAS,GAAGD,CAAG,GAAGP,CAAK,GAAGO,CAAG;AACnC,WAAO,MAAM,KAAK,EAAE,QAAQC,EAAO,SAASP,IAAO,EAAA,GAAK,CAACQ,GAAGC,MAAMF,EAAO,MAAME,GAAGA,IAAIT,CAAI,CAAC;AAAA,EAC7F;AAEA,SAAO,MAAM;AAAA,IAAK,EAAE,QAAQ,KAAK,KAAKD,EAAM,SAASC,CAAI,EAAA;AAAA,IAAK,CAACQ,GAAGC,MAChEV,EAAM,MAAMU,IAAIT,GAAMS,IAAIT,IAAOA,CAAI;AAAA,EAAA;AAEzC;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../function/assert.cjs"),r=require("../typed/isArray.cjs");function o(e){return t.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError}),e.filter(Boolean)}exports.compact=o;
2
+ //# sourceMappingURL=compact.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact.cjs","sources":["../../src/array/compact.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Removes falsy values from an array.\n *\n * @example\n * ```ts\n * const arr = [0, 1, false, 2, '', 3];\n * compact(arr); // [1, 2, 3]\n * ```\n *\n * @param array - The array to compact.\n *\n * @returns A new array with falsy values removed.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function compact<T>(array: T[]): NonNullable<T>[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.filter(Boolean) as NonNullable<T>[];\n}\n"],"names":["compact","array","assert","isArray","IS_ARRAY_ERROR_MSG"],"mappings":"4JAkBO,SAASA,EAAWC,EAA8B,CACvDC,OAAAA,EAAAA,OAAOC,EAAAA,QAAQF,CAAK,EAAGG,qBAAoB,CAAE,KAAM,CAAE,MAAAH,CAAA,EAAS,KAAM,UAAW,EAExEA,EAAM,OAAO,OAAO,CAC7B"}
@@ -0,0 +1,9 @@
1
+ import { assert as o } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as t, isArray as e } from "../typed/isArray.js";
3
+ function m(r) {
4
+ return o(e(r), t, { args: { array: r }, type: TypeError }), r.filter(Boolean);
5
+ }
6
+ export {
7
+ m as compact
8
+ };
9
+ //# sourceMappingURL=compact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact.js","sources":["../../src/array/compact.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Removes falsy values from an array.\n *\n * @example\n * ```ts\n * const arr = [0, 1, false, 2, '', 3];\n * compact(arr); // [1, 2, 3]\n * ```\n *\n * @param array - The array to compact.\n *\n * @returns A new array with falsy values removed.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function compact<T>(array: T[]): NonNullable<T>[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.filter(Boolean) as NonNullable<T>[];\n}\n"],"names":["compact","array","assert","isArray","IS_ARRAY_ERROR_MSG"],"mappings":";;AAkBO,SAASA,EAAWC,GAA8B;AACvD,SAAAC,EAAOC,EAAQF,CAAK,GAAGG,GAAoB,EAAE,MAAM,EAAE,OAAAH,EAAA,GAAS,MAAM,WAAW,GAExEA,EAAM,OAAO,OAAO;AAC7B;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../function/assert.cjs"),r=require("../typed/isArray.cjs"),o=require("../typed/isEqual.cjs");function s(e,t){return n.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError}),e.some(i=>o.isEqual(i,t))}s.fp=!0;exports.contains=s;
2
+ //# sourceMappingURL=contains.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contains.cjs","sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function contains<T>(array: T[], value: any): boolean {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.some((val) => isEqual(val, value));\n}\n\ncontains.fp = true;\n"],"names":["contains","array","value","assert","isArray","IS_ARRAY_ERROR_MSG","val","isEqual"],"mappings":"8LAuBO,SAASA,EAAYC,EAAYC,EAAqB,CAC3DC,OAAAA,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAExEA,EAAM,KAAMK,GAAQC,EAAAA,QAAQD,EAAKJ,CAAK,CAAC,CAChD,CAEAF,EAAS,GAAK"}
@@ -0,0 +1,11 @@
1
+ import { assert as e } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as i, isArray as m } from "../typed/isArray.js";
3
+ import { isEqual as p } from "../typed/isEqual.js";
4
+ function s(r, o) {
5
+ return e(m(r), i, { args: { array: r }, type: TypeError }), r.some((t) => p(t, o));
6
+ }
7
+ s.fp = !0;
8
+ export {
9
+ s as contains
10
+ };
11
+ //# sourceMappingURL=contains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contains.js","sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function contains<T>(array: T[], value: any): boolean {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.some((val) => isEqual(val, value));\n}\n\ncontains.fp = true;\n"],"names":["contains","array","value","assert","isArray","IS_ARRAY_ERROR_MSG","val","isEqual"],"mappings":";;;AAuBO,SAASA,EAAYC,GAAYC,GAAqB;AAC3D,SAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW,GAExEA,EAAM,KAAK,CAACK,MAAQC,EAAQD,GAAKJ,CAAK,CAAC;AAChD;AAEAF,EAAS,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../function/assert.cjs"),t=require("../typed/isArray.cjs");function s(e,i){n.assert(t.isArray(e),t.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});for(let r=0;r<e.length;r++)if(!i(e[r],r,e))return!1;return!0}s.fp=!0;exports.every=s;
2
+ //# sourceMappingURL=every.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.cjs","sources":["../../src/array/every.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Checks if all elements in an array pass a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * every(arr, isEven); // false\n * ```\n *\n * @param array - The array to check.\n * @param predicate - The predicate function to test each element.\n *\n * @returns true if all elements pass the predicate test, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function every<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (!predicate(array[index], index, array)) {\n return false;\n }\n }\n\n return true;\n}\n\nevery.fp = true;\n"],"names":["every","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":"4JAqBO,SAASA,EAASC,EAAYC,EAAyB,CAC5DC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAE/E,QAASK,EAAQ,EAAGA,EAAQL,EAAM,OAAQK,IACxC,GAAI,CAACJ,EAAUD,EAAMK,CAAK,EAAGA,EAAOL,CAAK,EACvC,MAAO,GAIX,MAAO,EACT,CAEAD,EAAM,GAAK"}
@@ -0,0 +1,14 @@
1
+ import { assert as o } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as f, isArray as i } from "../typed/isArray.js";
3
+ function n(e, t) {
4
+ o(i(e), f, { args: { array: e }, type: TypeError });
5
+ for (let r = 0; r < e.length; r++)
6
+ if (!t(e[r], r, e))
7
+ return !1;
8
+ return !0;
9
+ }
10
+ n.fp = !0;
11
+ export {
12
+ n as every
13
+ };
14
+ //# sourceMappingURL=every.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.js","sources":["../../src/array/every.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Checks if all elements in an array pass a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * every(arr, isEven); // false\n * ```\n *\n * @param array - The array to check.\n * @param predicate - The predicate function to test each element.\n *\n * @returns true if all elements pass the predicate test, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function every<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (!predicate(array[index], index, array)) {\n return false;\n }\n }\n\n return true;\n}\n\nevery.fp = true;\n"],"names":["every","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":";;AAqBO,SAASA,EAASC,GAAYC,GAAyB;AAC5D,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW;AAE/E,WAASK,IAAQ,GAAGA,IAAQL,EAAM,QAAQK;AACxC,QAAI,CAACJ,EAAUD,EAAMK,CAAK,GAAGA,GAAOL,CAAK;AACvC,aAAO;AAIX,SAAO;AACT;AAEAD,EAAM,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../function/assert.cjs"),s=require("../typed/isArray.cjs");function i(e,n){o.assert(s.isArray(e),s.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});const r=[];for(let t=0;t<e.length;t++)n(e[t],t,e)&&r.push(e[t]);return r}i.fp=!0;exports.filter=i;
2
+ //# sourceMappingURL=filter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.cjs","sources":["../../src/array/filter.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Filters an array based on a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * filter(arr, isEven); // [2, 4]\n * ```\n *\n * @param array - The array to filter.\n * @param predicate - The predicate function to test each element.\n *\n * @returns A new array with elements that pass the predicate test.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function filter<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: T[] = [];\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n result.push(array[index]);\n }\n }\n\n return result;\n}\n\nfilter.fp = true;\n"],"names":["filter","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","result","index"],"mappings":"4JAqBO,SAASA,EAAUC,EAAYC,EAAyB,CAC7DC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAE/E,MAAMK,EAAc,CAAA,EAEpB,QAASC,EAAQ,EAAGA,EAAQN,EAAM,OAAQM,IACpCL,EAAUD,EAAMM,CAAK,EAAGA,EAAON,CAAK,GACtCK,EAAO,KAAKL,EAAMM,CAAK,CAAC,EAI5B,OAAOD,CACT,CAEAN,EAAO,GAAK"}
@@ -0,0 +1,14 @@
1
+ import { assert as f } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as i, isArray as p } from "../typed/isArray.js";
3
+ function s(t, r) {
4
+ f(p(t), i, { args: { array: t }, type: TypeError });
5
+ const o = [];
6
+ for (let e = 0; e < t.length; e++)
7
+ r(t[e], e, t) && o.push(t[e]);
8
+ return o;
9
+ }
10
+ s.fp = !0;
11
+ export {
12
+ s as filter
13
+ };
14
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.js","sources":["../../src/array/filter.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Filters an array based on a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * filter(arr, isEven); // [2, 4]\n * ```\n *\n * @param array - The array to filter.\n * @param predicate - The predicate function to test each element.\n *\n * @returns A new array with elements that pass the predicate test.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function filter<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: T[] = [];\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n result.push(array[index]);\n }\n }\n\n return result;\n}\n\nfilter.fp = true;\n"],"names":["filter","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","result","index"],"mappings":";;AAqBO,SAASA,EAAUC,GAAYC,GAAyB;AAC7D,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW;AAE/E,QAAMK,IAAc,CAAA;AAEpB,WAASC,IAAQ,GAAGA,IAAQN,EAAM,QAAQM;AACxC,IAAIL,EAAUD,EAAMM,CAAK,GAAGA,GAAON,CAAK,KACtCK,EAAO,KAAKL,EAAMM,CAAK,CAAC;AAI5B,SAAOD;AACT;AAEAN,EAAO,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../function/assert.cjs"),r=require("../typed/isArray.cjs");function i(e,n,s){o.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});for(let t=0;t<e.length;t++)if(n(e[t],t,e))return e[t];return s}i.fp=!0;exports.find=i;
2
+ //# sourceMappingURL=find.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.cjs","sources":["../../src/array/find.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the first element in an array that satisfies a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * find(arr, isEven); // 2\n * find(arr, (num) => num > 5, 0); // 0\n * find(arr, (num) => num > 5); // undefined\n * ```\n *\n * @param array - The array to search through.\n * @param predicate - A function that is called for each element in the array.\n * @param [defaultValue] - (optional) value to return if no element satisfies the predicate.\n *\n * @return The first element in the array that satisfies the predicate, or the default value if none match.\n */\nexport function find<T>(array: T[], predicate: Predicate<T>, defaultValue?: T) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n return array[index];\n }\n }\n\n return defaultValue;\n}\n\nfind.fp = true;\n"],"names":["find","array","predicate","defaultValue","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":"4JAsBO,SAASA,EAAQC,EAAYC,EAAyBC,EAAkB,CAC7EC,EAAAA,OAAOC,EAAAA,QAAQJ,CAAK,EAAGK,qBAAoB,CAAE,KAAM,CAAE,MAAAL,CAAA,EAAS,KAAM,UAAW,EAE/E,QAASM,EAAQ,EAAGA,EAAQN,EAAM,OAAQM,IACxC,GAAIL,EAAUD,EAAMM,CAAK,EAAGA,EAAON,CAAK,EACtC,OAAOA,EAAMM,CAAK,EAItB,OAAOJ,CACT,CAEAH,EAAK,GAAK"}
@@ -0,0 +1,14 @@
1
+ import { assert as f } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as i, isArray as n } from "../typed/isArray.js";
3
+ function p(t, o, r) {
4
+ f(n(t), i, { args: { array: t }, type: TypeError });
5
+ for (let e = 0; e < t.length; e++)
6
+ if (o(t[e], e, t))
7
+ return t[e];
8
+ return r;
9
+ }
10
+ p.fp = !0;
11
+ export {
12
+ p as find
13
+ };
14
+ //# sourceMappingURL=find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.js","sources":["../../src/array/find.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the first element in an array that satisfies a predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * find(arr, isEven); // 2\n * find(arr, (num) => num > 5, 0); // 0\n * find(arr, (num) => num > 5); // undefined\n * ```\n *\n * @param array - The array to search through.\n * @param predicate - A function that is called for each element in the array.\n * @param [defaultValue] - (optional) value to return if no element satisfies the predicate.\n *\n * @return The first element in the array that satisfies the predicate, or the default value if none match.\n */\nexport function find<T>(array: T[], predicate: Predicate<T>, defaultValue?: T) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n return array[index];\n }\n }\n\n return defaultValue;\n}\n\nfind.fp = true;\n"],"names":["find","array","predicate","defaultValue","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":";;AAsBO,SAASA,EAAQC,GAAYC,GAAyBC,GAAkB;AAC7E,EAAAC,EAAOC,EAAQJ,CAAK,GAAGK,GAAoB,EAAE,MAAM,EAAE,OAAAL,EAAA,GAAS,MAAM,WAAW;AAE/E,WAASM,IAAQ,GAAGA,IAAQN,EAAM,QAAQM;AACxC,QAAIL,EAAUD,EAAMM,CAAK,GAAGA,GAAON,CAAK;AACtC,aAAOA,EAAMM,CAAK;AAItB,SAAOJ;AACT;AAEAH,EAAK,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../function/assert.cjs"),r=require("../typed/isArray.cjs");function n(e,i){s.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});for(let t=0;t<e.length;t++)if(i(e[t],t,e))return t;return-1}n.fp=!0;exports.findIndex=n;
2
+ //# sourceMappingURL=findIndex.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findIndex.cjs","sources":["../../src/array/findIndex.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the first element in an array that satisfies a predicate function. If no such element is found, returns -1.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * findIndex(arr, isEven); // 1\n * findIndex(arr, (num) => num > 5); // -1\n * ```\n *\n * @param array - The array to search.\n * @param predicate - A function that is called for each element in the array.\n *\n * @return The index of the first element that satisfies the predicate, or -1 if no such element is found.\n */\nexport function findIndex<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n}\n\nfindIndex.fp = true;\n"],"names":["findIndex","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":"4JAoBO,SAASA,EAAaC,EAAYC,EAAyB,CAChEC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAE/E,QAASK,EAAQ,EAAGA,EAAQL,EAAM,OAAQK,IACxC,GAAIJ,EAAUD,EAAMK,CAAK,EAAGA,EAAOL,CAAK,EACtC,OAAOK,EAIX,MAAO,EACT,CAEAN,EAAU,GAAK"}
@@ -0,0 +1,14 @@
1
+ import { assert as n } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as o, isArray as f } from "../typed/isArray.js";
3
+ function i(e, r) {
4
+ n(f(e), o, { args: { array: e }, type: TypeError });
5
+ for (let t = 0; t < e.length; t++)
6
+ if (r(e[t], t, e))
7
+ return t;
8
+ return -1;
9
+ }
10
+ i.fp = !0;
11
+ export {
12
+ i as findIndex
13
+ };
14
+ //# sourceMappingURL=findIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findIndex.js","sources":["../../src/array/findIndex.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the first element in an array that satisfies a predicate function. If no such element is found, returns -1.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * findIndex(arr, isEven); // 1\n * findIndex(arr, (num) => num > 5); // -1\n * ```\n *\n * @param array - The array to search.\n * @param predicate - A function that is called for each element in the array.\n *\n * @return The index of the first element that satisfies the predicate, or -1 if no such element is found.\n */\nexport function findIndex<T>(array: T[], predicate: Predicate<T>) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = 0; index < array.length; index++) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n\n return -1;\n}\n\nfindIndex.fp = true;\n"],"names":["findIndex","array","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":";;AAoBO,SAASA,EAAaC,GAAYC,GAAyB;AAChE,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW;AAE/E,WAASK,IAAQ,GAAGA,IAAQL,EAAM,QAAQK;AACxC,QAAIJ,EAAUD,EAAMK,CAAK,GAAGA,GAAOL,CAAK;AACtC,aAAOK;AAIX,SAAO;AACT;AAEAN,EAAU,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../function/assert.cjs"),r=require("../typed/isArray.cjs");function s(e,i,n){o.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});for(let t=e.length-1;t>=0;t--)if(i(e[t],t,e))return e[t];return n}s.fp=!0;exports.findLast=s;
2
+ //# sourceMappingURL=findLast.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findLast.cjs","sources":["../../src/array/findLast.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the last element in the array that satisfies the provided predicate function.\n * If no such element is found, returns the specified default value (if provided).\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * findLast(arr, isEven); // 4\n * findLast(arr, (num) => num > 5, 0); // 0\n * findLast(arr, (num) => num > 5); // undefined\n * ```\n *\n * @param array - The array to search through.\n * @param predicate - A function to test each element of the array.\n * @param [defaultValue] - The value to return if no element satisfies the predicate.\n *\n * @return The last element in the array that satisfies the predicate, or the default value if none match.\n */\nexport function findLast<T>(array: T[], predicate: Predicate<T>, defaultValue?: T) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return array[index];\n }\n }\n\n return defaultValue;\n}\n\nfindLast.fp = true;\n"],"names":["findLast","array","predicate","defaultValue","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":"4JAuBO,SAASA,EAAYC,EAAYC,EAAyBC,EAAkB,CACjFC,EAAAA,OAAOC,EAAAA,QAAQJ,CAAK,EAAGK,qBAAoB,CAAE,KAAM,CAAE,MAAAL,CAAA,EAAS,KAAM,UAAW,EAE/E,QAASM,EAAQN,EAAM,OAAS,EAAGM,GAAS,EAAGA,IAC7C,GAAIL,EAAUD,EAAMM,CAAK,EAAGA,EAAON,CAAK,EACtC,OAAOA,EAAMM,CAAK,EAItB,OAAOJ,CACT,CAEAH,EAAS,GAAK"}
@@ -0,0 +1,14 @@
1
+ import { assert as f } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as i, isArray as n } from "../typed/isArray.js";
3
+ function p(t, o, r) {
4
+ f(n(t), i, { args: { array: t }, type: TypeError });
5
+ for (let e = t.length - 1; e >= 0; e--)
6
+ if (o(t[e], e, t))
7
+ return t[e];
8
+ return r;
9
+ }
10
+ p.fp = !0;
11
+ export {
12
+ p as findLast
13
+ };
14
+ //# sourceMappingURL=findLast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findLast.js","sources":["../../src/array/findLast.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Predicate } from '../types';\n\n/**\n * Finds the last element in the array that satisfies the provided predicate function.\n * If no such element is found, returns the specified default value (if provided).\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * const isEven = (num) => num % 2 === 0;\n * findLast(arr, isEven); // 4\n * findLast(arr, (num) => num > 5, 0); // 0\n * findLast(arr, (num) => num > 5); // undefined\n * ```\n *\n * @param array - The array to search through.\n * @param predicate - A function to test each element of the array.\n * @param [defaultValue] - The value to return if no element satisfies the predicate.\n *\n * @return The last element in the array that satisfies the predicate, or the default value if none match.\n */\nexport function findLast<T>(array: T[], predicate: Predicate<T>, defaultValue?: T) {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return array[index];\n }\n }\n\n return defaultValue;\n}\n\nfindLast.fp = true;\n"],"names":["findLast","array","predicate","defaultValue","assert","isArray","IS_ARRAY_ERROR_MSG","index"],"mappings":";;AAuBO,SAASA,EAAYC,GAAYC,GAAyBC,GAAkB;AACjF,EAAAC,EAAOC,EAAQJ,CAAK,GAAGK,GAAoB,EAAE,MAAM,EAAE,OAAAL,EAAA,GAAS,MAAM,WAAW;AAE/E,WAASM,IAAQN,EAAM,SAAS,GAAGM,KAAS,GAAGA;AAC7C,QAAIL,EAAUD,EAAMM,CAAK,GAAGA,GAAON,CAAK;AACtC,aAAOA,EAAMM,CAAK;AAItB,SAAOJ;AACT;AAEAH,EAAS,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return t.flat(Number.POSITIVE_INFINITY)}exports.flatten=e;
2
+ //# sourceMappingURL=flatten.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.cjs","sources":["../../src/array/flatten.ts"],"sourcesContent":["type FlatArray<T> = T extends readonly (infer U)[] ? U : T;\n\n/**\n * Flattens a nested array into a single-level array.\n *\n * @example\n * ```ts\n * const arr = [1, [2, [3, [4, [5]]]]];\n * flatten(arr) // [1, 2, 3, 4, 5];\n * ```\n *\n * @param array - The array to flatten.\n *\n * @returns A single-level array.\n */\nexport function flatten<T>(array: T[]): FlatArray<T>[] {\n return array.flat(Number.POSITIVE_INFINITY) as FlatArray<T>[];\n}\n"],"names":["flatten","array"],"mappings":"gFAeO,SAASA,EAAWC,EAA4B,CACrD,OAAOA,EAAM,KAAK,OAAO,iBAAiB,CAC5C"}
@@ -0,0 +1,7 @@
1
+ function I(t) {
2
+ return t.flat(Number.POSITIVE_INFINITY);
3
+ }
4
+ export {
5
+ I as flatten
6
+ };
7
+ //# sourceMappingURL=flatten.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.js","sources":["../../src/array/flatten.ts"],"sourcesContent":["type FlatArray<T> = T extends readonly (infer U)[] ? U : T;\n\n/**\n * Flattens a nested array into a single-level array.\n *\n * @example\n * ```ts\n * const arr = [1, [2, [3, [4, [5]]]]];\n * flatten(arr) // [1, 2, 3, 4, 5];\n * ```\n *\n * @param array - The array to flatten.\n *\n * @returns A single-level array.\n */\nexport function flatten<T>(array: T[]): FlatArray<T>[] {\n return array.flat(Number.POSITIVE_INFINITY) as FlatArray<T>[];\n}\n"],"names":["flatten","array"],"mappings":"AAeO,SAASA,EAAWC,GAA4B;AACrD,SAAOA,EAAM,KAAK,OAAO,iBAAiB;AAC5C;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../function/assert.cjs"),n=require("../typed/isArray.cjs");function u(r,o){c.assert(n.isArray(r),n.IS_ARRAY_ERROR_MSG,{args:{array:r},type:TypeError});const t={},i=typeof o=="function"?o:e=>e[o];for(const e of r){const s=i(e)||"_";t[s]||(t[s]=[]),t[s].push(e)}return t}u.fp=!0;exports.group=u;
2
+ //# sourceMappingURL=group.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.cjs","sources":["../../src/array/group.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Selector } from '../types';\n\n/**\n * Groups the elements of an array based on the given key.\n *\n * @example\n * ```ts\n * const data = [{ a: 2 }, { a: 1 }];\n * group(data, 'a') // { '1': [{ a: 2 }], '2': [{ a: 1 }] };\n * ```\n *\n * @param array - The array to group.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns an object with keys as the grouped values and values as arrays of elements.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function group<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(\n array: T[],\n selector: Selector<T>,\n): Record<R, T[]> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = {} as Record<R, T[]>;\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = (getKey(item) || '_') as R;\n\n if (!result[key]) {\n result[key] = [];\n }\n result[key].push(item);\n }\n\n return result;\n}\n\ngroup.fp = true;\n"],"names":["group","array","selector","assert","isArray","IS_ARRAY_ERROR_MSG","result","getKey","item","key"],"mappings":"4JAoBO,SAASA,EACdC,EACAC,EACgB,CAChBC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CAAE,KAAM,CAAE,MAAAJ,CAAA,EAAS,KAAM,UAAW,EAE/E,MAAMK,EAAS,CAAA,EACTC,EAAS,OAAOL,GAAa,WAAaA,EAAYM,GAAYA,EAAKN,CAAQ,EAErF,UAAWM,KAAQP,EAAO,CACxB,MAAMQ,EAAOF,EAAOC,CAAI,GAAK,IAExBF,EAAOG,CAAG,IACbH,EAAOG,CAAG,EAAI,CAAA,GAEhBH,EAAOG,CAAG,EAAE,KAAKD,CAAI,CACvB,CAEA,OAAOF,CACT,CAEAN,EAAM,GAAK"}
@@ -0,0 +1,16 @@
1
+ import { assert as e } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as s, isArray as i } from "../typed/isArray.js";
3
+ function u(r, f) {
4
+ e(i(r), s, { args: { array: r }, type: TypeError });
5
+ const t = {}, p = typeof f == "function" ? f : (o) => o[f];
6
+ for (const o of r) {
7
+ const n = p(o) || "_";
8
+ t[n] || (t[n] = []), t[n].push(o);
9
+ }
10
+ return t;
11
+ }
12
+ u.fp = !0;
13
+ export {
14
+ u as group
15
+ };
16
+ //# sourceMappingURL=group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.js","sources":["../../src/array/group.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport type { Selector } from '../types';\n\n/**\n * Groups the elements of an array based on the given key.\n *\n * @example\n * ```ts\n * const data = [{ a: 2 }, { a: 1 }];\n * group(data, 'a') // { '1': [{ a: 2 }], '2': [{ a: 1 }] };\n * ```\n *\n * @param array - The array to group.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns an object with keys as the grouped values and values as arrays of elements.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function group<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(\n array: T[],\n selector: Selector<T>,\n): Record<R, T[]> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = {} as Record<R, T[]>;\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = (getKey(item) || '_') as R;\n\n if (!result[key]) {\n result[key] = [];\n }\n result[key].push(item);\n }\n\n return result;\n}\n\ngroup.fp = true;\n"],"names":["group","array","selector","assert","isArray","IS_ARRAY_ERROR_MSG","result","getKey","item","key"],"mappings":";;AAoBO,SAASA,EACdC,GACAC,GACgB;AAChB,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB,EAAE,MAAM,EAAE,OAAAJ,EAAA,GAAS,MAAM,WAAW;AAE/E,QAAMK,IAAS,CAAA,GACTC,IAAS,OAAOL,KAAa,aAAaA,IAAW,CAACM,MAAYA,EAAKN,CAAQ;AAErF,aAAWM,KAAQP,GAAO;AACxB,UAAMQ,IAAOF,EAAOC,CAAI,KAAK;AAE7B,IAAKF,EAAOG,CAAG,MACbH,EAAOG,CAAG,IAAI,CAAA,IAEhBH,EAAOG,CAAG,EAAE,KAAKD,CAAI;AAAA,EACvB;AAEA,SAAOF;AACT;AAEAN,EAAM,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../function/debounce.cjs"),d=require("./chunk.cjs"),x=require("./search.cjs"),T=10,b=.5,y=1;function f(s,i,e){const a=e?[...s].sort(e):[...s];return d.chunk(a,i)}function m(s,i,e=""){return(e?x.search(s,e,b):s).filter(i)}function D(s,i={}){let{limit:e=T,filterFn:a=()=>!0,sortFn:o}=i,c=[...s],t=0,h="",l=m(c,a),n=f(l,e,o);const u=()=>(l=m(c,a,h),n=f(l,e,o),t=Math.max(0,Math.min(t,n.length-1)),n[t]??[]);return{get current(){return n[t]??[]},set data(r){c=[...r],t=0,u()},filter(r){return a=r,t=0,u()},set limit(r){e=Math.max(y,r),u()},get meta(){return{end:Math.min(e*(t+1),l.length),isEmpty:l.length===0,isFirst:t===0,isLast:t===n.length-1,limit:e,page:t+1,pages:Math.ceil(l.length/e),start:Math.max(0,e*t+1),total:l.length}},next(){t<n.length-1&&t++},set page(r){const g=r-1,M=g<0?n.length+g:g;t=Math.max(0,Math.min(M,n.length-1))},get pages(){return n},prev(){t>0&&t--},reset(){return t=0,h="",a=i.filterFn??(()=>!0),u()},search:p.debounce(r=>(h=r,u())),sort(r){return o=r,u()},*[Symbol.iterator](){for(const r of n)yield r}}}exports.list=D;
2
+ //# sourceMappingURL=list.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.cjs","sources":["../../src/array/list.ts"],"sourcesContent":["import { debounce } from '../function/debounce';\nimport type { Predicate } from '../types';\nimport { chunk } from './chunk';\nimport { search } from './search';\n\ntype Config<T> = {\n filterFn?: Predicate<T>;\n limit?: number;\n sortFn?: (a: T, b: T) => number;\n};\n\nconst DEFAULT_LIMIT = 10;\nconst DEFAULT_SEARCH_TONE = 0.5;\nconst MIN_LIMIT = 1;\n\nfunction getPages<T>(data: T[], size: number, sortFn: Config<T>['sortFn']): T[][] {\n const sortedData = sortFn ? [...data].sort(sortFn) : [...data];\n return chunk<T>(sortedData, size) as T[][];\n}\n\nfunction getData<T>(data: T[], currentFilterFn: Predicate<T>, query = ''): T[] {\n const searchResults = query ? search(data, query, DEFAULT_SEARCH_TONE) : data;\n return searchResults.filter(currentFilterFn) as T[];\n}\n\nexport function list<T>(initialData: T[], config: Config<T> = {}) {\n let { limit = DEFAULT_LIMIT, filterFn = () => true, sortFn } = config;\n let rawData = [...initialData];\n let offset = 0;\n let query = '';\n let data = getData(rawData, filterFn);\n let pages = getPages(data, limit, sortFn);\n\n const update = () => {\n data = getData(rawData, filterFn, query);\n pages = getPages(data, limit, sortFn);\n offset = Math.max(0, Math.min(offset, pages.length - 1));\n return pages[offset] ?? [];\n };\n\n return {\n get current() {\n return pages[offset] ?? [];\n },\n set data(newData: T[]) {\n rawData = [...newData];\n offset = 0;\n update();\n },\n filter(predicate: (item: T) => boolean) {\n filterFn = predicate;\n offset = 0;\n return update();\n },\n set limit(newLimit: number) {\n limit = Math.max(MIN_LIMIT, newLimit);\n update();\n },\n get meta() {\n return {\n end: Math.min(limit * (offset + 1), data.length),\n isEmpty: data.length === 0,\n isFirst: offset === 0,\n isLast: offset === pages.length - 1,\n limit: limit,\n page: offset + 1,\n pages: Math.ceil(data.length / limit),\n start: Math.max(0, limit * offset + 1),\n total: data.length,\n };\n },\n next() {\n if (offset < pages.length - 1) {\n offset++;\n }\n },\n set page(page: number) {\n const index = page - 1;\n const value = index < 0 ? pages.length + index : index;\n offset = Math.max(0, Math.min(value, pages.length - 1));\n },\n get pages() {\n return pages;\n },\n prev() {\n if (offset > 0) {\n offset--;\n }\n },\n reset() {\n offset = 0;\n query = '';\n filterFn = config.filterFn ?? (() => true);\n return update();\n },\n search: debounce((str: string) => {\n query = str;\n return update();\n }),\n sort(fn?: (a: T, b: T) => number) {\n sortFn = fn;\n return update();\n },\n *[Symbol.iterator]() {\n for (const page of pages) {\n yield page;\n }\n },\n };\n}\n"],"names":["DEFAULT_LIMIT","DEFAULT_SEARCH_TONE","MIN_LIMIT","getPages","data","size","sortFn","sortedData","chunk","getData","currentFilterFn","query","search","list","initialData","config","limit","filterFn","rawData","offset","pages","update","newData","predicate","newLimit","page","index","value","debounce","str","fn"],"mappings":"+KAWMA,EAAgB,GAChBC,EAAsB,GACtBC,EAAY,EAElB,SAASC,EAAYC,EAAWC,EAAcC,EAAoC,CAChF,MAAMC,EAAaD,EAAS,CAAC,GAAGF,CAAI,EAAE,KAAKE,CAAM,EAAI,CAAC,GAAGF,CAAI,EAC7D,OAAOI,EAAAA,MAASD,EAAYF,CAAI,CAClC,CAEA,SAASI,EAAWL,EAAWM,EAA+BC,EAAQ,GAAS,CAE7E,OADsBA,EAAQC,EAAAA,OAAOR,EAAMO,EAAOV,CAAmB,EAAIG,GACpD,OAAOM,CAAe,CAC7C,CAEO,SAASG,EAAQC,EAAkBC,EAAoB,GAAI,CAChE,GAAI,CAAE,MAAAC,EAAQhB,EAAe,SAAAiB,EAAW,IAAM,GAAM,OAAAX,GAAWS,EAC3DG,EAAU,CAAC,GAAGJ,CAAW,EACzBK,EAAS,EACTR,EAAQ,GACRP,EAAOK,EAAQS,EAASD,CAAQ,EAChCG,EAAQjB,EAASC,EAAMY,EAAOV,CAAM,EAExC,MAAMe,EAAS,KACbjB,EAAOK,EAAQS,EAASD,EAAUN,CAAK,EACvCS,EAAQjB,EAASC,EAAMY,EAAOV,CAAM,EACpCa,EAAS,KAAK,IAAI,EAAG,KAAK,IAAIA,EAAQC,EAAM,OAAS,CAAC,CAAC,EAChDA,EAAMD,CAAM,GAAK,CAAA,GAG1B,MAAO,CACL,IAAI,SAAU,CACZ,OAAOC,EAAMD,CAAM,GAAK,CAAA,CAC1B,EACA,IAAI,KAAKG,EAAc,CACrBJ,EAAU,CAAC,GAAGI,CAAO,EACrBH,EAAS,EACTE,EAAA,CACF,EACA,OAAOE,EAAiC,CACtC,OAAAN,EAAWM,EACXJ,EAAS,EACFE,EAAA,CACT,EACA,IAAI,MAAMG,EAAkB,CAC1BR,EAAQ,KAAK,IAAId,EAAWsB,CAAQ,EACpCH,EAAA,CACF,EACA,IAAI,MAAO,CACT,MAAO,CACL,IAAK,KAAK,IAAIL,GAASG,EAAS,GAAIf,EAAK,MAAM,EAC/C,QAASA,EAAK,SAAW,EACzB,QAASe,IAAW,EACpB,OAAQA,IAAWC,EAAM,OAAS,EAClC,MAAAJ,EACA,KAAMG,EAAS,EACf,MAAO,KAAK,KAAKf,EAAK,OAASY,CAAK,EACpC,MAAO,KAAK,IAAI,EAAGA,EAAQG,EAAS,CAAC,EACrC,MAAOf,EAAK,MAAA,CAEhB,EACA,MAAO,CACDe,EAASC,EAAM,OAAS,GAC1BD,GAEJ,EACA,IAAI,KAAKM,EAAc,CACrB,MAAMC,EAAQD,EAAO,EACfE,EAAQD,EAAQ,EAAIN,EAAM,OAASM,EAAQA,EACjDP,EAAS,KAAK,IAAI,EAAG,KAAK,IAAIQ,EAAOP,EAAM,OAAS,CAAC,CAAC,CACxD,EACA,IAAI,OAAQ,CACV,OAAOA,CACT,EACA,MAAO,CACDD,EAAS,GACXA,GAEJ,EACA,OAAQ,CACN,OAAAA,EAAS,EACTR,EAAQ,GACRM,EAAWF,EAAO,WAAa,IAAM,IAC9BM,EAAA,CACT,EACA,OAAQO,EAAAA,SAAUC,IAChBlB,EAAQkB,EACDR,EAAA,EACR,EACD,KAAKS,EAA6B,CAChC,OAAAxB,EAASwB,EACFT,EAAA,CACT,EACA,EAAE,OAAO,QAAQ,GAAI,CACnB,UAAWI,KAAQL,EACjB,MAAMK,CAEV,CAAA,CAEJ"}
@@ -0,0 +1,70 @@
1
+ import { debounce as M } from "../function/debounce.js";
2
+ import { chunk as x } from "./chunk.js";
3
+ import { search as d } from "./search.js";
4
+ const D = 10, E = 0.5, F = 1;
5
+ function m(a, o, e) {
6
+ const s = e ? [...a].sort(e) : [...a];
7
+ return x(s, o);
8
+ }
9
+ function f(a, o, e = "") {
10
+ return (e ? d(a, e, E) : a).filter(o);
11
+ }
12
+ function _(a, o = {}) {
13
+ let { limit: e = D, filterFn: s = () => !0, sortFn: u } = o, h = [...a], t = 0, g = "", l = f(h, s), n = m(l, e, u);
14
+ const i = () => (l = f(h, s, g), n = m(l, e, u), t = Math.max(0, Math.min(t, n.length - 1)), n[t] ?? []);
15
+ return {
16
+ get current() {
17
+ return n[t] ?? [];
18
+ },
19
+ set data(r) {
20
+ h = [...r], t = 0, i();
21
+ },
22
+ filter(r) {
23
+ return s = r, t = 0, i();
24
+ },
25
+ set limit(r) {
26
+ e = Math.max(F, r), i();
27
+ },
28
+ get meta() {
29
+ return {
30
+ end: Math.min(e * (t + 1), l.length),
31
+ isEmpty: l.length === 0,
32
+ isFirst: t === 0,
33
+ isLast: t === n.length - 1,
34
+ limit: e,
35
+ page: t + 1,
36
+ pages: Math.ceil(l.length / e),
37
+ start: Math.max(0, e * t + 1),
38
+ total: l.length
39
+ };
40
+ },
41
+ next() {
42
+ t < n.length - 1 && t++;
43
+ },
44
+ set page(r) {
45
+ const c = r - 1, p = c < 0 ? n.length + c : c;
46
+ t = Math.max(0, Math.min(p, n.length - 1));
47
+ },
48
+ get pages() {
49
+ return n;
50
+ },
51
+ prev() {
52
+ t > 0 && t--;
53
+ },
54
+ reset() {
55
+ return t = 0, g = "", s = o.filterFn ?? (() => !0), i();
56
+ },
57
+ search: M((r) => (g = r, i())),
58
+ sort(r) {
59
+ return u = r, i();
60
+ },
61
+ *[Symbol.iterator]() {
62
+ for (const r of n)
63
+ yield r;
64
+ }
65
+ };
66
+ }
67
+ export {
68
+ _ as list
69
+ };
70
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sources":["../../src/array/list.ts"],"sourcesContent":["import { debounce } from '../function/debounce';\nimport type { Predicate } from '../types';\nimport { chunk } from './chunk';\nimport { search } from './search';\n\ntype Config<T> = {\n filterFn?: Predicate<T>;\n limit?: number;\n sortFn?: (a: T, b: T) => number;\n};\n\nconst DEFAULT_LIMIT = 10;\nconst DEFAULT_SEARCH_TONE = 0.5;\nconst MIN_LIMIT = 1;\n\nfunction getPages<T>(data: T[], size: number, sortFn: Config<T>['sortFn']): T[][] {\n const sortedData = sortFn ? [...data].sort(sortFn) : [...data];\n return chunk<T>(sortedData, size) as T[][];\n}\n\nfunction getData<T>(data: T[], currentFilterFn: Predicate<T>, query = ''): T[] {\n const searchResults = query ? search(data, query, DEFAULT_SEARCH_TONE) : data;\n return searchResults.filter(currentFilterFn) as T[];\n}\n\nexport function list<T>(initialData: T[], config: Config<T> = {}) {\n let { limit = DEFAULT_LIMIT, filterFn = () => true, sortFn } = config;\n let rawData = [...initialData];\n let offset = 0;\n let query = '';\n let data = getData(rawData, filterFn);\n let pages = getPages(data, limit, sortFn);\n\n const update = () => {\n data = getData(rawData, filterFn, query);\n pages = getPages(data, limit, sortFn);\n offset = Math.max(0, Math.min(offset, pages.length - 1));\n return pages[offset] ?? [];\n };\n\n return {\n get current() {\n return pages[offset] ?? [];\n },\n set data(newData: T[]) {\n rawData = [...newData];\n offset = 0;\n update();\n },\n filter(predicate: (item: T) => boolean) {\n filterFn = predicate;\n offset = 0;\n return update();\n },\n set limit(newLimit: number) {\n limit = Math.max(MIN_LIMIT, newLimit);\n update();\n },\n get meta() {\n return {\n end: Math.min(limit * (offset + 1), data.length),\n isEmpty: data.length === 0,\n isFirst: offset === 0,\n isLast: offset === pages.length - 1,\n limit: limit,\n page: offset + 1,\n pages: Math.ceil(data.length / limit),\n start: Math.max(0, limit * offset + 1),\n total: data.length,\n };\n },\n next() {\n if (offset < pages.length - 1) {\n offset++;\n }\n },\n set page(page: number) {\n const index = page - 1;\n const value = index < 0 ? pages.length + index : index;\n offset = Math.max(0, Math.min(value, pages.length - 1));\n },\n get pages() {\n return pages;\n },\n prev() {\n if (offset > 0) {\n offset--;\n }\n },\n reset() {\n offset = 0;\n query = '';\n filterFn = config.filterFn ?? (() => true);\n return update();\n },\n search: debounce((str: string) => {\n query = str;\n return update();\n }),\n sort(fn?: (a: T, b: T) => number) {\n sortFn = fn;\n return update();\n },\n *[Symbol.iterator]() {\n for (const page of pages) {\n yield page;\n }\n },\n };\n}\n"],"names":["DEFAULT_LIMIT","DEFAULT_SEARCH_TONE","MIN_LIMIT","getPages","data","size","sortFn","sortedData","chunk","getData","currentFilterFn","query","search","list","initialData","config","limit","filterFn","rawData","offset","pages","update","newData","predicate","newLimit","page","index","value","debounce","str","fn"],"mappings":";;;AAWA,MAAMA,IAAgB,IAChBC,IAAsB,KACtBC,IAAY;AAElB,SAASC,EAAYC,GAAWC,GAAcC,GAAoC;AAChF,QAAMC,IAAaD,IAAS,CAAC,GAAGF,CAAI,EAAE,KAAKE,CAAM,IAAI,CAAC,GAAGF,CAAI;AAC7D,SAAOI,EAASD,GAAYF,CAAI;AAClC;AAEA,SAASI,EAAWL,GAAWM,GAA+BC,IAAQ,IAAS;AAE7E,UADsBA,IAAQC,EAAOR,GAAMO,GAAOV,CAAmB,IAAIG,GACpD,OAAOM,CAAe;AAC7C;AAEO,SAASG,EAAQC,GAAkBC,IAAoB,IAAI;AAChE,MAAI,EAAE,OAAAC,IAAQhB,GAAe,UAAAiB,IAAW,MAAM,IAAM,QAAAX,MAAWS,GAC3DG,IAAU,CAAC,GAAGJ,CAAW,GACzBK,IAAS,GACTR,IAAQ,IACRP,IAAOK,EAAQS,GAASD,CAAQ,GAChCG,IAAQjB,EAASC,GAAMY,GAAOV,CAAM;AAExC,QAAMe,IAAS,OACbjB,IAAOK,EAAQS,GAASD,GAAUN,CAAK,GACvCS,IAAQjB,EAASC,GAAMY,GAAOV,CAAM,GACpCa,IAAS,KAAK,IAAI,GAAG,KAAK,IAAIA,GAAQC,EAAM,SAAS,CAAC,CAAC,GAChDA,EAAMD,CAAM,KAAK,CAAA;AAG1B,SAAO;AAAA,IACL,IAAI,UAAU;AACZ,aAAOC,EAAMD,CAAM,KAAK,CAAA;AAAA,IAC1B;AAAA,IACA,IAAI,KAAKG,GAAc;AACrB,MAAAJ,IAAU,CAAC,GAAGI,CAAO,GACrBH,IAAS,GACTE,EAAA;AAAA,IACF;AAAA,IACA,OAAOE,GAAiC;AACtC,aAAAN,IAAWM,GACXJ,IAAS,GACFE,EAAA;AAAA,IACT;AAAA,IACA,IAAI,MAAMG,GAAkB;AAC1B,MAAAR,IAAQ,KAAK,IAAId,GAAWsB,CAAQ,GACpCH,EAAA;AAAA,IACF;AAAA,IACA,IAAI,OAAO;AACT,aAAO;AAAA,QACL,KAAK,KAAK,IAAIL,KAASG,IAAS,IAAIf,EAAK,MAAM;AAAA,QAC/C,SAASA,EAAK,WAAW;AAAA,QACzB,SAASe,MAAW;AAAA,QACpB,QAAQA,MAAWC,EAAM,SAAS;AAAA,QAClC,OAAAJ;AAAA,QACA,MAAMG,IAAS;AAAA,QACf,OAAO,KAAK,KAAKf,EAAK,SAASY,CAAK;AAAA,QACpC,OAAO,KAAK,IAAI,GAAGA,IAAQG,IAAS,CAAC;AAAA,QACrC,OAAOf,EAAK;AAAA,MAAA;AAAA,IAEhB;AAAA,IACA,OAAO;AACL,MAAIe,IAASC,EAAM,SAAS,KAC1BD;AAAA,IAEJ;AAAA,IACA,IAAI,KAAKM,GAAc;AACrB,YAAMC,IAAQD,IAAO,GACfE,IAAQD,IAAQ,IAAIN,EAAM,SAASM,IAAQA;AACjD,MAAAP,IAAS,KAAK,IAAI,GAAG,KAAK,IAAIQ,GAAOP,EAAM,SAAS,CAAC,CAAC;AAAA,IACxD;AAAA,IACA,IAAI,QAAQ;AACV,aAAOA;AAAA,IACT;AAAA,IACA,OAAO;AACL,MAAID,IAAS,KACXA;AAAA,IAEJ;AAAA,IACA,QAAQ;AACN,aAAAA,IAAS,GACTR,IAAQ,IACRM,IAAWF,EAAO,aAAa,MAAM,KAC9BM,EAAA;AAAA,IACT;AAAA,IACA,QAAQO,EAAS,CAACC,OAChBlB,IAAQkB,GACDR,EAAA,EACR;AAAA,IACD,KAAKS,GAA6B;AAChC,aAAAxB,IAASwB,GACFT,EAAA;AAAA,IACT;AAAA,IACA,EAAE,OAAO,QAAQ,IAAI;AACnB,iBAAWI,KAAQL;AACjB,cAAMK;AAAA,IAEV;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../function/assert.cjs"),i=require("../typed/isArray.cjs"),u=require("../typed/isPromise.cjs");function o(e,s){n.assert(i.isArray(e),i.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});const t=Array(e.length);for(let r=0;r<e.length;r++)t[r]=s(e[r],r,e);return u.isPromise(s)?Promise.all(t):t}o.fp=!0;exports.map=o;
2
+ //# sourceMappingURL=map.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.cjs","sources":["../../src/array/map.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isPromise } from '../typed/isPromise';\nimport type { CallbackDynamic, ResultArray } from '../types';\n\n/**\n * Transforms an array by applying a callback function to each of its elements.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3];\n * map(arr, x => x * 2); // [2, 4, 6]\n * map(arr, async x => x * 2); // Promise<[2, 4, 6]>\n * ```\n *\n * @param array - The array to be transformed.\n * @param callback - The function to invoke for each element in the array.\n *\n * @return The transformed array, either as a synchronous result or a Promise if lazy is set.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function map<T, R, C extends CallbackDynamic<T, R>>(array: T[], callback: C): ResultArray<C> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, {\n args: { array },\n type: TypeError,\n });\n\n const result = Array(array.length);\n\n for (let index = 0; index < array.length; index++) {\n result[index] = callback(array[index], index, array);\n }\n\n return (isPromise(callback) ? Promise.all(result) : result) as ResultArray<C>;\n}\n\nmap.fp = true;\n"],"names":["map","array","callback","assert","isArray","IS_ARRAY_ERROR_MSG","result","index","isPromise"],"mappings":"gMAsBO,SAASA,EAA2CC,EAAYC,EAA6B,CAClGC,EAAAA,OAAOC,EAAAA,QAAQH,CAAK,EAAGI,qBAAoB,CACzC,KAAM,CAAE,MAAAJ,CAAA,EACR,KAAM,SAAA,CACP,EAED,MAAMK,EAAS,MAAML,EAAM,MAAM,EAEjC,QAASM,EAAQ,EAAGA,EAAQN,EAAM,OAAQM,IACxCD,EAAOC,CAAK,EAAIL,EAASD,EAAMM,CAAK,EAAGA,EAAON,CAAK,EAGrD,OAAQO,EAAAA,UAAUN,CAAQ,EAAI,QAAQ,IAAII,CAAM,EAAIA,CACtD,CAEAN,EAAI,GAAK"}
@@ -0,0 +1,18 @@
1
+ import { assert as i } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as m, isArray as s } from "../typed/isArray.js";
3
+ import { isPromise as p } from "../typed/isPromise.js";
4
+ function n(t, r) {
5
+ i(s(t), m, {
6
+ args: { array: t },
7
+ type: TypeError
8
+ });
9
+ const o = Array(t.length);
10
+ for (let e = 0; e < t.length; e++)
11
+ o[e] = r(t[e], e, t);
12
+ return p(r) ? Promise.all(o) : o;
13
+ }
14
+ n.fp = !0;
15
+ export {
16
+ n as map
17
+ };
18
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sources":["../../src/array/map.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isPromise } from '../typed/isPromise';\nimport type { CallbackDynamic, ResultArray } from '../types';\n\n/**\n * Transforms an array by applying a callback function to each of its elements.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3];\n * map(arr, x => x * 2); // [2, 4, 6]\n * map(arr, async x => x * 2); // Promise<[2, 4, 6]>\n * ```\n *\n * @param array - The array to be transformed.\n * @param callback - The function to invoke for each element in the array.\n *\n * @return The transformed array, either as a synchronous result or a Promise if lazy is set.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function map<T, R, C extends CallbackDynamic<T, R>>(array: T[], callback: C): ResultArray<C> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, {\n args: { array },\n type: TypeError,\n });\n\n const result = Array(array.length);\n\n for (let index = 0; index < array.length; index++) {\n result[index] = callback(array[index], index, array);\n }\n\n return (isPromise(callback) ? Promise.all(result) : result) as ResultArray<C>;\n}\n\nmap.fp = true;\n"],"names":["map","array","callback","assert","isArray","IS_ARRAY_ERROR_MSG","result","index","isPromise"],"mappings":";;;AAsBO,SAASA,EAA2CC,GAAYC,GAA6B;AAClG,EAAAC,EAAOC,EAAQH,CAAK,GAAGI,GAAoB;AAAA,IACzC,MAAM,EAAE,OAAAJ,EAAA;AAAA,IACR,MAAM;AAAA,EAAA,CACP;AAED,QAAMK,IAAS,MAAML,EAAM,MAAM;AAEjC,WAASM,IAAQ,GAAGA,IAAQN,EAAM,QAAQM;AACxC,IAAAD,EAAOC,CAAK,IAAIL,EAASD,EAAMM,CAAK,GAAGA,GAAON,CAAK;AAGrD,SAAQO,EAAUN,CAAQ,IAAI,QAAQ,IAAII,CAAM,IAAIA;AACtD;AAEAN,EAAI,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../function/assert.cjs"),t=require("../typed/isArray.cjs"),c=require("../typed/isNil.cjs");function s(i,r,n){u.assert(t.isArray(i),t.IS_ARRAY_ERROR_MSG,{args:{array:i},type:TypeError});const o=n??(e=>!c.isNil(e));for(let e=0;e<i.length;e++)if(o(i[e],e,i))return r(i[e],e,i)}s.fp=!0;exports.pick=s;
2
+ //# sourceMappingURL=pick.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.cjs","sources":["../../src/array/pick.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isNil } from '../typed/isNil';\nimport type { CallbackDynamic, Predicate, Result } from '../types';\n\n/**\n * Picks the first element from an array that satisfies a predicate function\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * pick(arr, x => x * x, x => x > 2) // 9\n * await pick(arr, async x => x * x, x => x > 2) // 9\n * ```\n *\n * @param array - The array to search.\n * @param callback - A function that is called for each element in the array.\n * @param predicate - A function that is called to validate each element in the array.\n *\n * @return The first element that satisfies the predicate, or undefined if no such element is found.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function pick<T, R, C extends CallbackDynamic<T, R>>(\n array: T[],\n callback: C,\n predicate?: Predicate<T>,\n): Result<C> | undefined {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const isValid = predicate ?? ((value: T) => !isNil(value));\n\n for (let index = 0; index < array.length; index++) {\n if (isValid(array[index], index, array)) {\n return callback(array[index], index, array) as Result<C>;\n }\n }\n\n return undefined;\n}\n\npick.fp = true;\n"],"names":["pick","array","callback","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","isValid","value","isNil","index"],"mappings":"4LAuBO,SAASA,EACdC,EACAC,EACAC,EACuB,CACvBC,EAAAA,OAAOC,EAAAA,QAAQJ,CAAK,EAAGK,qBAAoB,CAAE,KAAM,CAAE,MAAAL,CAAA,EAAS,KAAM,UAAW,EAE/E,MAAMM,EAAUJ,IAAeK,GAAa,CAACC,EAAAA,MAAMD,CAAK,GAExD,QAASE,EAAQ,EAAGA,EAAQT,EAAM,OAAQS,IACxC,GAAIH,EAAQN,EAAMS,CAAK,EAAGA,EAAOT,CAAK,EACpC,OAAOC,EAASD,EAAMS,CAAK,EAAGA,EAAOT,CAAK,CAKhD,CAEAD,EAAK,GAAK"}
@@ -0,0 +1,15 @@
1
+ import { assert as r } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as f, isArray as n } from "../typed/isArray.js";
3
+ import { isNil as s } from "../typed/isNil.js";
4
+ function m(t, o, e) {
5
+ r(n(t), f, { args: { array: t }, type: TypeError });
6
+ const p = e ?? ((i) => !s(i));
7
+ for (let i = 0; i < t.length; i++)
8
+ if (p(t[i], i, t))
9
+ return o(t[i], i, t);
10
+ }
11
+ m.fp = !0;
12
+ export {
13
+ m as pick
14
+ };
15
+ //# sourceMappingURL=pick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.js","sources":["../../src/array/pick.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isNil } from '../typed/isNil';\nimport type { CallbackDynamic, Predicate, Result } from '../types';\n\n/**\n * Picks the first element from an array that satisfies a predicate function\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * pick(arr, x => x * x, x => x > 2) // 9\n * await pick(arr, async x => x * x, x => x > 2) // 9\n * ```\n *\n * @param array - The array to search.\n * @param callback - A function that is called for each element in the array.\n * @param predicate - A function that is called to validate each element in the array.\n *\n * @return The first element that satisfies the predicate, or undefined if no such element is found.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function pick<T, R, C extends CallbackDynamic<T, R>>(\n array: T[],\n callback: C,\n predicate?: Predicate<T>,\n): Result<C> | undefined {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const isValid = predicate ?? ((value: T) => !isNil(value));\n\n for (let index = 0; index < array.length; index++) {\n if (isValid(array[index], index, array)) {\n return callback(array[index], index, array) as Result<C>;\n }\n }\n\n return undefined;\n}\n\npick.fp = true;\n"],"names":["pick","array","callback","predicate","assert","isArray","IS_ARRAY_ERROR_MSG","isValid","value","isNil","index"],"mappings":";;;AAuBO,SAASA,EACdC,GACAC,GACAC,GACuB;AACvB,EAAAC,EAAOC,EAAQJ,CAAK,GAAGK,GAAoB,EAAE,MAAM,EAAE,OAAAL,EAAA,GAAS,MAAM,WAAW;AAE/E,QAAMM,IAAUJ,MAAc,CAACK,MAAa,CAACC,EAAMD,CAAK;AAExD,WAASE,IAAQ,GAAGA,IAAQT,EAAM,QAAQS;AACxC,QAAIH,EAAQN,EAAMS,CAAK,GAAGA,GAAOT,CAAK;AACpC,aAAOC,EAASD,EAAMS,CAAK,GAAGA,GAAOT,CAAK;AAKhD;AAEAD,EAAK,KAAK;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../function/assert.cjs"),n=require("../typed/isArray.cjs"),R=require("../typed/isPromise.cjs");function u(e,r,o){f.assert(n.isArray(e),n.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError});const i=R.isPromise(r);let t=i?Promise.resolve(o):o;for(let s=0;s<e.length;s++)i?t=t.then(c=>r(c,e[s],s,e)):t=r(t,e[s],s,e);return t}u.fn=!0;exports.reduce=u;
2
+ //# sourceMappingURL=reduce.cjs.map