@vielzeug/toolkit 1.1.2 → 2.0.0

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 (764) hide show
  1. package/README.md +419 -0
  2. package/dist/array/chunk.cjs +2 -2
  3. package/dist/array/chunk.cjs.map +1 -1
  4. package/dist/array/chunk.d.ts +29 -0
  5. package/dist/array/chunk.d.ts.map +1 -0
  6. package/dist/array/chunk.js +22 -24
  7. package/dist/array/chunk.js.map +1 -1
  8. package/dist/array/contains.cjs +2 -2
  9. package/dist/array/contains.cjs.map +1 -1
  10. package/dist/array/contains.d.ts +19 -0
  11. package/dist/array/contains.d.ts.map +1 -0
  12. package/dist/array/contains.js +12 -9
  13. package/dist/array/contains.js.map +1 -1
  14. package/dist/array/fold.cjs +2 -0
  15. package/dist/array/fold.cjs.map +1 -0
  16. package/dist/array/fold.d.ts +21 -0
  17. package/dist/array/fold.d.ts.map +1 -0
  18. package/dist/array/fold.js +19 -0
  19. package/dist/array/fold.js.map +1 -0
  20. package/dist/array/group.cjs +2 -2
  21. package/dist/array/group.cjs.map +1 -1
  22. package/dist/array/group.d.ts +19 -0
  23. package/dist/array/group.d.ts.map +1 -0
  24. package/dist/array/group.js +18 -15
  25. package/dist/array/group.js.map +1 -1
  26. package/dist/array/index.d.ts +16 -0
  27. package/dist/array/index.d.ts.map +1 -0
  28. package/dist/array/keyBy.cjs +2 -0
  29. package/dist/array/keyBy.cjs.map +1 -0
  30. package/dist/array/keyBy.d.ts +20 -0
  31. package/dist/array/keyBy.d.ts.map +1 -0
  32. package/dist/array/keyBy.js +19 -0
  33. package/dist/array/keyBy.js.map +1 -0
  34. package/dist/array/list.cjs +2 -2
  35. package/dist/array/list.cjs.map +1 -1
  36. package/dist/array/list.d.ts +58 -0
  37. package/dist/array/list.d.ts.map +1 -0
  38. package/dist/array/list.js +103 -106
  39. package/dist/array/list.js.map +1 -1
  40. package/dist/array/pick.cjs +2 -2
  41. package/dist/array/pick.cjs.map +1 -1
  42. package/dist/array/pick.d.ts +19 -0
  43. package/dist/array/pick.d.ts.map +1 -0
  44. package/dist/array/pick.js +15 -14
  45. package/dist/array/pick.js.map +1 -1
  46. package/dist/array/remoteList.cjs +2 -2
  47. package/dist/array/remoteList.cjs.map +1 -1
  48. package/dist/array/remoteList.d.ts +64 -0
  49. package/dist/array/remoteList.d.ts.map +1 -0
  50. package/dist/array/remoteList.js +121 -122
  51. package/dist/array/remoteList.js.map +1 -1
  52. package/dist/array/replace.cjs +2 -0
  53. package/dist/array/replace.cjs.map +1 -0
  54. package/dist/array/replace.d.ts +20 -0
  55. package/dist/array/replace.d.ts.map +1 -0
  56. package/dist/array/replace.js +19 -0
  57. package/dist/array/replace.js.map +1 -0
  58. package/dist/array/rotate.cjs +2 -0
  59. package/dist/array/rotate.cjs.map +1 -0
  60. package/dist/array/rotate.d.ts +22 -0
  61. package/dist/array/rotate.d.ts.map +1 -0
  62. package/dist/array/rotate.js +19 -0
  63. package/dist/array/rotate.js.map +1 -0
  64. package/dist/array/search.cjs +2 -2
  65. package/dist/array/search.cjs.map +1 -1
  66. package/dist/array/search.d.ts +19 -0
  67. package/dist/array/search.d.ts.map +1 -0
  68. package/dist/array/search.js +23 -13
  69. package/dist/array/search.js.map +1 -1
  70. package/dist/array/select.cjs +2 -2
  71. package/dist/array/select.cjs.map +1 -1
  72. package/dist/array/select.d.ts +21 -0
  73. package/dist/array/select.d.ts.map +1 -0
  74. package/dist/array/select.js +16 -15
  75. package/dist/array/select.js.map +1 -1
  76. package/dist/array/sort.cjs +2 -2
  77. package/dist/array/sort.cjs.map +1 -1
  78. package/dist/array/sort.d.ts +26 -0
  79. package/dist/array/sort.d.ts.map +1 -0
  80. package/dist/array/sort.js +18 -12
  81. package/dist/array/sort.js.map +1 -1
  82. package/dist/array/toggle.cjs +2 -0
  83. package/dist/array/toggle.cjs.map +1 -0
  84. package/dist/array/toggle.d.ts +29 -0
  85. package/dist/array/toggle.d.ts.map +1 -0
  86. package/dist/array/toggle.js +9 -0
  87. package/dist/array/toggle.js.map +1 -0
  88. package/dist/array/uniq.cjs +2 -2
  89. package/dist/array/uniq.cjs.map +1 -1
  90. package/dist/array/uniq.d.ts +21 -0
  91. package/dist/array/uniq.d.ts.map +1 -0
  92. package/dist/array/uniq.js +15 -17
  93. package/dist/array/uniq.js.map +1 -1
  94. package/dist/async/attempt.cjs +2 -2
  95. package/dist/async/attempt.cjs.map +1 -1
  96. package/dist/async/attempt.d.ts +40 -0
  97. package/dist/async/attempt.d.ts.map +1 -0
  98. package/dist/async/attempt.js +19 -14
  99. package/dist/async/attempt.js.map +1 -1
  100. package/dist/async/defer.cjs +2 -2
  101. package/dist/async/defer.cjs.map +1 -1
  102. package/dist/async/defer.d.ts +23 -0
  103. package/dist/async/defer.d.ts.map +1 -0
  104. package/dist/async/defer.js +12 -9
  105. package/dist/async/defer.js.map +1 -1
  106. package/dist/async/index.d.ts +12 -0
  107. package/dist/async/index.d.ts.map +1 -0
  108. package/dist/async/parallel.cjs +2 -2
  109. package/dist/async/parallel.cjs.map +1 -1
  110. package/dist/async/parallel.d.ts +31 -0
  111. package/dist/async/parallel.d.ts.map +1 -0
  112. package/dist/async/parallel.js +26 -27
  113. package/dist/async/parallel.js.map +1 -1
  114. package/dist/async/pool.cjs +2 -2
  115. package/dist/async/pool.cjs.map +1 -1
  116. package/dist/async/pool.d.ts +21 -0
  117. package/dist/async/pool.d.ts.map +1 -0
  118. package/dist/async/pool.js +23 -21
  119. package/dist/async/pool.js.map +1 -1
  120. package/dist/async/predict.cjs +2 -2
  121. package/dist/async/predict.cjs.map +1 -1
  122. package/dist/async/predict.d.ts +24 -0
  123. package/dist/async/predict.d.ts.map +1 -0
  124. package/dist/async/predict.js +10 -12
  125. package/dist/async/predict.js.map +1 -1
  126. package/dist/async/queue.cjs +2 -2
  127. package/dist/async/queue.cjs.map +1 -1
  128. package/dist/async/queue.d.ts +43 -0
  129. package/dist/async/queue.d.ts.map +1 -0
  130. package/dist/async/queue.js +52 -56
  131. package/dist/async/queue.js.map +1 -1
  132. package/dist/async/race.cjs +2 -2
  133. package/dist/async/race.cjs.map +1 -1
  134. package/dist/async/race.d.ts +16 -0
  135. package/dist/async/race.d.ts.map +1 -0
  136. package/dist/async/race.js +8 -7
  137. package/dist/async/race.js.map +1 -1
  138. package/dist/async/retry.cjs +2 -2
  139. package/dist/async/retry.cjs.map +1 -1
  140. package/dist/async/retry.d.ts +32 -0
  141. package/dist/async/retry.d.ts.map +1 -0
  142. package/dist/async/retry.js +19 -24
  143. package/dist/async/retry.js.map +1 -1
  144. package/dist/async/scheduler.cjs +2 -0
  145. package/dist/async/scheduler.cjs.map +1 -0
  146. package/dist/async/scheduler.d.ts +51 -0
  147. package/dist/async/scheduler.d.ts.map +1 -0
  148. package/dist/async/scheduler.js +43 -0
  149. package/dist/async/scheduler.js.map +1 -0
  150. package/dist/async/sleep.cjs +2 -2
  151. package/dist/async/sleep.cjs.map +1 -1
  152. package/dist/async/sleep.d.ts +16 -0
  153. package/dist/async/sleep.d.ts.map +1 -0
  154. package/dist/async/sleep.js +11 -11
  155. package/dist/async/sleep.js.map +1 -1
  156. package/dist/async/waitFor.cjs +2 -2
  157. package/dist/async/waitFor.cjs.map +1 -1
  158. package/dist/async/waitFor.d.ts +33 -0
  159. package/dist/async/waitFor.d.ts.map +1 -0
  160. package/dist/async/waitFor.js +29 -36
  161. package/dist/async/waitFor.js.map +1 -1
  162. package/dist/date/expires.cjs +2 -2
  163. package/dist/date/expires.cjs.map +1 -1
  164. package/dist/date/expires.d.ts +15 -0
  165. package/dist/date/expires.d.ts.map +1 -0
  166. package/dist/date/expires.js +11 -10
  167. package/dist/date/expires.js.map +1 -1
  168. package/dist/date/index.d.ts +4 -0
  169. package/dist/date/index.d.ts.map +1 -0
  170. package/dist/date/interval.cjs +2 -2
  171. package/dist/date/interval.cjs.map +1 -1
  172. package/dist/date/interval.d.ts +25 -0
  173. package/dist/date/interval.d.ts.map +1 -0
  174. package/dist/date/interval.js +31 -37
  175. package/dist/date/interval.js.map +1 -1
  176. package/dist/date/timeDiff.cjs +2 -2
  177. package/dist/date/timeDiff.cjs.map +1 -1
  178. package/dist/date/timeDiff.d.ts +24 -0
  179. package/dist/date/timeDiff.d.ts.map +1 -0
  180. package/dist/date/timeDiff.js +58 -25
  181. package/dist/date/timeDiff.js.map +1 -1
  182. package/dist/function/assert.cjs +2 -3
  183. package/dist/function/assert.cjs.map +1 -1
  184. package/dist/function/assert.d.ts +38 -0
  185. package/dist/function/assert.d.ts.map +1 -0
  186. package/dist/function/assert.js +13 -11
  187. package/dist/function/assert.js.map +1 -1
  188. package/dist/function/assertParams.cjs +2 -2
  189. package/dist/function/assertParams.cjs.map +1 -1
  190. package/dist/function/assertParams.d.ts +24 -0
  191. package/dist/function/assertParams.d.ts.map +1 -0
  192. package/dist/function/assertParams.js +13 -12
  193. package/dist/function/assertParams.js.map +1 -1
  194. package/dist/function/compare.cjs +2 -2
  195. package/dist/function/compare.cjs.map +1 -1
  196. package/dist/function/compare.d.ts +23 -0
  197. package/dist/function/compare.d.ts.map +1 -0
  198. package/dist/function/compare.js +22 -21
  199. package/dist/function/compare.js.map +1 -1
  200. package/dist/function/compareBy.cjs +2 -2
  201. package/dist/function/compareBy.cjs.map +1 -1
  202. package/dist/function/compareBy.d.ts +24 -0
  203. package/dist/function/compareBy.d.ts.map +1 -0
  204. package/dist/function/compareBy.js +15 -14
  205. package/dist/function/compareBy.js.map +1 -1
  206. package/dist/function/compose.cjs +2 -2
  207. package/dist/function/compose.cjs.map +1 -1
  208. package/dist/function/compose.d.ts +22 -0
  209. package/dist/function/compose.d.ts.map +1 -0
  210. package/dist/function/compose.js +10 -13
  211. package/dist/function/compose.js.map +1 -1
  212. package/dist/function/curry.cjs +2 -2
  213. package/dist/function/curry.cjs.map +1 -1
  214. package/dist/function/curry.d.ts +21 -0
  215. package/dist/function/curry.d.ts.map +1 -0
  216. package/dist/function/curry.js +8 -7
  217. package/dist/function/curry.js.map +1 -1
  218. package/dist/function/debounce.cjs +2 -2
  219. package/dist/function/debounce.cjs.map +1 -1
  220. package/dist/function/debounce.d.ts +12 -0
  221. package/dist/function/debounce.d.ts.map +1 -0
  222. package/dist/function/debounce.js +34 -26
  223. package/dist/function/debounce.js.map +1 -1
  224. package/dist/function/fp.cjs +2 -2
  225. package/dist/function/fp.cjs.map +1 -1
  226. package/dist/function/fp.d.ts +24 -0
  227. package/dist/function/fp.d.ts.map +1 -0
  228. package/dist/function/fp.js +6 -10
  229. package/dist/function/fp.js.map +1 -1
  230. package/dist/function/index.d.ts +13 -0
  231. package/dist/function/index.d.ts.map +1 -0
  232. package/dist/function/memo.cjs +2 -2
  233. package/dist/function/memo.cjs.map +1 -1
  234. package/dist/function/memo.d.ts +30 -0
  235. package/dist/function/memo.d.ts.map +1 -0
  236. package/dist/function/memo.js +16 -24
  237. package/dist/function/memo.js.map +1 -1
  238. package/dist/function/once.cjs +2 -2
  239. package/dist/function/once.cjs.map +1 -1
  240. package/dist/function/once.d.ts +24 -0
  241. package/dist/function/once.d.ts.map +1 -0
  242. package/dist/function/once.js +10 -10
  243. package/dist/function/once.js.map +1 -1
  244. package/dist/function/pipe.cjs +2 -2
  245. package/dist/function/pipe.cjs.map +1 -1
  246. package/dist/function/pipe.d.ts +23 -0
  247. package/dist/function/pipe.d.ts.map +1 -0
  248. package/dist/function/pipe.js +10 -10
  249. package/dist/function/pipe.js.map +1 -1
  250. package/dist/function/throttle.cjs +2 -2
  251. package/dist/function/throttle.cjs.map +1 -1
  252. package/dist/function/throttle.d.ts +21 -0
  253. package/dist/function/throttle.d.ts.map +1 -0
  254. package/dist/function/throttle.js +45 -37
  255. package/dist/function/throttle.js.map +1 -1
  256. package/dist/index.cjs +1 -2
  257. package/dist/index.d.ts +77 -2813
  258. package/dist/index.d.ts.map +1 -0
  259. package/dist/index.js +75 -253
  260. package/dist/math/abs.cjs +2 -2
  261. package/dist/math/abs.cjs.map +1 -1
  262. package/dist/math/abs.d.ts +17 -0
  263. package/dist/math/abs.d.ts.map +1 -0
  264. package/dist/math/abs.js +7 -6
  265. package/dist/math/abs.js.map +1 -1
  266. package/dist/math/allocate.cjs +2 -2
  267. package/dist/math/allocate.cjs.map +1 -1
  268. package/dist/math/allocate.d.ts +24 -0
  269. package/dist/math/allocate.d.ts.map +1 -0
  270. package/dist/math/allocate.js +20 -28
  271. package/dist/math/allocate.js.map +1 -1
  272. package/dist/math/average.cjs +2 -2
  273. package/dist/math/average.cjs.map +1 -1
  274. package/dist/math/average.d.ts +16 -0
  275. package/dist/math/average.d.ts.map +1 -0
  276. package/dist/math/average.js +13 -24
  277. package/dist/math/average.js.map +1 -1
  278. package/dist/math/clamp.cjs +2 -2
  279. package/dist/math/clamp.cjs.map +1 -1
  280. package/dist/math/clamp.d.ts +18 -0
  281. package/dist/math/clamp.d.ts.map +1 -0
  282. package/dist/math/clamp.js +7 -6
  283. package/dist/math/clamp.js.map +1 -1
  284. package/dist/math/distribute.cjs +2 -2
  285. package/dist/math/distribute.cjs.map +1 -1
  286. package/dist/math/distribute.d.ts +24 -0
  287. package/dist/math/distribute.d.ts.map +1 -0
  288. package/dist/math/distribute.js +14 -17
  289. package/dist/math/distribute.js.map +1 -1
  290. package/dist/math/index.d.ts +14 -0
  291. package/dist/math/index.d.ts.map +1 -0
  292. package/dist/math/linspace.cjs +2 -0
  293. package/dist/math/linspace.cjs.map +1 -0
  294. package/dist/math/linspace.d.ts +19 -0
  295. package/dist/math/linspace.d.ts.map +1 -0
  296. package/dist/math/linspace.js +11 -0
  297. package/dist/math/linspace.js.map +1 -0
  298. package/dist/math/max.cjs +2 -2
  299. package/dist/math/max.cjs.map +1 -1
  300. package/dist/math/max.d.ts +23 -0
  301. package/dist/math/max.d.ts.map +1 -0
  302. package/dist/math/max.js +10 -11
  303. package/dist/math/max.js.map +1 -1
  304. package/dist/math/median.cjs +2 -2
  305. package/dist/math/median.cjs.map +1 -1
  306. package/dist/math/median.d.ts +17 -0
  307. package/dist/math/median.d.ts.map +1 -0
  308. package/dist/math/median.js +11 -10
  309. package/dist/math/median.js.map +1 -1
  310. package/dist/math/min.cjs +2 -2
  311. package/dist/math/min.cjs.map +1 -1
  312. package/dist/math/min.d.ts +23 -0
  313. package/dist/math/min.d.ts.map +1 -0
  314. package/dist/math/min.js +10 -11
  315. package/dist/math/min.js.map +1 -1
  316. package/dist/math/percent.cjs +2 -0
  317. package/dist/math/percent.cjs.map +1 -0
  318. package/dist/math/percent.d.ts +19 -0
  319. package/dist/math/percent.d.ts.map +1 -0
  320. package/dist/math/percent.js +8 -0
  321. package/dist/math/percent.js.map +1 -0
  322. package/dist/math/range.cjs +2 -2
  323. package/dist/math/range.cjs.map +1 -1
  324. package/dist/math/range.d.ts +23 -0
  325. package/dist/math/range.d.ts.map +1 -0
  326. package/dist/math/range.js +28 -17
  327. package/dist/math/range.js.map +1 -1
  328. package/dist/math/round.cjs +2 -2
  329. package/dist/math/round.cjs.map +1 -1
  330. package/dist/math/round.d.ts +21 -0
  331. package/dist/math/round.d.ts.map +1 -0
  332. package/dist/math/round.js +9 -8
  333. package/dist/math/round.js.map +1 -1
  334. package/dist/math/sum.cjs +2 -2
  335. package/dist/math/sum.cjs.map +1 -1
  336. package/dist/math/sum.d.ts +17 -0
  337. package/dist/math/sum.d.ts.map +1 -0
  338. package/dist/math/sum.js +11 -14
  339. package/dist/math/sum.js.map +1 -1
  340. package/dist/money/currency.cjs +2 -2
  341. package/dist/money/currency.cjs.map +1 -1
  342. package/dist/money/currency.d.ts +30 -0
  343. package/dist/money/currency.d.ts.map +1 -0
  344. package/dist/money/currency.js +19 -47
  345. package/dist/money/currency.js.map +1 -1
  346. package/dist/money/exchange.cjs +2 -2
  347. package/dist/money/exchange.cjs.map +1 -1
  348. package/dist/money/exchange.d.ts +29 -0
  349. package/dist/money/exchange.d.ts.map +1 -0
  350. package/dist/money/exchange.js +12 -12
  351. package/dist/money/exchange.js.map +1 -1
  352. package/dist/money/index.d.ts +4 -0
  353. package/dist/money/index.d.ts.map +1 -0
  354. package/dist/money/types.d.ts +9 -0
  355. package/dist/money/types.d.ts.map +1 -0
  356. package/dist/object/diff.cjs +2 -2
  357. package/dist/object/diff.cjs.map +1 -1
  358. package/dist/object/diff.d.ts +26 -0
  359. package/dist/object/diff.d.ts.map +1 -0
  360. package/dist/object/diff.js +19 -17
  361. package/dist/object/diff.js.map +1 -1
  362. package/dist/object/index.d.ts +9 -0
  363. package/dist/object/index.d.ts.map +1 -0
  364. package/dist/object/merge.cjs +2 -2
  365. package/dist/object/merge.cjs.map +1 -1
  366. package/dist/object/merge.d.ts +44 -0
  367. package/dist/object/merge.d.ts.map +1 -0
  368. package/dist/object/merge.js +27 -21
  369. package/dist/object/merge.js.map +1 -1
  370. package/dist/object/parseJSON.cjs +2 -2
  371. package/dist/object/parseJSON.cjs.map +1 -1
  372. package/dist/object/parseJSON.d.ts +32 -0
  373. package/dist/object/parseJSON.d.ts.map +1 -0
  374. package/dist/object/parseJSON.js +17 -18
  375. package/dist/object/parseJSON.js.map +1 -1
  376. package/dist/object/path.cjs +2 -2
  377. package/dist/object/path.cjs.map +1 -1
  378. package/dist/object/path.d.ts +32 -0
  379. package/dist/object/path.d.ts.map +1 -0
  380. package/dist/object/path.js +25 -23
  381. package/dist/object/path.js.map +1 -1
  382. package/dist/object/proxy.cjs +2 -0
  383. package/dist/object/proxy.cjs.map +1 -0
  384. package/dist/object/proxy.d.ts +30 -0
  385. package/dist/object/proxy.d.ts.map +1 -0
  386. package/dist/object/proxy.js +21 -0
  387. package/dist/object/proxy.js.map +1 -0
  388. package/dist/object/prune.cjs +2 -0
  389. package/dist/object/prune.cjs.map +1 -0
  390. package/dist/object/prune.d.ts +21 -0
  391. package/dist/object/prune.d.ts.map +1 -0
  392. package/dist/object/prune.js +31 -0
  393. package/dist/object/prune.js.map +1 -0
  394. package/dist/object/seek.cjs +2 -2
  395. package/dist/object/seek.cjs.map +1 -1
  396. package/dist/object/seek.d.ts +2 -0
  397. package/dist/object/seek.d.ts.map +1 -0
  398. package/dist/object/seek.js +25 -12
  399. package/dist/object/seek.js.map +1 -1
  400. package/dist/object/stash.cjs +2 -0
  401. package/dist/object/stash.cjs.map +1 -0
  402. package/dist/object/stash.d.ts +45 -0
  403. package/dist/object/stash.d.ts.map +1 -0
  404. package/dist/object/stash.js +99 -0
  405. package/dist/object/stash.js.map +1 -0
  406. package/dist/random/draw.cjs +2 -2
  407. package/dist/random/draw.cjs.map +1 -1
  408. package/dist/random/draw.d.ts +16 -0
  409. package/dist/random/draw.d.ts.map +1 -0
  410. package/dist/random/draw.js +13 -10
  411. package/dist/random/draw.js.map +1 -1
  412. package/dist/random/index.d.ts +5 -0
  413. package/dist/random/index.d.ts.map +1 -0
  414. package/dist/random/random.cjs +2 -2
  415. package/dist/random/random.cjs.map +1 -1
  416. package/dist/random/random.d.ts +14 -0
  417. package/dist/random/random.d.ts.map +1 -0
  418. package/dist/random/random.js +16 -9
  419. package/dist/random/random.js.map +1 -1
  420. package/dist/random/shuffle.cjs +2 -2
  421. package/dist/random/shuffle.cjs.map +1 -1
  422. package/dist/random/shuffle.d.ts +17 -0
  423. package/dist/random/shuffle.d.ts.map +1 -0
  424. package/dist/random/shuffle.js +18 -14
  425. package/dist/random/shuffle.js.map +1 -1
  426. package/dist/random/uuid.cjs +2 -2
  427. package/dist/random/uuid.cjs.map +1 -1
  428. package/dist/random/uuid.d.ts +12 -0
  429. package/dist/random/uuid.d.ts.map +1 -0
  430. package/dist/random/uuid.js +7 -9
  431. package/dist/random/uuid.js.map +1 -1
  432. package/dist/string/_caseUtils.cjs +2 -2
  433. package/dist/string/_caseUtils.cjs.map +1 -1
  434. package/dist/string/_caseUtils.d.ts +13 -0
  435. package/dist/string/_caseUtils.d.ts.map +1 -0
  436. package/dist/string/_caseUtils.js +8 -8
  437. package/dist/string/_caseUtils.js.map +1 -1
  438. package/dist/string/camelCase.cjs +2 -2
  439. package/dist/string/camelCase.cjs.map +1 -1
  440. package/dist/string/camelCase.d.ts +14 -0
  441. package/dist/string/camelCase.d.ts.map +1 -0
  442. package/dist/string/camelCase.js +8 -7
  443. package/dist/string/camelCase.js.map +1 -1
  444. package/dist/string/index.d.ts +7 -0
  445. package/dist/string/index.d.ts.map +1 -0
  446. package/dist/string/kebabCase.cjs +2 -2
  447. package/dist/string/kebabCase.cjs.map +1 -1
  448. package/dist/string/kebabCase.d.ts +15 -0
  449. package/dist/string/kebabCase.d.ts.map +1 -0
  450. package/dist/string/kebabCase.js +8 -7
  451. package/dist/string/kebabCase.js.map +1 -1
  452. package/dist/string/pascalCase.cjs +2 -2
  453. package/dist/string/pascalCase.cjs.map +1 -1
  454. package/dist/string/pascalCase.d.ts +15 -0
  455. package/dist/string/pascalCase.d.ts.map +1 -0
  456. package/dist/string/pascalCase.js +8 -7
  457. package/dist/string/pascalCase.js.map +1 -1
  458. package/dist/string/similarity.cjs +2 -2
  459. package/dist/string/similarity.cjs.map +1 -1
  460. package/dist/string/similarity.d.ts +20 -0
  461. package/dist/string/similarity.d.ts.map +1 -0
  462. package/dist/string/similarity.js +20 -36
  463. package/dist/string/similarity.js.map +1 -1
  464. package/dist/string/snakeCase.cjs +2 -2
  465. package/dist/string/snakeCase.cjs.map +1 -1
  466. package/dist/string/snakeCase.d.ts +15 -0
  467. package/dist/string/snakeCase.d.ts.map +1 -0
  468. package/dist/string/snakeCase.js +8 -7
  469. package/dist/string/snakeCase.js.map +1 -1
  470. package/dist/string/truncate.cjs +2 -2
  471. package/dist/string/truncate.cjs.map +1 -1
  472. package/dist/string/truncate.d.ts +28 -0
  473. package/dist/string/truncate.d.ts.map +1 -0
  474. package/dist/string/truncate.js +20 -17
  475. package/dist/string/truncate.js.map +1 -1
  476. package/dist/toolkit.cjs +2 -0
  477. package/dist/toolkit.cjs.map +1 -0
  478. package/dist/toolkit.js +1523 -0
  479. package/dist/toolkit.js.map +1 -0
  480. package/dist/typed/index.d.ts +24 -0
  481. package/dist/typed/index.d.ts.map +1 -0
  482. package/dist/typed/is.cjs +2 -2
  483. package/dist/typed/is.cjs.map +1 -1
  484. package/dist/typed/is.d.ts +95 -0
  485. package/dist/typed/is.d.ts.map +1 -0
  486. package/dist/typed/is.js +54 -42
  487. package/dist/typed/is.js.map +1 -1
  488. package/dist/typed/isArray.cjs +2 -2
  489. package/dist/typed/isArray.cjs.map +1 -1
  490. package/dist/typed/isArray.d.ts +16 -0
  491. package/dist/typed/isArray.d.ts.map +1 -0
  492. package/dist/typed/isArray.js +8 -8
  493. package/dist/typed/isArray.js.map +1 -1
  494. package/dist/typed/isBoolean.cjs +2 -2
  495. package/dist/typed/isBoolean.cjs.map +1 -1
  496. package/dist/typed/isBoolean.d.ts +23 -0
  497. package/dist/typed/isBoolean.d.ts.map +1 -0
  498. package/dist/typed/isBoolean.js +7 -6
  499. package/dist/typed/isBoolean.js.map +1 -1
  500. package/dist/typed/isDate.cjs +2 -2
  501. package/dist/typed/isDate.cjs.map +1 -1
  502. package/dist/typed/isDate.d.ts +16 -0
  503. package/dist/typed/isDate.d.ts.map +1 -0
  504. package/dist/typed/isDate.js +7 -8
  505. package/dist/typed/isDate.js.map +1 -1
  506. package/dist/typed/isDefined.cjs +2 -2
  507. package/dist/typed/isDefined.cjs.map +1 -1
  508. package/dist/typed/isDefined.d.ts +19 -0
  509. package/dist/typed/isDefined.d.ts.map +1 -0
  510. package/dist/typed/isDefined.js +7 -6
  511. package/dist/typed/isDefined.js.map +1 -1
  512. package/dist/typed/isEmpty.cjs +2 -2
  513. package/dist/typed/isEmpty.cjs.map +1 -1
  514. package/dist/typed/isEmpty.d.ts +24 -0
  515. package/dist/typed/isEmpty.d.ts.map +1 -0
  516. package/dist/typed/isEmpty.js +8 -9
  517. package/dist/typed/isEmpty.js.map +1 -1
  518. package/dist/typed/isEqual.cjs +2 -2
  519. package/dist/typed/isEqual.cjs.map +1 -1
  520. package/dist/typed/isEqual.d.ts +24 -0
  521. package/dist/typed/isEqual.d.ts.map +1 -0
  522. package/dist/typed/isEqual.js +27 -28
  523. package/dist/typed/isEqual.js.map +1 -1
  524. package/dist/typed/isEven.cjs +2 -2
  525. package/dist/typed/isEven.cjs.map +1 -1
  526. package/dist/typed/isEven.d.ts +9 -0
  527. package/dist/typed/isEven.d.ts.map +1 -0
  528. package/dist/typed/isEven.js +7 -6
  529. package/dist/typed/isEven.js.map +1 -1
  530. package/dist/typed/isFunction.cjs +2 -2
  531. package/dist/typed/isFunction.cjs.map +1 -1
  532. package/dist/typed/isFunction.d.ts +16 -0
  533. package/dist/typed/isFunction.d.ts.map +1 -0
  534. package/dist/typed/isFunction.js +7 -8
  535. package/dist/typed/isFunction.js.map +1 -1
  536. package/dist/typed/isMatch.cjs +2 -2
  537. package/dist/typed/isMatch.cjs.map +1 -1
  538. package/dist/typed/isMatch.d.ts +23 -0
  539. package/dist/typed/isMatch.d.ts.map +1 -0
  540. package/dist/typed/isMatch.js +16 -18
  541. package/dist/typed/isMatch.js.map +1 -1
  542. package/dist/typed/isNegative.cjs +2 -2
  543. package/dist/typed/isNegative.cjs.map +1 -1
  544. package/dist/typed/isNegative.d.ts +26 -0
  545. package/dist/typed/isNegative.d.ts.map +1 -0
  546. package/dist/typed/isNegative.js +7 -6
  547. package/dist/typed/isNegative.js.map +1 -1
  548. package/dist/typed/isNil.cjs +2 -2
  549. package/dist/typed/isNil.cjs.map +1 -1
  550. package/dist/typed/isNil.d.ts +17 -0
  551. package/dist/typed/isNil.d.ts.map +1 -0
  552. package/dist/typed/isNil.js +7 -8
  553. package/dist/typed/isNil.js.map +1 -1
  554. package/dist/typed/isNumber.cjs +2 -2
  555. package/dist/typed/isNumber.cjs.map +1 -1
  556. package/dist/typed/isNumber.d.ts +16 -0
  557. package/dist/typed/isNumber.d.ts.map +1 -0
  558. package/dist/typed/isNumber.js +8 -8
  559. package/dist/typed/isNumber.js.map +1 -1
  560. package/dist/typed/isObject.cjs +2 -2
  561. package/dist/typed/isObject.cjs.map +1 -1
  562. package/dist/typed/isObject.d.ts +19 -0
  563. package/dist/typed/isObject.d.ts.map +1 -0
  564. package/dist/typed/isObject.js +8 -8
  565. package/dist/typed/isObject.js.map +1 -1
  566. package/dist/typed/isOdd.cjs +2 -2
  567. package/dist/typed/isOdd.cjs.map +1 -1
  568. package/dist/typed/isOdd.d.ts +9 -0
  569. package/dist/typed/isOdd.d.ts.map +1 -0
  570. package/dist/typed/isOdd.js +7 -6
  571. package/dist/typed/isOdd.js.map +1 -1
  572. package/dist/typed/isPositive.cjs +2 -2
  573. package/dist/typed/isPositive.cjs.map +1 -1
  574. package/dist/typed/isPositive.d.ts +26 -0
  575. package/dist/typed/isPositive.d.ts.map +1 -0
  576. package/dist/typed/isPositive.js +7 -6
  577. package/dist/typed/isPositive.js.map +1 -1
  578. package/dist/typed/isPrimitive.cjs +2 -2
  579. package/dist/typed/isPrimitive.cjs.map +1 -1
  580. package/dist/typed/isPrimitive.d.ts +18 -0
  581. package/dist/typed/isPrimitive.d.ts.map +1 -0
  582. package/dist/typed/isPrimitive.js +8 -9
  583. package/dist/typed/isPrimitive.js.map +1 -1
  584. package/dist/typed/isPromise.cjs +2 -2
  585. package/dist/typed/isPromise.cjs.map +1 -1
  586. package/dist/typed/isPromise.d.ts +17 -0
  587. package/dist/typed/isPromise.d.ts.map +1 -0
  588. package/dist/typed/isPromise.js +7 -9
  589. package/dist/typed/isPromise.js.map +1 -1
  590. package/dist/typed/isRegex.cjs +2 -2
  591. package/dist/typed/isRegex.cjs.map +1 -1
  592. package/dist/typed/isRegex.d.ts +21 -0
  593. package/dist/typed/isRegex.d.ts.map +1 -0
  594. package/dist/typed/isRegex.js +7 -6
  595. package/dist/typed/isRegex.js.map +1 -1
  596. package/dist/typed/isString.cjs +2 -2
  597. package/dist/typed/isString.cjs.map +1 -1
  598. package/dist/typed/isString.d.ts +16 -0
  599. package/dist/typed/isString.d.ts.map +1 -0
  600. package/dist/typed/isString.js +8 -8
  601. package/dist/typed/isString.js.map +1 -1
  602. package/dist/typed/isWithin.cjs +2 -2
  603. package/dist/typed/isWithin.cjs.map +1 -1
  604. package/dist/typed/isWithin.d.ts +20 -0
  605. package/dist/typed/isWithin.d.ts.map +1 -0
  606. package/dist/typed/isWithin.js +9 -9
  607. package/dist/typed/isWithin.js.map +1 -1
  608. package/dist/typed/isZero.cjs +2 -2
  609. package/dist/typed/isZero.cjs.map +1 -1
  610. package/dist/typed/isZero.d.ts +25 -0
  611. package/dist/typed/isZero.d.ts.map +1 -0
  612. package/dist/typed/isZero.js +7 -6
  613. package/dist/typed/isZero.js.map +1 -1
  614. package/dist/typed/typeOf.cjs +2 -2
  615. package/dist/typed/typeOf.cjs.map +1 -1
  616. package/dist/typed/typeOf.d.ts +30 -0
  617. package/dist/typed/typeOf.d.ts.map +1 -0
  618. package/dist/typed/typeOf.js +11 -13
  619. package/dist/typed/typeOf.js.map +1 -1
  620. package/dist/types.d.ts +9 -0
  621. package/dist/types.d.ts.map +1 -0
  622. package/package.json +77 -12
  623. package/dist/array/aggregate.cjs +0 -2
  624. package/dist/array/aggregate.cjs.map +0 -1
  625. package/dist/array/aggregate.js +0 -16
  626. package/dist/array/aggregate.js.map +0 -1
  627. package/dist/array/alternate.cjs +0 -2
  628. package/dist/array/alternate.cjs.map +0 -1
  629. package/dist/array/alternate.js +0 -9
  630. package/dist/array/alternate.js.map +0 -1
  631. package/dist/array/arrange.cjs +0 -2
  632. package/dist/array/arrange.cjs.map +0 -1
  633. package/dist/array/arrange.js +0 -6
  634. package/dist/array/arrange.js.map +0 -1
  635. package/dist/array/compact.cjs +0 -2
  636. package/dist/array/compact.cjs.map +0 -1
  637. package/dist/array/compact.js +0 -9
  638. package/dist/array/compact.js.map +0 -1
  639. package/dist/array/every.cjs +0 -2
  640. package/dist/array/every.cjs.map +0 -1
  641. package/dist/array/every.js +0 -14
  642. package/dist/array/every.js.map +0 -1
  643. package/dist/array/filter.cjs +0 -2
  644. package/dist/array/filter.cjs.map +0 -1
  645. package/dist/array/filter.js +0 -14
  646. package/dist/array/filter.js.map +0 -1
  647. package/dist/array/find.cjs +0 -2
  648. package/dist/array/find.cjs.map +0 -1
  649. package/dist/array/find.js +0 -14
  650. package/dist/array/find.js.map +0 -1
  651. package/dist/array/findIndex.cjs +0 -2
  652. package/dist/array/findIndex.cjs.map +0 -1
  653. package/dist/array/findIndex.js +0 -14
  654. package/dist/array/findIndex.js.map +0 -1
  655. package/dist/array/findLast.cjs +0 -2
  656. package/dist/array/findLast.cjs.map +0 -1
  657. package/dist/array/findLast.js +0 -14
  658. package/dist/array/findLast.js.map +0 -1
  659. package/dist/array/flatten.cjs +0 -2
  660. package/dist/array/flatten.cjs.map +0 -1
  661. package/dist/array/flatten.js +0 -7
  662. package/dist/array/flatten.js.map +0 -1
  663. package/dist/array/map.cjs +0 -2
  664. package/dist/array/map.cjs.map +0 -1
  665. package/dist/array/map.js +0 -18
  666. package/dist/array/map.js.map +0 -1
  667. package/dist/array/reduce.cjs +0 -2
  668. package/dist/array/reduce.cjs.map +0 -1
  669. package/dist/array/reduce.js +0 -16
  670. package/dist/array/reduce.js.map +0 -1
  671. package/dist/array/shift.cjs +0 -2
  672. package/dist/array/shift.cjs.map +0 -1
  673. package/dist/array/shift.js +0 -13
  674. package/dist/array/shift.js.map +0 -1
  675. package/dist/array/some.cjs +0 -2
  676. package/dist/array/some.cjs.map +0 -1
  677. package/dist/array/some.js +0 -14
  678. package/dist/array/some.js.map +0 -1
  679. package/dist/array/substitute.cjs +0 -2
  680. package/dist/array/substitute.cjs.map +0 -1
  681. package/dist/array/substitute.js +0 -13
  682. package/dist/array/substitute.js.map +0 -1
  683. package/dist/async/delay.cjs +0 -2
  684. package/dist/async/delay.cjs.map +0 -1
  685. package/dist/async/delay.js +0 -8
  686. package/dist/async/delay.js.map +0 -1
  687. package/dist/function/proxy.cjs +0 -2
  688. package/dist/function/proxy.cjs.map +0 -1
  689. package/dist/function/proxy.js +0 -22
  690. package/dist/function/proxy.js.map +0 -1
  691. package/dist/function/prune.cjs +0 -2
  692. package/dist/function/prune.cjs.map +0 -1
  693. package/dist/function/prune.js +0 -30
  694. package/dist/function/prune.js.map +0 -1
  695. package/dist/function/worker.cjs +0 -14
  696. package/dist/function/worker.cjs.map +0 -1
  697. package/dist/function/worker.js +0 -29
  698. package/dist/function/worker.js.map +0 -1
  699. package/dist/index.cjs.map +0 -1
  700. package/dist/index.js.map +0 -1
  701. package/dist/logit/dist/logit.cjs +0 -2
  702. package/dist/logit/dist/logit.cjs.map +0 -1
  703. package/dist/logit/dist/logit.js +0 -263
  704. package/dist/logit/dist/logit.js.map +0 -1
  705. package/dist/math/add.cjs +0 -2
  706. package/dist/math/add.cjs.map +0 -1
  707. package/dist/math/add.js +0 -9
  708. package/dist/math/add.js.map +0 -1
  709. package/dist/math/boil.cjs +0 -2
  710. package/dist/math/boil.cjs.map +0 -1
  711. package/dist/math/boil.js +0 -17
  712. package/dist/math/boil.js.map +0 -1
  713. package/dist/math/divide.cjs +0 -2
  714. package/dist/math/divide.cjs.map +0 -1
  715. package/dist/math/divide.js +0 -11
  716. package/dist/math/divide.js.map +0 -1
  717. package/dist/math/multiply.cjs +0 -2
  718. package/dist/math/multiply.cjs.map +0 -1
  719. package/dist/math/multiply.js +0 -9
  720. package/dist/math/multiply.js.map +0 -1
  721. package/dist/math/rate.cjs +0 -2
  722. package/dist/math/rate.cjs.map +0 -1
  723. package/dist/math/rate.js +0 -9
  724. package/dist/math/rate.js.map +0 -1
  725. package/dist/math/subtract.cjs +0 -2
  726. package/dist/math/subtract.cjs.map +0 -1
  727. package/dist/math/subtract.js +0 -9
  728. package/dist/math/subtract.js.map +0 -1
  729. package/dist/object/cache.cjs +0 -2
  730. package/dist/object/cache.cjs.map +0 -1
  731. package/dist/object/cache.js +0 -63
  732. package/dist/object/cache.js.map +0 -1
  733. package/dist/object/clone.cjs +0 -2
  734. package/dist/object/clone.cjs.map +0 -1
  735. package/dist/object/clone.js +0 -17
  736. package/dist/object/clone.js.map +0 -1
  737. package/dist/object/entries.cjs +0 -2
  738. package/dist/object/entries.cjs.map +0 -1
  739. package/dist/object/entries.js +0 -9
  740. package/dist/object/entries.js.map +0 -1
  741. package/dist/object/keys.cjs +0 -2
  742. package/dist/object/keys.cjs.map +0 -1
  743. package/dist/object/keys.js +0 -9
  744. package/dist/object/keys.js.map +0 -1
  745. package/dist/object/values.cjs +0 -2
  746. package/dist/object/values.cjs.map +0 -1
  747. package/dist/object/values.js +0 -9
  748. package/dist/object/values.js.map +0 -1
  749. package/dist/typed/ge.cjs +0 -2
  750. package/dist/typed/ge.cjs.map +0 -1
  751. package/dist/typed/ge.js +0 -7
  752. package/dist/typed/ge.js.map +0 -1
  753. package/dist/typed/gt.cjs +0 -2
  754. package/dist/typed/gt.cjs.map +0 -1
  755. package/dist/typed/gt.js +0 -7
  756. package/dist/typed/gt.js.map +0 -1
  757. package/dist/typed/le.cjs +0 -2
  758. package/dist/typed/le.cjs.map +0 -1
  759. package/dist/typed/le.js +0 -7
  760. package/dist/typed/le.js.map +0 -1
  761. package/dist/typed/lt.cjs +0 -2
  762. package/dist/typed/lt.cjs.map +0 -1
  763. package/dist/typed/lt.js +0 -7
  764. package/dist/typed/lt.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"average.js","sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers or dates.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * average(arr, (num) => new Date(Date.now() + 1000 * 60 * 60 * 24 * num); // Date object representing 3 days from now\n * ```\n *\n * @param array - The array of numbers or dates to average.\n * @param callback - (optional) A callback function to map the values.\n * @returns The average of the numbers or dates in the array.\n */\n\nexport function average<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (array.length === 0) return undefined;\n\n // Check if we are dealing with Dates (either directly or via callback)\n const firstItem = callback ? callback(array[0]) : array[0];\n const isDate = firstItem instanceof Date;\n\n if (isDate) {\n const totalTimestamp = array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : item;\n if (!(val instanceof Date)) {\n throw new TypeError('average expected all items to be Date objects');\n }\n return acc + val.getTime();\n }, 0);\n return new Date(totalTimestamp / array.length);\n }\n\n // Handle numbers\n try {\n const total = sum(array, callback as (item: T) => number);\n if (typeof total === 'number') {\n return total / array.length;\n }\n } catch (err) {\n if (err instanceof TypeError) return undefined;\n throw err;\n }\n\n return undefined;\n}\n"],"names":["average","array","callback","totalTimestamp","acc","item","val","total","sum","err"],"mappings":";AAkBO,SAASA,EAAWC,GAAYC,GAAkE;AACvG,MAAID,EAAM,WAAW,EAAG;AAMxB,OAHkBC,IAAWA,EAASD,EAAM,CAAC,CAAC,IAAIA,EAAM,CAAC,cACrB,MAExB;AACV,UAAME,IAAiBF,EAAM,OAAe,CAACG,GAAKC,MAAS;AACzD,YAAMC,IAAMJ,IAAWA,EAASG,CAAI,IAAIA;AACxC,UAAI,EAAEC,aAAe;AACnB,cAAM,IAAI,UAAU,+CAA+C;AAErE,aAAOF,IAAME,EAAI,QAAA;AAAA,IACnB,GAAG,CAAC;AACJ,WAAO,IAAI,KAAKH,IAAiBF,EAAM,MAAM;AAAA,EAC/C;AAGA,MAAI;AACF,UAAMM,IAAQC,EAAIP,GAAOC,CAA+B;AACxD,QAAI,OAAOK,KAAU;AACnB,aAAOA,IAAQN,EAAM;AAAA,EAEzB,SAASQ,GAAK;AACZ,QAAIA,aAAe,UAAW;AAC9B,UAAMA;AAAA,EACR;AAGF;"}
1
+ {"version":3,"file":"average.js","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty or contains non-numeric values.\n */\nexport function average<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n try {\n const result = sum(array, callback) / array.length;\n\n return Number.isNaN(result) ? undefined : result;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;AAgBA,SAAgB,EAAW,GAAY,GAAoD;AACrF,OAAM,WAAW,EAErB,KAAI;EACF,IAAM,IAAS,EAAI,GAAO,EAAS,GAAG,EAAM;AAE5C,SAAO,OAAO,MAAM,EAAO,GAAG,KAAA,IAAY;SACpC;AACN"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,e,a){return Math.min(Math.max(t,e),a)}exports.clamp=n;
2
- //# sourceMappingURL=clamp.cjs.map
1
+ function e(e,t,n){return Math.min(Math.max(e,t),n)}exports.clamp=e;
2
+ //# sourceMappingURL=clamp.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"clamp.cjs","sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * The `clamp` function restricts a number to be within a specified range.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5\n * clamp(0, 1, 10) // 1\n * clamp(15, 1, 10) // 10\n * ```\n *\n * @param n - The number to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(Math.max(n, min), max);\n}\n"],"names":["clamp","n","min","max"],"mappings":"gFAgBO,SAASA,EAAMC,EAAWC,EAAaC,EAAqB,CACjE,OAAO,KAAK,IAAI,KAAK,IAAIF,EAAGC,CAAG,EAAGC,CAAG,CACvC"}
1
+ {"version":3,"file":"clamp.cjs","names":[],"sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * The `clamp` function restricts a number to be within a specified range.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5\n * clamp(0, 1, 10) // 1\n * clamp(15, 1, 10) // 10\n * ```\n *\n * @param n - The number to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(Math.max(n, min), max);\n}\n"],"mappings":"AAgBA,SAAgB,EAAM,EAAW,EAAa,EAAqB,CACjE,OAAO,KAAK,IAAI,KAAK,IAAI,EAAG,EAAI,CAAE,EAAI"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The `clamp` function restricts a number to be within a specified range.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * clamp(5, 1, 10) // 5
7
+ * clamp(0, 1, 10) // 1
8
+ * clamp(15, 1, 10) // 10
9
+ * ```
10
+ *
11
+ * @param n - The number to be clamped.
12
+ * @param min - The minimum value of the range.
13
+ * @param max - The maximum value of the range.
14
+ *
15
+ * @returns The clamped number.
16
+ */
17
+ export declare function clamp(n: number, min: number, max: number): number;
18
+ //# sourceMappingURL=clamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjE"}
@@ -1,7 +1,8 @@
1
- function m(t, a, n) {
2
- return Math.min(Math.max(t, a), n);
1
+ //#region src/math/clamp.ts
2
+ function e(e, t, n) {
3
+ return Math.min(Math.max(e, t), n);
3
4
  }
4
- export {
5
- m as clamp
6
- };
7
- //# sourceMappingURL=clamp.js.map
5
+ //#endregion
6
+ export { e as clamp };
7
+
8
+ //# sourceMappingURL=clamp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clamp.js","sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * The `clamp` function restricts a number to be within a specified range.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5\n * clamp(0, 1, 10) // 1\n * clamp(15, 1, 10) // 10\n * ```\n *\n * @param n - The number to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(Math.max(n, min), max);\n}\n"],"names":["clamp","n","min","max"],"mappings":"AAgBO,SAASA,EAAMC,GAAWC,GAAaC,GAAqB;AACjE,SAAO,KAAK,IAAI,KAAK,IAAIF,GAAGC,CAAG,GAAGC,CAAG;AACvC;"}
1
+ {"version":3,"file":"clamp.js","names":[],"sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * The `clamp` function restricts a number to be within a specified range.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5\n * clamp(0, 1, 10) // 1\n * clamp(15, 1, 10) // 10\n * ```\n *\n * @param n - The number to be clamped.\n * @param min - The minimum value of the range.\n * @param max - The maximum value of the range.\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(Math.max(n, min), max);\n}\n"],"mappings":";AAgBA,SAAgB,EAAM,GAAW,GAAa,GAAqB;AACjE,QAAO,KAAK,IAAI,KAAK,IAAI,GAAG,EAAI,EAAE,EAAI"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(r,e){if(e<1)throw new Error("Parts must be at least 1");if(typeof r=="bigint"){const t=r/BigInt(e),b=r%BigInt(e),o=[];for(let n=0;n<e;n++)o.push(n<Number(b)?t+1n:t);return o}const i=Math.floor(r/e),u=r-i*e,s=[];for(let t=0;t<e;t++)s.push(t<u?i+1:i);return s}exports.distribute=c;
2
- //# sourceMappingURL=distribute.cjs.map
1
+ function e(e,t){if(t<1)throw Error(`Parts must be at least 1`);if(typeof e==`bigint`){let n=e/BigInt(t),r=e%BigInt(t),i=[];for(let e=0;e<t;e++)i.push(BigInt(e)<r?n+1n:n);return i}let n=Math.floor(e/t),r=e-n*t;return Array.from({length:t},(e,t)=>t<r?n+1:n)}exports.distribute=e;
2
+ //# sourceMappingURL=distribute.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"distribute.cjs","sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < Number(remainder) ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n const results: number[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < remainder ? baseShare + 1 : baseShare);\n }\n\n return results;\n}\n"],"names":["distribute","amount","parts","baseShare","remainder","results","i"],"mappings":"gFAuBO,SAASA,EAAWC,EAAyBC,EAAoC,CACtF,GAAIA,EAAQ,EACV,MAAM,IAAI,MAAM,0BAA0B,EAG5C,GAAI,OAAOD,GAAW,SAAU,CAC9B,MAAME,EAAYF,EAAS,OAAOC,CAAK,EACjCE,EAAYH,EAAS,OAAOC,CAAK,EACjCG,EAAoB,CAAA,EAE1B,QAASC,EAAI,EAAGA,EAAIJ,EAAOI,IAEzBD,EAAQ,KAAKC,EAAI,OAAOF,CAAS,EAAID,EAAY,GAAKA,CAAS,EAGjE,OAAOE,CACT,CAGA,MAAMF,EAAY,KAAK,MAAMF,EAASC,CAAK,EACrCE,EAAYH,EAASE,EAAYD,EACjCG,EAAoB,CAAA,EAE1B,QAASC,EAAI,EAAGA,EAAIJ,EAAOI,IAEzBD,EAAQ,KAAKC,EAAIF,EAAYD,EAAY,EAAIA,CAAS,EAGxD,OAAOE,CACT"}
1
+ {"version":3,"file":"distribute.cjs","names":[],"sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(BigInt(i) < remainder ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n\n return Array.from({ length: parts }, (_, i) => (i < remainder ? baseShare + 1 : baseShare));\n}\n"],"mappings":"AAuBA,SAAgB,EAAW,EAAyB,EAAoC,CACtF,GAAI,EAAQ,EACV,MAAU,MAAM,2BAA2B,CAG7C,GAAI,OAAO,GAAW,SAAU,CAC9B,IAAM,EAAY,EAAS,OAAO,EAAM,CAClC,EAAY,EAAS,OAAO,EAAM,CAClC,EAAoB,EAAE,CAE5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IAEzB,EAAQ,KAAK,OAAO,EAAE,CAAG,EAAY,EAAY,GAAK,EAAU,CAGlE,OAAO,EAIT,IAAM,EAAY,KAAK,MAAM,EAAS,EAAM,CACtC,EAAY,EAAS,EAAY,EAEvC,OAAO,MAAM,KAAK,CAAE,OAAQ,EAAO,EAAG,EAAG,IAAO,EAAI,EAAY,EAAY,EAAI,EAAW"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Distributes an amount evenly among N parties.
3
+ * Handles rounding to ensure the sum equals the original amount exactly.
4
+ * Useful for splitting bills, costs, or payments equally.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * // Split $100 among 3 people
9
+ * distribute(100, 3);
10
+ * // [34, 33, 33] - sum is exactly 100
11
+ *
12
+ * // Split with bigint (e.g., cents)
13
+ * distribute(10000n, 3);
14
+ * // [3334n, 3333n, 3333n] - sum is exactly 10000n
15
+ * ```
16
+ *
17
+ * @param amount - Total amount to distribute
18
+ * @param parts - Number of parts to divide into
19
+ * @returns Array of distributed amounts (a sum equals original amount)
20
+ * @throws {Error} If parts are less than 1
21
+ */
22
+ export declare function distribute(amount: number, parts: number): number[];
23
+ export declare function distribute(amount: bigint, parts: number): bigint[];
24
+ //# sourceMappingURL=distribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribute.d.ts","sourceRoot":"","sources":["../../src/math/distribute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AACpE,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC"}
@@ -1,18 +1,15 @@
1
- function b(t, e) {
2
- if (e < 1)
3
- throw new Error("Parts must be at least 1");
4
- if (typeof t == "bigint") {
5
- const r = t / BigInt(e), f = t % BigInt(e), o = [];
6
- for (let n = 0; n < e; n++)
7
- o.push(n < Number(f) ? r + 1n : r);
8
- return o;
9
- }
10
- const i = Math.floor(t / e), c = t - i * e, s = [];
11
- for (let r = 0; r < e; r++)
12
- s.push(r < c ? i + 1 : i);
13
- return s;
1
+ //#region src/math/distribute.ts
2
+ function e(e, t) {
3
+ if (t < 1) throw Error("Parts must be at least 1");
4
+ if (typeof e == "bigint") {
5
+ let n = e / BigInt(t), r = e % BigInt(t), i = [];
6
+ for (let e = 0; e < t; e++) i.push(BigInt(e) < r ? n + 1n : n);
7
+ return i;
8
+ }
9
+ let n = Math.floor(e / t), r = e - n * t;
10
+ return Array.from({ length: t }, (e, t) => t < r ? n + 1 : n);
14
11
  }
15
- export {
16
- b as distribute
17
- };
18
- //# sourceMappingURL=distribute.js.map
12
+ //#endregion
13
+ export { e as distribute };
14
+
15
+ //# sourceMappingURL=distribute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"distribute.js","sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < Number(remainder) ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n const results: number[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(i < remainder ? baseShare + 1 : baseShare);\n }\n\n return results;\n}\n"],"names":["distribute","amount","parts","baseShare","remainder","results","i"],"mappings":"AAuBO,SAASA,EAAWC,GAAyBC,GAAoC;AACtF,MAAIA,IAAQ;AACV,UAAM,IAAI,MAAM,0BAA0B;AAG5C,MAAI,OAAOD,KAAW,UAAU;AAC9B,UAAME,IAAYF,IAAS,OAAOC,CAAK,GACjCE,IAAYH,IAAS,OAAOC,CAAK,GACjCG,IAAoB,CAAA;AAE1B,aAASC,IAAI,GAAGA,IAAIJ,GAAOI;AAEzBD,MAAAA,EAAQ,KAAKC,IAAI,OAAOF,CAAS,IAAID,IAAY,KAAKA,CAAS;AAGjE,WAAOE;AAAAA,EACT;AAGA,QAAMF,IAAY,KAAK,MAAMF,IAASC,CAAK,GACrCE,IAAYH,IAASE,IAAYD,GACjCG,IAAoB,CAAA;AAE1B,WAASC,IAAI,GAAGA,IAAIJ,GAAOI;AAEzB,IAAAD,EAAQ,KAAKC,IAAIF,IAAYD,IAAY,IAAIA,CAAS;AAGxD,SAAOE;AACT;"}
1
+ {"version":3,"file":"distribute.js","names":[],"sources":["../../src/math/distribute.ts"],"sourcesContent":["/**\n * Distributes an amount evenly among N parties.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * Useful for splitting bills, costs, or payments equally.\n *\n * @example\n * ```ts\n * // Split $100 among 3 people\n * distribute(100, 3);\n * // [34, 33, 33] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * distribute(10000n, 3);\n * // [3334n, 3333n, 3333n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to distribute\n * @param parts - Number of parts to divide into\n * @returns Array of distributed amounts (a sum equals original amount)\n * @throws {Error} If parts are less than 1\n */\nexport function distribute(amount: number, parts: number): number[];\nexport function distribute(amount: bigint, parts: number): bigint[];\nexport function distribute(amount: number | bigint, parts: number): (number | bigint)[] {\n if (parts < 1) {\n throw new Error('Parts must be at least 1');\n }\n\n if (typeof amount === 'bigint') {\n const baseShare = amount / BigInt(parts);\n const remainder = amount % BigInt(parts);\n const results: bigint[] = [];\n\n for (let i = 0; i < parts; i++) {\n // Distribute the remainder to first items\n results.push(BigInt(i) < remainder ? baseShare + 1n : baseShare);\n }\n\n return results;\n }\n\n // Handle number type\n const baseShare = Math.floor(amount / parts);\n const remainder = amount - baseShare * parts;\n\n return Array.from({ length: parts }, (_, i) => (i < remainder ? baseShare + 1 : baseShare));\n}\n"],"mappings":";AAuBA,SAAgB,EAAW,GAAyB,GAAoC;AACtF,KAAI,IAAQ,EACV,OAAU,MAAM,2BAA2B;AAG7C,KAAI,OAAO,KAAW,UAAU;EAC9B,IAAM,IAAY,IAAS,OAAO,EAAM,EAClC,IAAY,IAAS,OAAO,EAAM,EAClC,IAAoB,EAAE;AAE5B,OAAK,IAAI,IAAI,GAAG,IAAI,GAAO,IAEzB,GAAQ,KAAK,OAAO,EAAE,GAAG,IAAY,IAAY,KAAK,EAAU;AAGlE,SAAO;;CAIT,IAAM,IAAY,KAAK,MAAM,IAAS,EAAM,EACtC,IAAY,IAAS,IAAY;AAEvC,QAAO,MAAM,KAAK,EAAE,QAAQ,GAAO,GAAG,GAAG,MAAO,IAAI,IAAY,IAAY,IAAI,EAAW"}
@@ -0,0 +1,14 @@
1
+ export * from './abs';
2
+ export * from './allocate';
3
+ export * from './average';
4
+ export * from './clamp';
5
+ export * from './distribute';
6
+ export * from './linspace';
7
+ export * from './max';
8
+ export * from './median';
9
+ export * from './min';
10
+ export * from './percent';
11
+ export * from './range';
12
+ export * from './round';
13
+ export * from './sum';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ function e(e,t,n=5){if(n<=0)return[];if(n===1)return[e];let r=(t-e)/(n-1);return Array.from({length:n},(t,n)=>e+n*r)}exports.linspace=e;
2
+ //# sourceMappingURL=linspace.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linspace.cjs","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":"AAiBA,SAAgB,EAAS,EAAe,EAAa,EAAQ,EAAa,CACxE,GAAI,GAAS,EAAG,MAAO,EAAE,CAEzB,GAAI,IAAU,EAAG,MAAO,CAAC,EAAM,CAE/B,IAAM,GAAY,EAAM,IAAU,EAAQ,GAE1C,OAAO,MAAM,KAAK,CAAE,OAAQ,EAAO,EAAG,EAAG,IAAM,EAAQ,EAAI,EAAS"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Creates an array of evenly-spaced numbers from `start` to `end`.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]
7
+ * linspace(0, 10, 3); // [0, 5, 10]
8
+ * linspace(0, 10, 1); // [0]
9
+ * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]
10
+ * ```
11
+ *
12
+ * @param start - The start of the range.
13
+ * @param end - The end of the range.
14
+ * @param steps - Number of evenly-spaced points to generate (default: 5).
15
+ *
16
+ * @returns An array of `steps` numbers from `start` to `end`.
17
+ */
18
+ export declare function linspace(start: number, end: number, steps?: number): number[];
19
+ //# sourceMappingURL=linspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linspace.d.ts","sourceRoot":"","sources":["../../src/math/linspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,EAAE,CAQxE"}
@@ -0,0 +1,11 @@
1
+ //#region src/math/linspace.ts
2
+ function e(e, t, n = 5) {
3
+ if (n <= 0) return [];
4
+ if (n === 1) return [e];
5
+ let r = (t - e) / (n - 1);
6
+ return Array.from({ length: n }, (t, n) => e + n * r);
7
+ }
8
+ //#endregion
9
+ export { e as linspace };
10
+
11
+ //# sourceMappingURL=linspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linspace.js","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":";AAiBA,SAAgB,EAAS,GAAe,GAAa,IAAQ,GAAa;AACxE,KAAI,KAAS,EAAG,QAAO,EAAE;AAEzB,KAAI,MAAU,EAAG,QAAO,CAAC,EAAM;CAE/B,IAAM,KAAY,IAAM,MAAU,IAAQ;AAE1C,QAAO,MAAM,KAAK,EAAE,QAAQ,GAAO,GAAG,GAAG,MAAM,IAAQ,IAAI,EAAS"}
package/dist/math/max.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../function/compare.cjs"),u=require("./boil.cjs");function a(t,n){return u.boil(t,(e,r)=>{const o=n||(c=>c);return i.compare(o(e),o(r))>0?e:r})}exports.max=a;
2
- //# sourceMappingURL=max.cjs.map
1
+ const e=require(`../array/fold.cjs`),t=require(`../function/compare.cjs`);function n(n,r){let i=r??(e=>e);return e.fold(n,(e,n)=>t.compare(i(e),i(n))>0?e:n)}exports.max=n;
2
+ //# sourceMappingURL=max.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"max.cjs","sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../function/compare';\nimport { boil } from './boil';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n return boil(array, (a, b) => {\n const fn = callback || ((item: T) => item);\n return compare(fn(a), fn(b)) > 0 ? a : b;\n });\n}\n"],"names":["max","array","callback","boil","a","b","fn","item","compare"],"mappings":"mJAwBO,SAASA,EAAOC,EAAYC,EAA+D,CAChG,OAAOC,OAAKF,EAAO,CAACG,EAAGC,IAAM,CAC3B,MAAMC,EAAKJ,IAAcK,GAAYA,GACrC,OAAOC,EAAAA,QAAQF,EAAGF,CAAC,EAAGE,EAAGD,CAAC,CAAC,EAAI,EAAID,EAAIC,CACzC,CAAC,CACH"}
1
+ {"version":3,"file":"max.cjs","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { fold } from '../array/fold';\nimport { compare } from '../function/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n const fn = callback ?? ((item: T) => item);\n\n return fold(array, (a, b) => (compare(fn(a), fn(b)) > 0 ? a : b));\n}\n"],"mappings":"0EAwBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,IAAM,EAAK,IAAc,GAAY,GAErC,OAAO,EAAA,KAAK,GAAQ,EAAG,IAAO,EAAA,QAAQ,EAAG,EAAE,CAAE,EAAG,EAAE,CAAC,CAAG,EAAI,EAAI,EAAG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Finds the maximum item in an array.
3
+ *
4
+ * @description
5
+ * This function can be used to find the maximum number, string, or any other type of item in an array.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * max([1, 2, 3]); // 3
10
+ * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3
11
+ * max(['apple', 'banana', 'cherry']); // 'cherry'
12
+ * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01
13
+ * ```
14
+ *
15
+ * @param array - The array to be searched.
16
+ * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
17
+ *
18
+ * @return The item with the maximum value as determined by the callback function.
19
+ *
20
+ * @throws {TypeError} If the provided array is not an array.
21
+ */
22
+ export declare function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
23
+ //# sourceMappingURL=max.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../src/math/max.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAIhG"}
package/dist/math/max.js CHANGED
@@ -1,12 +1,11 @@
1
- import { compare as f } from "../function/compare.js";
2
- import { boil as i } from "./boil.js";
3
- function u(m, n) {
4
- return i(m, (r, o) => {
5
- const t = n || ((e) => e);
6
- return f(t(r), t(o)) > 0 ? r : o;
7
- });
1
+ import { fold as e } from "../array/fold.js";
2
+ import { compare as t } from "../function/compare.js";
3
+ //#region src/math/max.ts
4
+ function n(n, r) {
5
+ let i = r ?? ((e) => e);
6
+ return e(n, (e, n) => t(i(e), i(n)) > 0 ? e : n);
8
7
  }
9
- export {
10
- u as max
11
- };
12
- //# sourceMappingURL=max.js.map
8
+ //#endregion
9
+ export { n as max };
10
+
11
+ //# sourceMappingURL=max.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"max.js","sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../function/compare';\nimport { boil } from './boil';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n return boil(array, (a, b) => {\n const fn = callback || ((item: T) => item);\n return compare(fn(a), fn(b)) > 0 ? a : b;\n });\n}\n"],"names":["max","array","callback","boil","a","b","fn","item","compare"],"mappings":";;AAwBO,SAASA,EAAOC,GAAYC,GAA+D;AAChG,SAAOC,EAAKF,GAAO,CAACG,GAAGC,MAAM;AAC3B,UAAMC,IAAKJ,MAAa,CAACK,MAAYA;AACrC,WAAOC,EAAQF,EAAGF,CAAC,GAAGE,EAAGD,CAAC,CAAC,IAAI,IAAID,IAAIC;AAAA,EACzC,CAAC;AACH;"}
1
+ {"version":3,"file":"max.js","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { fold } from '../array/fold';\nimport { compare } from '../function/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n const fn = callback ?? ((item: T) => item);\n\n return fold(array, (a, b) => (compare(fn(a), fn(b)) > 0 ? a : b));\n}\n"],"mappings":";;;AAwBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAM,IAAK,OAAc,MAAY;AAErC,QAAO,EAAK,IAAQ,GAAG,MAAO,EAAQ,EAAG,EAAE,EAAE,EAAG,EAAE,CAAC,GAAG,IAAI,IAAI,EAAG"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(n,a){if(n.length===0)return;const i=a?n.map(a):n,l=i.every(e=>e instanceof Date),t=i.map(e=>e instanceof Date?e.getTime():e);t.sort((e,u)=>e-u);const o=Math.floor(t.length/2),s=t.length%2===0?(t[o-1]+t[o])/2:t[o];return l?new Date(s):s}exports.median=c;
2
- //# sourceMappingURL=median.cjs.map
1
+ function e(e,t){if(e.length===0)return;let n=t?e.map(t):[...e];n.sort((e,t)=>e-t);let r=Math.floor(n.length/2);return n.length%2==0?(n[r-1]+n[r])/2:n[r]}exports.median=e;
2
+ //# sourceMappingURL=median.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"median.cjs","sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return (allDates ? new Date(medianValue) : medianValue) as unknown as number | Date;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"gFAgBO,SAASA,EAAUC,EAAUC,EAAkE,CACpG,GAAID,EAAI,SAAW,EAAG,OAEtB,MAAME,EAASD,EAAWD,EAAI,IAAIC,CAAQ,EAAKD,EACzCG,EAAWD,EAAO,MAAOE,GAAMA,aAAa,IAAI,EAChDC,EAAgBH,EAAO,IAAKE,GAAOA,aAAa,KAAOA,EAAE,QAAA,EAAaA,CAAa,EAEzFC,EAAc,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EAElC,MAAMC,EAAM,KAAK,MAAMH,EAAc,OAAS,CAAC,EACzCI,EACJJ,EAAc,OAAS,IAAM,GAAKA,EAAcG,EAAM,CAAC,EAAIH,EAAcG,CAAG,GAAK,EAAIH,EAAcG,CAAG,EAExG,OAAQL,EAAW,IAAI,KAAKM,CAAW,EAAIA,CAC7C"}
1
+ {"version":3,"file":"median.cjs","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":"AAeA,SAAgB,EAAU,EAAU,EAAoD,CACtF,GAAI,EAAI,SAAW,EAAG,OAEtB,IAAM,EAAS,EAAW,EAAI,IAAI,EAAS,CAAG,CAAC,GAAI,EAA4B,CAE/E,EAAO,MAAM,EAAG,IAAM,EAAI,EAAE,CAE5B,IAAM,EAAM,KAAK,MAAM,EAAO,OAAS,EAAE,CAEzC,OAAO,EAAO,OAAS,GAAM,GAAK,EAAO,EAAM,GAAK,EAAO,IAAQ,EAAI,EAAO"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns the median of an array of numbers.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * median([1, 2, 3, 4, 100]); // 3
7
+ * median([1, 2, 3, 4, 5], (n) => n * 2); // 6
8
+ * median([]); // undefined
9
+ * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5
10
+ * ```
11
+ *
12
+ * @param arr - The array of numbers.
13
+ * @param callback - (optional) A callback function to map each item to a number.
14
+ * @returns The median, or `undefined` if the array is empty.
15
+ */
16
+ export declare function median<T>(arr: T[], callback?: (item: T) => number): number | undefined;
17
+ //# sourceMappingURL=median.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../src/math/median.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAUtF"}
@@ -1,11 +1,12 @@
1
- function m(n, a) {
2
- if (n.length === 0) return;
3
- const s = a ? n.map(a) : n, c = s.every((e) => e instanceof Date), t = s.map((e) => e instanceof Date ? e.getTime() : e);
4
- t.sort((e, l) => e - l);
5
- const o = Math.floor(t.length / 2), i = t.length % 2 === 0 ? (t[o - 1] + t[o]) / 2 : t[o];
6
- return c ? new Date(i) : i;
1
+ //#region src/math/median.ts
2
+ function e(e, t) {
3
+ if (e.length === 0) return;
4
+ let n = t ? e.map(t) : [...e];
5
+ n.sort((e, t) => e - t);
6
+ let r = Math.floor(n.length / 2);
7
+ return n.length % 2 == 0 ? (n[r - 1] + n[r]) / 2 : n[r];
7
8
  }
8
- export {
9
- m as median
10
- };
11
- //# sourceMappingURL=median.js.map
9
+ //#endregion
10
+ export { e as median };
11
+
12
+ //# sourceMappingURL=median.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"median.js","sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return (allDates ? new Date(medianValue) : medianValue) as unknown as number | Date;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"AAgBO,SAASA,EAAUC,GAAUC,GAAkE;AACpG,MAAID,EAAI,WAAW,EAAG;AAEtB,QAAME,IAASD,IAAWD,EAAI,IAAIC,CAAQ,IAAKD,GACzCG,IAAWD,EAAO,MAAM,CAACE,MAAMA,aAAa,IAAI,GAChDC,IAAgBH,EAAO,IAAI,CAACE,MAAOA,aAAa,OAAOA,EAAE,QAAA,IAAaA,CAAa;AAEzF,EAAAC,EAAc,KAAK,CAACC,GAAGC,MAAMD,IAAIC,CAAC;AAElC,QAAMC,IAAM,KAAK,MAAMH,EAAc,SAAS,CAAC,GACzCI,IACJJ,EAAc,SAAS,MAAM,KAAKA,EAAcG,IAAM,CAAC,IAAIH,EAAcG,CAAG,KAAK,IAAIH,EAAcG,CAAG;AAExG,SAAQL,IAAW,IAAI,KAAKM,CAAW,IAAIA;AAC7C;"}
1
+ {"version":3,"file":"median.js","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":";AAeA,SAAgB,EAAU,GAAU,GAAoD;AACtF,KAAI,EAAI,WAAW,EAAG;CAEtB,IAAM,IAAS,IAAW,EAAI,IAAI,EAAS,GAAG,CAAC,GAAI,EAA4B;AAE/E,GAAO,MAAM,GAAG,MAAM,IAAI,EAAE;CAE5B,IAAM,IAAM,KAAK,MAAM,EAAO,SAAS,EAAE;AAEzC,QAAO,EAAO,SAAS,KAAM,KAAK,EAAO,IAAM,KAAK,EAAO,MAAQ,IAAI,EAAO"}
package/dist/math/min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../function/compare.cjs"),u=require("./boil.cjs");function l(o,t){return u.boil(o,(e,r)=>{const n=t||(i=>i);return c.compare(n(e),n(r))<0?e:r})}exports.min=l;
2
- //# sourceMappingURL=min.cjs.map
1
+ const e=require(`../array/fold.cjs`),t=require(`../function/compare.cjs`);function n(n,r){let i=r??(e=>e);return e.fold(n,(e,n)=>t.compare(i(e),i(n))<0?e:n)}exports.min=n;
2
+ //# sourceMappingURL=min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"min.cjs","sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../function/compare';\nimport { boil } from './boil';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n return boil(array, (a, b) => {\n const fn = callback || ((item: T) => item);\n return compare(fn(a), fn(b)) < 0 ? a : b;\n });\n}\n"],"names":["min","array","callback","boil","a","b","fn","item","compare"],"mappings":"mJAwBO,SAASA,EAAOC,EAAYC,EAA+D,CAChG,OAAOC,OAAKF,EAAO,CAACG,EAAGC,IAAM,CAC3B,MAAMC,EAAKJ,IAAcK,GAAYA,GACrC,OAAOC,EAAAA,QAAQF,EAAGF,CAAC,EAAGE,EAAGD,CAAC,CAAC,EAAI,EAAID,EAAIC,CACzC,CAAC,CACH"}
1
+ {"version":3,"file":"min.cjs","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { fold } from '../array/fold';\nimport { compare } from '../function/compare';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n const fn = callback ?? ((item: T) => item);\n\n return fold(array, (a, b) => (compare(fn(a), fn(b)) < 0 ? a : b));\n}\n"],"mappings":"0EAwBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,IAAM,EAAK,IAAc,GAAY,GAErC,OAAO,EAAA,KAAK,GAAQ,EAAG,IAAO,EAAA,QAAQ,EAAG,EAAE,CAAE,EAAG,EAAE,CAAC,CAAG,EAAI,EAAI,EAAG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Finds the minimum item in an array.
3
+ *
4
+ * @description
5
+ * This function can be used to find the minimum number, string, or any other type of item in an array.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * min([1, 2, 3]); // 1
10
+ * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1
11
+ * min(['apple', 'banana', 'cherry']); // 'apple'
12
+ * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01
13
+ * ```
14
+ *
15
+ * @param array - The array to be searched.
16
+ * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
17
+ *
18
+ * @return The item with the minimum value as determined by the callback function.
19
+ *
20
+ * @throws {TypeError} If the provided array is not an array.
21
+ */
22
+ export declare function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
23
+ //# sourceMappingURL=min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../src/math/min.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAIhG"}
package/dist/math/min.js CHANGED
@@ -1,12 +1,11 @@
1
- import { compare as e } from "../function/compare.js";
2
- import { boil as f } from "./boil.js";
3
- function u(t, m) {
4
- return f(t, (r, o) => {
5
- const n = m || ((i) => i);
6
- return e(n(r), n(o)) < 0 ? r : o;
7
- });
1
+ import { fold as e } from "../array/fold.js";
2
+ import { compare as t } from "../function/compare.js";
3
+ //#region src/math/min.ts
4
+ function n(n, r) {
5
+ let i = r ?? ((e) => e);
6
+ return e(n, (e, n) => t(i(e), i(n)) < 0 ? e : n);
8
7
  }
9
- export {
10
- u as min
11
- };
12
- //# sourceMappingURL=min.js.map
8
+ //#endregion
9
+ export { n as min };
10
+
11
+ //# sourceMappingURL=min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"min.js","sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../function/compare';\nimport { boil } from './boil';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n return boil(array, (a, b) => {\n const fn = callback || ((item: T) => item);\n return compare(fn(a), fn(b)) < 0 ? a : b;\n });\n}\n"],"names":["min","array","callback","boil","a","b","fn","item","compare"],"mappings":";;AAwBO,SAASA,EAAOC,GAAYC,GAA+D;AAChG,SAAOC,EAAKF,GAAO,CAACG,GAAGC,MAAM;AAC3B,UAAMC,IAAKJ,MAAa,CAACK,MAAYA;AACrC,WAAOC,EAAQF,EAAGF,CAAC,GAAGE,EAAGD,CAAC,CAAC,IAAI,IAAID,IAAIC;AAAA,EACzC,CAAC;AACH;"}
1
+ {"version":3,"file":"min.js","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { fold } from '../array/fold';\nimport { compare } from '../function/compare';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n const fn = callback ?? ((item: T) => item);\n\n return fold(array, (a, b) => (compare(fn(a), fn(b)) < 0 ? a : b));\n}\n"],"mappings":";;;AAwBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAM,IAAK,OAAc,MAAY;AAErC,QAAO,EAAK,IAAQ,GAAG,MAAO,EAAQ,EAAG,EAAE,EAAE,EAAG,EAAE,CAAC,GAAG,IAAI,IAAI,EAAG"}
@@ -0,0 +1,2 @@
1
+ function e(e,t){return t===0?0:e/t*100}exports.percent=e;
2
+ //# sourceMappingURL=percent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percent.cjs","names":[],"sources":["../../src/math/percent.ts"],"sourcesContent":["/**\n * Calculates what percentage `value` is of `total`.\n *\n * @example\n * ```ts\n * percent(25, 100); // 25\n * percent(1, 3); // 33.333...\n * percent(50, 200); // 25\n * percent(0, 100); // 0\n * percent(5, 0); // 0\n * ```\n *\n * @param value - The partial value.\n * @param total - The total value.\n *\n * @returns The percentage (0–100 scale). Returns 0 when `total` is 0.\n */\nexport function percent(value: number, total: number): number {\n if (total === 0) return 0;\n\n return (value / total) * 100;\n}\n"],"mappings":"AAiBA,SAAgB,EAAQ,EAAe,EAAuB,CAG5D,OAFI,IAAU,EAAU,EAEhB,EAAQ,EAAS"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Calculates what percentage `value` is of `total`.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * percent(25, 100); // 25
7
+ * percent(1, 3); // 33.333...
8
+ * percent(50, 200); // 25
9
+ * percent(0, 100); // 0
10
+ * percent(5, 0); // 0
11
+ * ```
12
+ *
13
+ * @param value - The partial value.
14
+ * @param total - The total value.
15
+ *
16
+ * @returns The percentage (0–100 scale). Returns 0 when `total` is 0.
17
+ */
18
+ export declare function percent(value: number, total: number): number;
19
+ //# sourceMappingURL=percent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../src/math/percent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5D"}
@@ -0,0 +1,8 @@
1
+ //#region src/math/percent.ts
2
+ function e(e, t) {
3
+ return t === 0 ? 0 : e / t * 100;
4
+ }
5
+ //#endregion
6
+ export { e as percent };
7
+
8
+ //# sourceMappingURL=percent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percent.js","names":[],"sources":["../../src/math/percent.ts"],"sourcesContent":["/**\n * Calculates what percentage `value` is of `total`.\n *\n * @example\n * ```ts\n * percent(25, 100); // 25\n * percent(1, 3); // 33.333...\n * percent(50, 200); // 25\n * percent(0, 100); // 0\n * percent(5, 0); // 0\n * ```\n *\n * @param value - The partial value.\n * @param total - The total value.\n *\n * @returns The percentage (0–100 scale). Returns 0 when `total` is 0.\n */\nexport function percent(value: number, total: number): number {\n if (total === 0) return 0;\n\n return (value / total) * 100;\n}\n"],"mappings":";AAiBA,SAAgB,EAAQ,GAAe,GAAuB;AAG5D,QAFI,MAAU,IAAU,IAEhB,IAAQ,IAAS"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../function/assert.cjs");function m(r,i,e){if(a.assert(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(e),"start, stop, and step must be finite numbers",{args:{start:r,step:e,stop:i},type:TypeError}),a.assert(e!==0,"Step cannot be 0",{args:{step:e},type:Error}),r===i)return[];const n=Math.max(0,Math.ceil((i-r)/e+Number.EPSILON));return a.assert(n<=1e7,"Range exceeds maximum allowed size of 10,000,000",{args:{length:n,start:r,step:e,stop:i},type:Error}),Array.from({length:n},(t,u)=>r+u*e)}exports.range=m;
2
- //# sourceMappingURL=range.cjs.map
1
+ const e=require(`../function/assert.cjs`);function t(t,n,r){if(e.assert(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r),`start, stop, and step must be finite numbers`,{args:{start:t,step:r,stop:n},type:TypeError}),e.assert(r!==0,`Step cannot be 0`,{args:{step:r},type:Error}),t===n)return[];let i=Math.max(0,Math.ceil((n-t)/r+2**-52));return e.assert(i<=1e7,`Range exceeds maximum allowed size of 10,000,000`,{args:{length:i,start:t,step:r,stop:n},type:Error}),Array.from({length:i},(e,n)=>t+n*r)}exports.range=t;
2
+ //# sourceMappingURL=range.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"range.cjs","sources":["../../src/math/range.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {TypeError} If start, stop, or step are not finite numbers.\n * @throws {Error} If step is 0 or if range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number) {\n assert(\n Number.isFinite(start) && Number.isFinite(stop) && Number.isFinite(step),\n 'start, stop, and step must be finite numbers',\n { args: { start, step, stop }, type: TypeError },\n );\n assert(step !== 0, 'Step cannot be 0', { args: { step }, type: Error });\n\n if (start === stop) {\n return [];\n }\n\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n\n assert(length <= 10_000_000, 'Range exceeds maximum allowed size of 10,000,000', {\n args: { length, start, step, stop },\n type: Error,\n });\n\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"names":["range","start","stop","step","assert","length","_","i"],"mappings":"0HAuBO,SAASA,EAAMC,EAAeC,EAAcC,EAAc,CAQ/D,GAPAC,EAAAA,OACE,OAAO,SAASH,CAAK,GAAK,OAAO,SAASC,CAAI,GAAK,OAAO,SAASC,CAAI,EACvE,+CACA,CAAE,KAAM,CAAE,MAAAF,EAAO,KAAAE,EAAM,KAAAD,CAAA,EAAQ,KAAM,SAAA,CAAU,EAEjDE,SAAOD,IAAS,EAAG,mBAAoB,CAAE,KAAM,CAAE,KAAAA,CAAA,EAAQ,KAAM,MAAO,EAElEF,IAAUC,EACZ,MAAO,CAAA,EAGT,MAAMG,EAAS,KAAK,IAAI,EAAG,KAAK,MAAMH,EAAOD,GAASE,EAAO,OAAO,OAAO,CAAC,EAE5EC,OAAAA,SAAOC,GAAU,IAAY,mDAAoD,CAC/E,KAAM,CAAE,OAAAA,EAAQ,MAAAJ,EAAO,KAAAE,EAAM,KAAAD,CAAA,EAC7B,KAAM,KAAA,CACP,EAEM,MAAM,KAAK,CAAE,OAAAG,CAAA,EAAU,CAACC,EAAGC,IAAMN,EAAQM,EAAIJ,CAAI,CAC1D"}
1
+ {"version":3,"file":"range.cjs","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {TypeError} If start, stop, or step are not finite numbers.\n * @throws {Error} If step is 0 or if range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number) {\n assert(\n Number.isFinite(start) && Number.isFinite(stop) && Number.isFinite(step),\n 'start, stop, and step must be finite numbers',\n { args: { start, step, stop }, type: TypeError },\n );\n assert(step !== 0, 'Step cannot be 0', { args: { step }, type: Error });\n\n if (start === stop) {\n return [];\n }\n\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n\n assert(length <= 10_000_000, 'Range exceeds maximum allowed size of 10,000,000', {\n args: { length, start, step, stop },\n type: Error,\n });\n\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"mappings":"0CAuBA,SAAgB,EAAM,EAAe,EAAc,EAAc,CAQ/D,GAPA,EAAA,OACE,OAAO,SAAS,EAAM,EAAI,OAAO,SAAS,EAAK,EAAI,OAAO,SAAS,EAAK,CACxE,+CACA,CAAE,KAAM,CAAE,QAAO,OAAM,OAAM,CAAE,KAAM,UAAW,CACjD,CACD,EAAA,OAAO,IAAS,EAAG,mBAAoB,CAAE,KAAM,CAAE,OAAM,CAAE,KAAM,MAAO,CAAC,CAEnE,IAAU,EACZ,MAAO,EAAE,CAGX,IAAM,EAAS,KAAK,IAAI,EAAG,KAAK,MAAM,EAAO,GAAS,SAAsB,CAAC,CAO7E,OALA,EAAA,OAAO,GAAU,IAAY,mDAAoD,CAC/E,KAAM,CAAE,SAAQ,QAAO,OAAM,OAAM,CACnC,KAAM,MACP,CAAC,CAEK,MAAM,KAAK,CAAE,SAAQ,EAAG,EAAG,IAAM,EAAQ,EAAI,EAAK"}