@vielzeug/arsenal 1.0.1

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 (772) hide show
  1. package/README.md +104 -0
  2. package/dist/_common/_abortable.d.ts +5 -0
  3. package/dist/_common/_abortable.d.ts.map +1 -0
  4. package/dist/_common/_lruMap.cjs +2 -0
  5. package/dist/_common/_lruMap.cjs.map +1 -0
  6. package/dist/_common/_lruMap.d.ts +20 -0
  7. package/dist/_common/_lruMap.d.ts.map +1 -0
  8. package/dist/_common/_lruMap.js +18 -0
  9. package/dist/_common/_lruMap.js.map +1 -0
  10. package/dist/_common/_secureRandomIndex.cjs +2 -0
  11. package/dist/_common/_secureRandomIndex.cjs.map +1 -0
  12. package/dist/_common/_secureRandomIndex.d.ts +2 -0
  13. package/dist/_common/_secureRandomIndex.d.ts.map +1 -0
  14. package/dist/_common/_secureRandomIndex.js +9 -0
  15. package/dist/_common/_secureRandomIndex.js.map +1 -0
  16. package/dist/_common/_selectorSet.cjs +2 -0
  17. package/dist/_common/_selectorSet.cjs.map +1 -0
  18. package/dist/_common/_selectorSet.d.ts +2 -0
  19. package/dist/_common/_selectorSet.d.ts.map +1 -0
  20. package/dist/_common/_selectorSet.js +16 -0
  21. package/dist/_common/_selectorSet.js.map +1 -0
  22. package/dist/_common/unsafePaths.cjs +2 -0
  23. package/dist/_common/unsafePaths.cjs.map +1 -0
  24. package/dist/_common/unsafePaths.d.ts +25 -0
  25. package/dist/_common/unsafePaths.d.ts.map +1 -0
  26. package/dist/_common/unsafePaths.js +13 -0
  27. package/dist/_common/unsafePaths.js.map +1 -0
  28. package/dist/_dev.cjs +2 -0
  29. package/dist/_dev.cjs.map +1 -0
  30. package/dist/_dev.d.ts +2 -0
  31. package/dist/_dev.d.ts.map +1 -0
  32. package/dist/_dev.js +9 -0
  33. package/dist/_dev.js.map +1 -0
  34. package/dist/array/chunk.cjs +2 -0
  35. package/dist/array/chunk.cjs.map +1 -0
  36. package/dist/array/chunk.d.ts +19 -0
  37. package/dist/array/chunk.d.ts.map +1 -0
  38. package/dist/array/chunk.js +12 -0
  39. package/dist/array/chunk.js.map +1 -0
  40. package/dist/array/compact.cjs +2 -0
  41. package/dist/array/compact.cjs.map +1 -0
  42. package/dist/array/compact.d.ts +7 -0
  43. package/dist/array/compact.d.ts.map +1 -0
  44. package/dist/array/compact.js +8 -0
  45. package/dist/array/compact.js.map +1 -0
  46. package/dist/array/compare.cjs +2 -0
  47. package/dist/array/compare.cjs.map +1 -0
  48. package/dist/array/compare.d.ts +31 -0
  49. package/dist/array/compare.d.ts.map +1 -0
  50. package/dist/array/compare.js +20 -0
  51. package/dist/array/compare.js.map +1 -0
  52. package/dist/array/compareBy.cjs +2 -0
  53. package/dist/array/compareBy.cjs.map +1 -0
  54. package/dist/array/compareBy.d.ts +24 -0
  55. package/dist/array/compareBy.d.ts.map +1 -0
  56. package/dist/array/compareBy.js +16 -0
  57. package/dist/array/compareBy.js.map +1 -0
  58. package/dist/array/contains.cjs +2 -0
  59. package/dist/array/contains.cjs.map +1 -0
  60. package/dist/array/contains.d.ts +17 -0
  61. package/dist/array/contains.d.ts.map +1 -0
  62. package/dist/array/contains.js +9 -0
  63. package/dist/array/contains.js.map +1 -0
  64. package/dist/array/countBy.cjs +2 -0
  65. package/dist/array/countBy.cjs.map +1 -0
  66. package/dist/array/countBy.d.ts +8 -0
  67. package/dist/array/countBy.d.ts.map +1 -0
  68. package/dist/array/countBy.js +14 -0
  69. package/dist/array/countBy.js.map +1 -0
  70. package/dist/array/difference.cjs +2 -0
  71. package/dist/array/difference.cjs.map +1 -0
  72. package/dist/array/difference.d.ts +6 -0
  73. package/dist/array/difference.d.ts.map +1 -0
  74. package/dist/array/difference.js +14 -0
  75. package/dist/array/difference.js.map +1 -0
  76. package/dist/array/drop.cjs +2 -0
  77. package/dist/array/drop.cjs.map +1 -0
  78. package/dist/array/drop.d.ts +5 -0
  79. package/dist/array/drop.d.ts.map +1 -0
  80. package/dist/array/drop.js +9 -0
  81. package/dist/array/drop.js.map +1 -0
  82. package/dist/array/dropLast.cjs +2 -0
  83. package/dist/array/dropLast.cjs.map +1 -0
  84. package/dist/array/dropLast.d.ts +5 -0
  85. package/dist/array/dropLast.d.ts.map +1 -0
  86. package/dist/array/dropLast.js +9 -0
  87. package/dist/array/dropLast.js.map +1 -0
  88. package/dist/array/filterMap.cjs +2 -0
  89. package/dist/array/filterMap.cjs.map +1 -0
  90. package/dist/array/filterMap.d.ts +5 -0
  91. package/dist/array/filterMap.d.ts.map +1 -0
  92. package/dist/array/filterMap.js +13 -0
  93. package/dist/array/filterMap.js.map +1 -0
  94. package/dist/array/first.cjs +2 -0
  95. package/dist/array/first.cjs.map +1 -0
  96. package/dist/array/first.d.ts +5 -0
  97. package/dist/array/first.d.ts.map +1 -0
  98. package/dist/array/first.js +8 -0
  99. package/dist/array/first.js.map +1 -0
  100. package/dist/array/flatten.cjs +2 -0
  101. package/dist/array/flatten.cjs.map +1 -0
  102. package/dist/array/flatten.d.ts +5 -0
  103. package/dist/array/flatten.d.ts.map +1 -0
  104. package/dist/array/flatten.js +11 -0
  105. package/dist/array/flatten.js.map +1 -0
  106. package/dist/array/groupBy.cjs +2 -0
  107. package/dist/array/groupBy.cjs.map +1 -0
  108. package/dist/array/groupBy.d.ts +7 -0
  109. package/dist/array/groupBy.d.ts.map +1 -0
  110. package/dist/array/groupBy.js +14 -0
  111. package/dist/array/groupBy.js.map +1 -0
  112. package/dist/array/index.d.ts +29 -0
  113. package/dist/array/index.d.ts.map +1 -0
  114. package/dist/array/indexBy.cjs +2 -0
  115. package/dist/array/indexBy.cjs.map +1 -0
  116. package/dist/array/indexBy.d.ts +7 -0
  117. package/dist/array/indexBy.d.ts.map +1 -0
  118. package/dist/array/indexBy.js +14 -0
  119. package/dist/array/indexBy.js.map +1 -0
  120. package/dist/array/intersection.cjs +2 -0
  121. package/dist/array/intersection.cjs.map +1 -0
  122. package/dist/array/intersection.d.ts +6 -0
  123. package/dist/array/intersection.d.ts.map +1 -0
  124. package/dist/array/intersection.js +14 -0
  125. package/dist/array/intersection.js.map +1 -0
  126. package/dist/array/last.cjs +2 -0
  127. package/dist/array/last.cjs.map +1 -0
  128. package/dist/array/last.d.ts +5 -0
  129. package/dist/array/last.d.ts.map +1 -0
  130. package/dist/array/last.js +8 -0
  131. package/dist/array/last.js.map +1 -0
  132. package/dist/array/partition.cjs +2 -0
  133. package/dist/array/partition.cjs.map +1 -0
  134. package/dist/array/partition.d.ts +5 -0
  135. package/dist/array/partition.d.ts.map +1 -0
  136. package/dist/array/partition.js +10 -0
  137. package/dist/array/partition.js.map +1 -0
  138. package/dist/array/replace.cjs +2 -0
  139. package/dist/array/replace.cjs.map +1 -0
  140. package/dist/array/replace.d.ts +18 -0
  141. package/dist/array/replace.d.ts.map +1 -0
  142. package/dist/array/replace.js +13 -0
  143. package/dist/array/replace.js.map +1 -0
  144. package/dist/array/rotate.cjs +2 -0
  145. package/dist/array/rotate.cjs.map +1 -0
  146. package/dist/array/rotate.d.ts +20 -0
  147. package/dist/array/rotate.d.ts.map +1 -0
  148. package/dist/array/rotate.js +10 -0
  149. package/dist/array/rotate.js.map +1 -0
  150. package/dist/array/search.cjs +2 -0
  151. package/dist/array/search.cjs.map +1 -0
  152. package/dist/array/search.d.ts +85 -0
  153. package/dist/array/search.d.ts.map +1 -0
  154. package/dist/array/search.js +47 -0
  155. package/dist/array/search.js.map +1 -0
  156. package/dist/array/sort.cjs +2 -0
  157. package/dist/array/sort.cjs.map +1 -0
  158. package/dist/array/sort.d.ts +26 -0
  159. package/dist/array/sort.d.ts.map +1 -0
  160. package/dist/array/sort.js +16 -0
  161. package/dist/array/sort.js.map +1 -0
  162. package/dist/array/take.cjs +2 -0
  163. package/dist/array/take.cjs.map +1 -0
  164. package/dist/array/take.d.ts +5 -0
  165. package/dist/array/take.d.ts.map +1 -0
  166. package/dist/array/take.js +9 -0
  167. package/dist/array/take.js.map +1 -0
  168. package/dist/array/takeLast.cjs +2 -0
  169. package/dist/array/takeLast.cjs.map +1 -0
  170. package/dist/array/takeLast.d.ts +5 -0
  171. package/dist/array/takeLast.d.ts.map +1 -0
  172. package/dist/array/takeLast.js +9 -0
  173. package/dist/array/takeLast.js.map +1 -0
  174. package/dist/array/toggle.cjs +2 -0
  175. package/dist/array/toggle.cjs.map +1 -0
  176. package/dist/array/toggle.d.ts +29 -0
  177. package/dist/array/toggle.d.ts.map +1 -0
  178. package/dist/array/toggle.js +9 -0
  179. package/dist/array/toggle.js.map +1 -0
  180. package/dist/array/union.cjs +2 -0
  181. package/dist/array/union.cjs.map +1 -0
  182. package/dist/array/union.d.ts +6 -0
  183. package/dist/array/union.d.ts.map +1 -0
  184. package/dist/array/union.js +9 -0
  185. package/dist/array/union.js.map +1 -0
  186. package/dist/array/uniq.cjs +2 -0
  187. package/dist/array/uniq.cjs.map +1 -0
  188. package/dist/array/uniq.d.ts +18 -0
  189. package/dist/array/uniq.d.ts.map +1 -0
  190. package/dist/array/uniq.js +9 -0
  191. package/dist/array/uniq.js.map +1 -0
  192. package/dist/array/unzip.cjs +2 -0
  193. package/dist/array/unzip.cjs.map +1 -0
  194. package/dist/array/unzip.d.ts +7 -0
  195. package/dist/array/unzip.d.ts.map +1 -0
  196. package/dist/array/unzip.js +11 -0
  197. package/dist/array/unzip.js.map +1 -0
  198. package/dist/array/zip.cjs +2 -0
  199. package/dist/array/zip.cjs.map +1 -0
  200. package/dist/array/zip.d.ts +7 -0
  201. package/dist/array/zip.d.ts.map +1 -0
  202. package/dist/array/zip.js +11 -0
  203. package/dist/array/zip.js.map +1 -0
  204. package/dist/arsenal.cjs +2 -0
  205. package/dist/arsenal.cjs.map +1 -0
  206. package/dist/arsenal.iife.js +2 -0
  207. package/dist/arsenal.iife.js.map +1 -0
  208. package/dist/arsenal.js +2 -0
  209. package/dist/arsenal.js.map +1 -0
  210. package/dist/async/abortError.cjs +2 -0
  211. package/dist/async/abortError.cjs.map +1 -0
  212. package/dist/async/abortError.d.ts +23 -0
  213. package/dist/async/abortError.d.ts.map +1 -0
  214. package/dist/async/abortError.js +8 -0
  215. package/dist/async/abortError.js.map +1 -0
  216. package/dist/async/attempt.cjs +2 -0
  217. package/dist/async/attempt.cjs.map +1 -0
  218. package/dist/async/attempt.d.ts +58 -0
  219. package/dist/async/attempt.d.ts.map +1 -0
  220. package/dist/async/attempt.js +31 -0
  221. package/dist/async/attempt.js.map +1 -0
  222. package/dist/async/backoff.cjs +2 -0
  223. package/dist/async/backoff.cjs.map +1 -0
  224. package/dist/async/backoff.d.ts +20 -0
  225. package/dist/async/backoff.d.ts.map +1 -0
  226. package/dist/async/backoff.js +9 -0
  227. package/dist/async/backoff.js.map +1 -0
  228. package/dist/async/index.d.ts +9 -0
  229. package/dist/async/index.d.ts.map +1 -0
  230. package/dist/async/parallel.cjs +2 -0
  231. package/dist/async/parallel.cjs.map +1 -0
  232. package/dist/async/parallel.d.ts +42 -0
  233. package/dist/async/parallel.d.ts.map +1 -0
  234. package/dist/async/parallel.js +26 -0
  235. package/dist/async/parallel.js.map +1 -0
  236. package/dist/async/queue.cjs +2 -0
  237. package/dist/async/queue.cjs.map +1 -0
  238. package/dist/async/queue.d.ts +42 -0
  239. package/dist/async/queue.d.ts.map +1 -0
  240. package/dist/async/queue.js +72 -0
  241. package/dist/async/queue.js.map +1 -0
  242. package/dist/async/retry.cjs +2 -0
  243. package/dist/async/retry.cjs.map +1 -0
  244. package/dist/async/retry.d.ts +46 -0
  245. package/dist/async/retry.d.ts.map +1 -0
  246. package/dist/async/retry.js +26 -0
  247. package/dist/async/retry.js.map +1 -0
  248. package/dist/async/sleep.cjs +2 -0
  249. package/dist/async/sleep.cjs.map +1 -0
  250. package/dist/async/sleep.d.ts +21 -0
  251. package/dist/async/sleep.d.ts.map +1 -0
  252. package/dist/async/sleep.js +16 -0
  253. package/dist/async/sleep.js.map +1 -0
  254. package/dist/async/waitFor.cjs +2 -0
  255. package/dist/async/waitFor.cjs.map +1 -0
  256. package/dist/async/waitFor.d.ts +34 -0
  257. package/dist/async/waitFor.d.ts.map +1 -0
  258. package/dist/async/waitFor.js +13 -0
  259. package/dist/async/waitFor.js.map +1 -0
  260. package/dist/cache/index.d.ts +3 -0
  261. package/dist/cache/index.d.ts.map +1 -0
  262. package/dist/cache/memo.cjs +2 -0
  263. package/dist/cache/memo.cjs.map +1 -0
  264. package/dist/cache/memo.d.ts +40 -0
  265. package/dist/cache/memo.d.ts.map +1 -0
  266. package/dist/cache/memo.js +37 -0
  267. package/dist/cache/memo.js.map +1 -0
  268. package/dist/cache/stash.cjs +2 -0
  269. package/dist/cache/stash.cjs.map +1 -0
  270. package/dist/cache/stash.d.ts +111 -0
  271. package/dist/cache/stash.d.ts.map +1 -0
  272. package/dist/cache/stash.js +92 -0
  273. package/dist/cache/stash.js.map +1 -0
  274. package/dist/errors.cjs +2 -0
  275. package/dist/errors.cjs.map +1 -0
  276. package/dist/errors.d.ts +20 -0
  277. package/dist/errors.d.ts.map +1 -0
  278. package/dist/errors.js +13 -0
  279. package/dist/errors.js.map +1 -0
  280. package/dist/function/assert.cjs +2 -0
  281. package/dist/function/assert.cjs.map +1 -0
  282. package/dist/function/assert.d.ts +19 -0
  283. package/dist/function/assert.d.ts.map +1 -0
  284. package/dist/function/assert.js +8 -0
  285. package/dist/function/assert.js.map +1 -0
  286. package/dist/function/constant.cjs +2 -0
  287. package/dist/function/constant.cjs.map +1 -0
  288. package/dist/function/constant.d.ts +5 -0
  289. package/dist/function/constant.d.ts.map +1 -0
  290. package/dist/function/constant.js +8 -0
  291. package/dist/function/constant.js.map +1 -0
  292. package/dist/function/debounce.cjs +2 -0
  293. package/dist/function/debounce.cjs.map +1 -0
  294. package/dist/function/debounce.d.ts +31 -0
  295. package/dist/function/debounce.d.ts.map +1 -0
  296. package/dist/function/debounce.js +29 -0
  297. package/dist/function/debounce.js.map +1 -0
  298. package/dist/function/identity.cjs +2 -0
  299. package/dist/function/identity.cjs.map +1 -0
  300. package/dist/function/identity.d.ts +5 -0
  301. package/dist/function/identity.d.ts.map +1 -0
  302. package/dist/function/identity.js +8 -0
  303. package/dist/function/identity.js.map +1 -0
  304. package/dist/function/index.d.ts +10 -0
  305. package/dist/function/index.d.ts.map +1 -0
  306. package/dist/function/once.cjs +2 -0
  307. package/dist/function/once.cjs.map +1 -0
  308. package/dist/function/once.d.ts +32 -0
  309. package/dist/function/once.d.ts.map +1 -0
  310. package/dist/function/once.js +11 -0
  311. package/dist/function/once.js.map +1 -0
  312. package/dist/function/pipe.cjs +2 -0
  313. package/dist/function/pipe.cjs.map +1 -0
  314. package/dist/function/pipe.d.ts +32 -0
  315. package/dist/function/pipe.d.ts.map +1 -0
  316. package/dist/function/pipe.js +10 -0
  317. package/dist/function/pipe.js.map +1 -0
  318. package/dist/function/runAll.cjs +2 -0
  319. package/dist/function/runAll.cjs.map +1 -0
  320. package/dist/function/runAll.d.ts +15 -0
  321. package/dist/function/runAll.d.ts.map +1 -0
  322. package/dist/function/runAll.js +19 -0
  323. package/dist/function/runAll.js.map +1 -0
  324. package/dist/function/tap.cjs +2 -0
  325. package/dist/function/tap.cjs.map +1 -0
  326. package/dist/function/tap.d.ts +5 -0
  327. package/dist/function/tap.d.ts.map +1 -0
  328. package/dist/function/tap.js +8 -0
  329. package/dist/function/tap.js.map +1 -0
  330. package/dist/function/throttle.cjs +2 -0
  331. package/dist/function/throttle.cjs.map +1 -0
  332. package/dist/function/throttle.d.ts +23 -0
  333. package/dist/function/throttle.d.ts.map +1 -0
  334. package/dist/function/throttle.js +36 -0
  335. package/dist/function/throttle.js.map +1 -0
  336. package/dist/guards/combinators.cjs +2 -0
  337. package/dist/guards/combinators.cjs.map +1 -0
  338. package/dist/guards/combinators.d.ts +49 -0
  339. package/dist/guards/combinators.d.ts.map +1 -0
  340. package/dist/guards/combinators.js +17 -0
  341. package/dist/guards/combinators.js.map +1 -0
  342. package/dist/guards/index.d.ts +20 -0
  343. package/dist/guards/index.d.ts.map +1 -0
  344. package/dist/guards/isAbortError.cjs +2 -0
  345. package/dist/guards/isAbortError.cjs.map +1 -0
  346. package/dist/guards/isAbortError.d.ts +19 -0
  347. package/dist/guards/isAbortError.d.ts.map +1 -0
  348. package/dist/guards/isAbortError.js +8 -0
  349. package/dist/guards/isAbortError.js.map +1 -0
  350. package/dist/guards/isArray.cjs +2 -0
  351. package/dist/guards/isArray.cjs.map +1 -0
  352. package/dist/guards/isArray.d.ts +16 -0
  353. package/dist/guards/isArray.d.ts.map +1 -0
  354. package/dist/guards/isArray.js +8 -0
  355. package/dist/guards/isArray.js.map +1 -0
  356. package/dist/guards/isBoolean.cjs +2 -0
  357. package/dist/guards/isBoolean.cjs.map +1 -0
  358. package/dist/guards/isBoolean.d.ts +23 -0
  359. package/dist/guards/isBoolean.d.ts.map +1 -0
  360. package/dist/guards/isBoolean.js +8 -0
  361. package/dist/guards/isBoolean.js.map +1 -0
  362. package/dist/guards/isDate.cjs +2 -0
  363. package/dist/guards/isDate.cjs.map +1 -0
  364. package/dist/guards/isDate.d.ts +15 -0
  365. package/dist/guards/isDate.d.ts.map +1 -0
  366. package/dist/guards/isDate.js +8 -0
  367. package/dist/guards/isDate.js.map +1 -0
  368. package/dist/guards/isDefined.cjs +2 -0
  369. package/dist/guards/isDefined.cjs.map +1 -0
  370. package/dist/guards/isDefined.d.ts +19 -0
  371. package/dist/guards/isDefined.d.ts.map +1 -0
  372. package/dist/guards/isDefined.js +8 -0
  373. package/dist/guards/isDefined.js.map +1 -0
  374. package/dist/guards/isEmpty.cjs +2 -0
  375. package/dist/guards/isEmpty.cjs.map +1 -0
  376. package/dist/guards/isEmpty.d.ts +23 -0
  377. package/dist/guards/isEmpty.d.ts.map +1 -0
  378. package/dist/guards/isEmpty.js +10 -0
  379. package/dist/guards/isEmpty.js.map +1 -0
  380. package/dist/guards/isEqual.cjs +2 -0
  381. package/dist/guards/isEqual.cjs.map +1 -0
  382. package/dist/guards/isEqual.d.ts +24 -0
  383. package/dist/guards/isEqual.d.ts.map +1 -0
  384. package/dist/guards/isEqual.js +34 -0
  385. package/dist/guards/isEqual.js.map +1 -0
  386. package/dist/guards/isError.cjs +2 -0
  387. package/dist/guards/isError.cjs.map +1 -0
  388. package/dist/guards/isError.d.ts +15 -0
  389. package/dist/guards/isError.d.ts.map +1 -0
  390. package/dist/guards/isError.js +8 -0
  391. package/dist/guards/isError.js.map +1 -0
  392. package/dist/guards/isFunction.cjs +2 -0
  393. package/dist/guards/isFunction.cjs.map +1 -0
  394. package/dist/guards/isFunction.d.ts +16 -0
  395. package/dist/guards/isFunction.d.ts.map +1 -0
  396. package/dist/guards/isFunction.js +8 -0
  397. package/dist/guards/isFunction.js.map +1 -0
  398. package/dist/guards/isMatch.cjs +2 -0
  399. package/dist/guards/isMatch.cjs.map +1 -0
  400. package/dist/guards/isMatch.d.ts +23 -0
  401. package/dist/guards/isMatch.d.ts.map +1 -0
  402. package/dist/guards/isMatch.js +23 -0
  403. package/dist/guards/isMatch.js.map +1 -0
  404. package/dist/guards/isNil.cjs +2 -0
  405. package/dist/guards/isNil.cjs.map +1 -0
  406. package/dist/guards/isNil.d.ts +17 -0
  407. package/dist/guards/isNil.d.ts.map +1 -0
  408. package/dist/guards/isNil.js +8 -0
  409. package/dist/guards/isNil.js.map +1 -0
  410. package/dist/guards/isNumber.cjs +2 -0
  411. package/dist/guards/isNumber.cjs.map +1 -0
  412. package/dist/guards/isNumber.d.ts +15 -0
  413. package/dist/guards/isNumber.d.ts.map +1 -0
  414. package/dist/guards/isNumber.js +8 -0
  415. package/dist/guards/isNumber.js.map +1 -0
  416. package/dist/guards/isPlainObject.cjs +2 -0
  417. package/dist/guards/isPlainObject.cjs.map +1 -0
  418. package/dist/guards/isPlainObject.d.ts +16 -0
  419. package/dist/guards/isPlainObject.d.ts.map +1 -0
  420. package/dist/guards/isPlainObject.js +10 -0
  421. package/dist/guards/isPlainObject.js.map +1 -0
  422. package/dist/guards/isPrimitive.cjs +2 -0
  423. package/dist/guards/isPrimitive.cjs.map +1 -0
  424. package/dist/guards/isPrimitive.d.ts +18 -0
  425. package/dist/guards/isPrimitive.d.ts.map +1 -0
  426. package/dist/guards/isPrimitive.js +9 -0
  427. package/dist/guards/isPrimitive.js.map +1 -0
  428. package/dist/guards/isPromise.cjs +2 -0
  429. package/dist/guards/isPromise.cjs.map +1 -0
  430. package/dist/guards/isPromise.d.ts +17 -0
  431. package/dist/guards/isPromise.d.ts.map +1 -0
  432. package/dist/guards/isPromise.js +8 -0
  433. package/dist/guards/isPromise.js.map +1 -0
  434. package/dist/guards/isRegex.cjs +2 -0
  435. package/dist/guards/isRegex.cjs.map +1 -0
  436. package/dist/guards/isRegex.d.ts +21 -0
  437. package/dist/guards/isRegex.d.ts.map +1 -0
  438. package/dist/guards/isRegex.js +8 -0
  439. package/dist/guards/isRegex.js.map +1 -0
  440. package/dist/guards/isString.cjs +2 -0
  441. package/dist/guards/isString.cjs.map +1 -0
  442. package/dist/guards/isString.d.ts +15 -0
  443. package/dist/guards/isString.d.ts.map +1 -0
  444. package/dist/guards/isString.js +8 -0
  445. package/dist/guards/isString.js.map +1 -0
  446. package/dist/guards/shallowEqual.cjs +2 -0
  447. package/dist/guards/shallowEqual.cjs.map +1 -0
  448. package/dist/guards/shallowEqual.d.ts +29 -0
  449. package/dist/guards/shallowEqual.d.ts.map +1 -0
  450. package/dist/guards/shallowEqual.js +20 -0
  451. package/dist/guards/shallowEqual.js.map +1 -0
  452. package/dist/index.cjs +1 -0
  453. package/dist/index.d.ts +119 -0
  454. package/dist/index.d.ts.map +1 -0
  455. package/dist/index.js +118 -0
  456. package/dist/math/abs.cjs +2 -0
  457. package/dist/math/abs.cjs.map +1 -0
  458. package/dist/math/abs.d.ts +17 -0
  459. package/dist/math/abs.d.ts.map +1 -0
  460. package/dist/math/abs.js +8 -0
  461. package/dist/math/abs.js.map +1 -0
  462. package/dist/math/allocate.cjs +2 -0
  463. package/dist/math/allocate.cjs.map +1 -0
  464. package/dist/math/allocate.d.ts +29 -0
  465. package/dist/math/allocate.d.ts.map +1 -0
  466. package/dist/math/allocate.js +20 -0
  467. package/dist/math/allocate.js.map +1 -0
  468. package/dist/math/average.cjs +2 -0
  469. package/dist/math/average.cjs.map +1 -0
  470. package/dist/math/average.d.ts +16 -0
  471. package/dist/math/average.d.ts.map +1 -0
  472. package/dist/math/average.js +14 -0
  473. package/dist/math/average.js.map +1 -0
  474. package/dist/math/clamp.cjs +2 -0
  475. package/dist/math/clamp.cjs.map +1 -0
  476. package/dist/math/clamp.d.ts +21 -0
  477. package/dist/math/clamp.d.ts.map +1 -0
  478. package/dist/math/clamp.js +8 -0
  479. package/dist/math/clamp.js.map +1 -0
  480. package/dist/math/gcd.cjs +2 -0
  481. package/dist/math/gcd.cjs.map +1 -0
  482. package/dist/math/gcd.d.ts +18 -0
  483. package/dist/math/gcd.d.ts.map +1 -0
  484. package/dist/math/gcd.js +13 -0
  485. package/dist/math/gcd.js.map +1 -0
  486. package/dist/math/index.d.ts +20 -0
  487. package/dist/math/index.d.ts.map +1 -0
  488. package/dist/math/lcm.cjs +2 -0
  489. package/dist/math/lcm.cjs.map +1 -0
  490. package/dist/math/lcm.d.ts +15 -0
  491. package/dist/math/lcm.d.ts.map +1 -0
  492. package/dist/math/lcm.js +9 -0
  493. package/dist/math/lcm.js.map +1 -0
  494. package/dist/math/lerp.cjs +2 -0
  495. package/dist/math/lerp.cjs.map +1 -0
  496. package/dist/math/lerp.d.ts +17 -0
  497. package/dist/math/lerp.d.ts.map +1 -0
  498. package/dist/math/lerp.js +8 -0
  499. package/dist/math/lerp.js.map +1 -0
  500. package/dist/math/linspace.cjs +2 -0
  501. package/dist/math/linspace.cjs.map +1 -0
  502. package/dist/math/linspace.d.ts +19 -0
  503. package/dist/math/linspace.d.ts.map +1 -0
  504. package/dist/math/linspace.js +11 -0
  505. package/dist/math/linspace.js.map +1 -0
  506. package/dist/math/max.cjs +2 -0
  507. package/dist/math/max.cjs.map +1 -0
  508. package/dist/math/max.d.ts +21 -0
  509. package/dist/math/max.d.ts.map +1 -0
  510. package/dist/math/max.js +12 -0
  511. package/dist/math/max.js.map +1 -0
  512. package/dist/math/median.cjs +2 -0
  513. package/dist/math/median.cjs.map +1 -0
  514. package/dist/math/median.d.ts +17 -0
  515. package/dist/math/median.d.ts.map +1 -0
  516. package/dist/math/median.js +12 -0
  517. package/dist/math/median.js.map +1 -0
  518. package/dist/math/min.cjs +2 -0
  519. package/dist/math/min.cjs.map +1 -0
  520. package/dist/math/min.d.ts +21 -0
  521. package/dist/math/min.d.ts.map +1 -0
  522. package/dist/math/min.js +12 -0
  523. package/dist/math/min.js.map +1 -0
  524. package/dist/math/mod.cjs +2 -0
  525. package/dist/math/mod.cjs.map +1 -0
  526. package/dist/math/mod.d.ts +18 -0
  527. package/dist/math/mod.d.ts.map +1 -0
  528. package/dist/math/mod.js +10 -0
  529. package/dist/math/mod.js.map +1 -0
  530. package/dist/math/normalize.cjs +2 -0
  531. package/dist/math/normalize.cjs.map +1 -0
  532. package/dist/math/normalize.d.ts +18 -0
  533. package/dist/math/normalize.d.ts.map +1 -0
  534. package/dist/math/normalize.js +9 -0
  535. package/dist/math/normalize.js.map +1 -0
  536. package/dist/math/percent.cjs +2 -0
  537. package/dist/math/percent.cjs.map +1 -0
  538. package/dist/math/percent.d.ts +19 -0
  539. package/dist/math/percent.d.ts.map +1 -0
  540. package/dist/math/percent.js +8 -0
  541. package/dist/math/percent.js.map +1 -0
  542. package/dist/math/range.cjs +2 -0
  543. package/dist/math/range.cjs.map +1 -0
  544. package/dist/math/range.d.ts +37 -0
  545. package/dist/math/range.d.ts.map +1 -0
  546. package/dist/math/range.js +27 -0
  547. package/dist/math/range.js.map +1 -0
  548. package/dist/math/round.cjs +2 -0
  549. package/dist/math/round.cjs.map +1 -0
  550. package/dist/math/round.d.ts +21 -0
  551. package/dist/math/round.d.ts.map +1 -0
  552. package/dist/math/round.js +10 -0
  553. package/dist/math/round.js.map +1 -0
  554. package/dist/math/standardDeviation.cjs +2 -0
  555. package/dist/math/standardDeviation.cjs.map +1 -0
  556. package/dist/math/standardDeviation.d.ts +16 -0
  557. package/dist/math/standardDeviation.d.ts.map +1 -0
  558. package/dist/math/standardDeviation.js +9 -0
  559. package/dist/math/standardDeviation.js.map +1 -0
  560. package/dist/math/sum.cjs +2 -0
  561. package/dist/math/sum.cjs.map +1 -0
  562. package/dist/math/sum.d.ts +19 -0
  563. package/dist/math/sum.d.ts.map +1 -0
  564. package/dist/math/sum.js +13 -0
  565. package/dist/math/sum.js.map +1 -0
  566. package/dist/math/variance.cjs +2 -0
  567. package/dist/math/variance.cjs.map +1 -0
  568. package/dist/math/variance.d.ts +17 -0
  569. package/dist/math/variance.d.ts.map +1 -0
  570. package/dist/math/variance.js +11 -0
  571. package/dist/math/variance.js.map +1 -0
  572. package/dist/object/defaults.cjs +2 -0
  573. package/dist/object/defaults.cjs.map +1 -0
  574. package/dist/object/defaults.d.ts +17 -0
  575. package/dist/object/defaults.d.ts.map +1 -0
  576. package/dist/object/defaults.js +12 -0
  577. package/dist/object/defaults.js.map +1 -0
  578. package/dist/object/diff.cjs +2 -0
  579. package/dist/object/diff.cjs.map +1 -0
  580. package/dist/object/diff.d.ts +63 -0
  581. package/dist/object/diff.d.ts.map +1 -0
  582. package/dist/object/diff.js +27 -0
  583. package/dist/object/diff.js.map +1 -0
  584. package/dist/object/filterValues.cjs +2 -0
  585. package/dist/object/filterValues.cjs.map +1 -0
  586. package/dist/object/filterValues.d.ts +16 -0
  587. package/dist/object/filterValues.d.ts.map +1 -0
  588. package/dist/object/filterValues.js +11 -0
  589. package/dist/object/filterValues.js.map +1 -0
  590. package/dist/object/flattenPaths.cjs +2 -0
  591. package/dist/object/flattenPaths.cjs.map +1 -0
  592. package/dist/object/flattenPaths.d.ts +13 -0
  593. package/dist/object/flattenPaths.d.ts.map +1 -0
  594. package/dist/object/flattenPaths.js +31 -0
  595. package/dist/object/flattenPaths.js.map +1 -0
  596. package/dist/object/getPath.cjs +2 -0
  597. package/dist/object/getPath.cjs.map +1 -0
  598. package/dist/object/getPath.d.ts +48 -0
  599. package/dist/object/getPath.d.ts.map +1 -0
  600. package/dist/object/getPath.js +27 -0
  601. package/dist/object/getPath.js.map +1 -0
  602. package/dist/object/hash.cjs +2 -0
  603. package/dist/object/hash.cjs.map +1 -0
  604. package/dist/object/hash.d.ts +12 -0
  605. package/dist/object/hash.d.ts.map +1 -0
  606. package/dist/object/hash.js +28 -0
  607. package/dist/object/hash.js.map +1 -0
  608. package/dist/object/index.d.ts +15 -0
  609. package/dist/object/index.d.ts.map +1 -0
  610. package/dist/object/invert.cjs +2 -0
  611. package/dist/object/invert.cjs.map +1 -0
  612. package/dist/object/invert.d.ts +15 -0
  613. package/dist/object/invert.d.ts.map +1 -0
  614. package/dist/object/invert.js +11 -0
  615. package/dist/object/invert.js.map +1 -0
  616. package/dist/object/mapKeys.cjs +2 -0
  617. package/dist/object/mapKeys.cjs.map +1 -0
  618. package/dist/object/mapKeys.d.ts +16 -0
  619. package/dist/object/mapKeys.d.ts.map +1 -0
  620. package/dist/object/mapKeys.js +15 -0
  621. package/dist/object/mapKeys.js.map +1 -0
  622. package/dist/object/mapValues.cjs +2 -0
  623. package/dist/object/mapValues.cjs.map +1 -0
  624. package/dist/object/mapValues.d.ts +18 -0
  625. package/dist/object/mapValues.d.ts.map +1 -0
  626. package/dist/object/mapValues.js +11 -0
  627. package/dist/object/mapValues.js.map +1 -0
  628. package/dist/object/merge.cjs +2 -0
  629. package/dist/object/merge.cjs.map +1 -0
  630. package/dist/object/merge.d.ts +41 -0
  631. package/dist/object/merge.d.ts.map +1 -0
  632. package/dist/object/merge.js +27 -0
  633. package/dist/object/merge.js.map +1 -0
  634. package/dist/object/omit.cjs +2 -0
  635. package/dist/object/omit.cjs.map +1 -0
  636. package/dist/object/omit.d.ts +16 -0
  637. package/dist/object/omit.d.ts.map +1 -0
  638. package/dist/object/omit.js +11 -0
  639. package/dist/object/omit.js.map +1 -0
  640. package/dist/object/parseJSON.cjs +2 -0
  641. package/dist/object/parseJSON.cjs.map +1 -0
  642. package/dist/object/parseJSON.d.ts +32 -0
  643. package/dist/object/parseJSON.d.ts.map +1 -0
  644. package/dist/object/parseJSON.js +16 -0
  645. package/dist/object/parseJSON.js.map +1 -0
  646. package/dist/object/pick.cjs +2 -0
  647. package/dist/object/pick.cjs.map +1 -0
  648. package/dist/object/pick.d.ts +17 -0
  649. package/dist/object/pick.d.ts.map +1 -0
  650. package/dist/object/pick.js +11 -0
  651. package/dist/object/pick.js.map +1 -0
  652. package/dist/object/prune.cjs +2 -0
  653. package/dist/object/prune.cjs.map +1 -0
  654. package/dist/object/prune.d.ts +26 -0
  655. package/dist/object/prune.d.ts.map +1 -0
  656. package/dist/object/prune.js +36 -0
  657. package/dist/object/prune.js.map +1 -0
  658. package/dist/random/draw.cjs +2 -0
  659. package/dist/random/draw.cjs.map +1 -0
  660. package/dist/random/draw.d.ts +24 -0
  661. package/dist/random/draw.d.ts.map +1 -0
  662. package/dist/random/draw.js +21 -0
  663. package/dist/random/draw.js.map +1 -0
  664. package/dist/random/index.d.ts +5 -0
  665. package/dist/random/index.d.ts.map +1 -0
  666. package/dist/random/random.cjs +2 -0
  667. package/dist/random/random.cjs.map +1 -0
  668. package/dist/random/random.d.ts +14 -0
  669. package/dist/random/random.d.ts.map +1 -0
  670. package/dist/random/random.js +11 -0
  671. package/dist/random/random.js.map +1 -0
  672. package/dist/random/shuffle.cjs +2 -0
  673. package/dist/random/shuffle.cjs.map +1 -0
  674. package/dist/random/shuffle.d.ts +12 -0
  675. package/dist/random/shuffle.d.ts.map +1 -0
  676. package/dist/random/shuffle.js +14 -0
  677. package/dist/random/shuffle.js.map +1 -0
  678. package/dist/random/uuid.cjs +2 -0
  679. package/dist/random/uuid.cjs.map +1 -0
  680. package/dist/random/uuid.d.ts +12 -0
  681. package/dist/random/uuid.d.ts.map +1 -0
  682. package/dist/random/uuid.js +8 -0
  683. package/dist/random/uuid.js.map +1 -0
  684. package/dist/string/_caseUtils.cjs +2 -0
  685. package/dist/string/_caseUtils.cjs.map +1 -0
  686. package/dist/string/_caseUtils.d.ts +9 -0
  687. package/dist/string/_caseUtils.d.ts.map +1 -0
  688. package/dist/string/_caseUtils.js +13 -0
  689. package/dist/string/_caseUtils.js.map +1 -0
  690. package/dist/string/camelCase.cjs +2 -0
  691. package/dist/string/camelCase.cjs.map +1 -0
  692. package/dist/string/camelCase.d.ts +14 -0
  693. package/dist/string/camelCase.d.ts.map +1 -0
  694. package/dist/string/camelCase.js +9 -0
  695. package/dist/string/camelCase.js.map +1 -0
  696. package/dist/string/endsWith.cjs +2 -0
  697. package/dist/string/endsWith.cjs.map +1 -0
  698. package/dist/string/endsWith.d.ts +5 -0
  699. package/dist/string/endsWith.d.ts.map +1 -0
  700. package/dist/string/endsWith.js +8 -0
  701. package/dist/string/endsWith.js.map +1 -0
  702. package/dist/string/escape.cjs +2 -0
  703. package/dist/string/escape.cjs.map +1 -0
  704. package/dist/string/escape.d.ts +5 -0
  705. package/dist/string/escape.d.ts.map +1 -0
  706. package/dist/string/escape.js +15 -0
  707. package/dist/string/escape.js.map +1 -0
  708. package/dist/string/index.d.ts +14 -0
  709. package/dist/string/index.d.ts.map +1 -0
  710. package/dist/string/kebabCase.cjs +2 -0
  711. package/dist/string/kebabCase.cjs.map +1 -0
  712. package/dist/string/kebabCase.d.ts +15 -0
  713. package/dist/string/kebabCase.d.ts.map +1 -0
  714. package/dist/string/kebabCase.js +9 -0
  715. package/dist/string/kebabCase.js.map +1 -0
  716. package/dist/string/pad.cjs +2 -0
  717. package/dist/string/pad.cjs.map +1 -0
  718. package/dist/string/pad.d.ts +5 -0
  719. package/dist/string/pad.d.ts.map +1 -0
  720. package/dist/string/pad.js +10 -0
  721. package/dist/string/pad.js.map +1 -0
  722. package/dist/string/pascalCase.cjs +2 -0
  723. package/dist/string/pascalCase.cjs.map +1 -0
  724. package/dist/string/pascalCase.d.ts +15 -0
  725. package/dist/string/pascalCase.d.ts.map +1 -0
  726. package/dist/string/pascalCase.js +9 -0
  727. package/dist/string/pascalCase.js.map +1 -0
  728. package/dist/string/similarity.cjs +2 -0
  729. package/dist/string/similarity.cjs.map +1 -0
  730. package/dist/string/similarity.d.ts +2 -0
  731. package/dist/string/similarity.d.ts.map +1 -0
  732. package/dist/string/similarity.js +24 -0
  733. package/dist/string/similarity.js.map +1 -0
  734. package/dist/string/snakeCase.cjs +2 -0
  735. package/dist/string/snakeCase.cjs.map +1 -0
  736. package/dist/string/snakeCase.d.ts +15 -0
  737. package/dist/string/snakeCase.d.ts.map +1 -0
  738. package/dist/string/snakeCase.js +9 -0
  739. package/dist/string/snakeCase.js.map +1 -0
  740. package/dist/string/startsWith.cjs +2 -0
  741. package/dist/string/startsWith.cjs.map +1 -0
  742. package/dist/string/startsWith.d.ts +5 -0
  743. package/dist/string/startsWith.d.ts.map +1 -0
  744. package/dist/string/startsWith.js +8 -0
  745. package/dist/string/startsWith.js.map +1 -0
  746. package/dist/string/titleCase.cjs +2 -0
  747. package/dist/string/titleCase.cjs.map +1 -0
  748. package/dist/string/titleCase.d.ts +5 -0
  749. package/dist/string/titleCase.d.ts.map +1 -0
  750. package/dist/string/titleCase.js +9 -0
  751. package/dist/string/titleCase.js.map +1 -0
  752. package/dist/string/truncate.cjs +2 -0
  753. package/dist/string/truncate.cjs.map +1 -0
  754. package/dist/string/truncate.d.ts +27 -0
  755. package/dist/string/truncate.d.ts.map +1 -0
  756. package/dist/string/truncate.js +17 -0
  757. package/dist/string/truncate.js.map +1 -0
  758. package/dist/string/unescape.cjs +2 -0
  759. package/dist/string/unescape.cjs.map +1 -0
  760. package/dist/string/unescape.d.ts +5 -0
  761. package/dist/string/unescape.d.ts.map +1 -0
  762. package/dist/string/unescape.js +15 -0
  763. package/dist/string/unescape.js.map +1 -0
  764. package/dist/string/words.cjs +2 -0
  765. package/dist/string/words.cjs.map +1 -0
  766. package/dist/string/words.d.ts +5 -0
  767. package/dist/string/words.d.ts.map +1 -0
  768. package/dist/string/words.js +10 -0
  769. package/dist/string/words.js.map +1 -0
  770. package/dist/types.d.ts +13 -0
  771. package/dist/types.d.ts.map +1 -0
  772. package/package.json +102 -0
@@ -0,0 +1,12 @@
1
+ import { compare as e } from "../array/compare.js";
2
+ //#region src/math/min.ts
3
+ function t(t, n) {
4
+ if (t.length === 0) return;
5
+ let r = n ?? ((e) => e), i = t[0];
6
+ for (let n = 1; n < t.length; n++) e(r(t[n]), r(i)) < 0 && (i = t[n]);
7
+ return i;
8
+ }
9
+ //#endregion
10
+ export { t as min };
11
+
12
+ //# sourceMappingURL=min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.js","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../array/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 */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) < 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":";;AAqBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAI,EAAM,WAAW,GAAG;CAExB,IAAM,IAAK,OAAc,MAAY,IACjC,IAAU,EAAM;CAEpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAChC,AAAI,EAAQ,EAAG,EAAM,EAAE,GAAG,EAAG,CAAO,CAAC,IAAI,MACvC,IAAU,EAAM;CAIpB,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("../errors.cjs");function t(t,n){if(n===0)throw new e.ArsenalValidationError(`mod: divisor cannot be 0`);return(t%n+n)%n}exports.mod=t;
2
+ //# sourceMappingURL=mod.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.cjs","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Sign-correct modulo — unlike the native `%` operator, the result always has the same sign\n * as the divisor `b` (e.g. `mod(-1, 4)` is `3`, not `-1`).\n *\n * @example\n * ```ts\n * mod(-1, 4); // 3\n * mod(5, 3); // 2\n * ```\n *\n * @param a - The dividend.\n * @param b - The divisor. Must not be `0`.\n * @returns The sign-correct modulo of `a` by `b`.\n *\n * @throws {ArsenalValidationError} If `b` is `0`.\n */\nexport function mod(a: number, b: number): number {\n if (b === 0) throw new ArsenalValidationError('mod: divisor cannot be 0');\n\n return ((a % b) + b) % b;\n}\n"],"mappings":"iCAkBA,SAAgB,EAAI,EAAW,EAAmB,CAChD,GAAI,IAAM,EAAG,MAAM,IAAI,EAAA,uBAAuB,0BAA0B,EAExE,OAAS,EAAI,EAAK,GAAK,CACzB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Sign-correct modulo — unlike the native `%` operator, the result always has the same sign
3
+ * as the divisor `b` (e.g. `mod(-1, 4)` is `3`, not `-1`).
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * mod(-1, 4); // 3
8
+ * mod(5, 3); // 2
9
+ * ```
10
+ *
11
+ * @param a - The dividend.
12
+ * @param b - The divisor. Must not be `0`.
13
+ * @returns The sign-correct modulo of `a` by `b`.
14
+ *
15
+ * @throws {ArsenalValidationError} If `b` is `0`.
16
+ */
17
+ export declare function mod(a: number, b: number): number;
18
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/math/mod.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhD"}
@@ -0,0 +1,10 @@
1
+ import { ArsenalValidationError as e } from "../errors.js";
2
+ //#region src/math/mod.ts
3
+ function t(t, n) {
4
+ if (n === 0) throw new e("mod: divisor cannot be 0");
5
+ return (t % n + n) % n;
6
+ }
7
+ //#endregion
8
+ export { t as mod };
9
+
10
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Sign-correct modulo — unlike the native `%` operator, the result always has the same sign\n * as the divisor `b` (e.g. `mod(-1, 4)` is `3`, not `-1`).\n *\n * @example\n * ```ts\n * mod(-1, 4); // 3\n * mod(5, 3); // 2\n * ```\n *\n * @param a - The dividend.\n * @param b - The divisor. Must not be `0`.\n * @returns The sign-correct modulo of `a` by `b`.\n *\n * @throws {ArsenalValidationError} If `b` is `0`.\n */\nexport function mod(a: number, b: number): number {\n if (b === 0) throw new ArsenalValidationError('mod: divisor cannot be 0');\n\n return ((a % b) + b) % b;\n}\n"],"mappings":";;AAkBA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAI,MAAM,GAAG,MAAM,IAAI,EAAuB,0BAA0B;CAExE,QAAS,IAAI,IAAK,KAAK;AACzB"}
@@ -0,0 +1,2 @@
1
+ const e=require("./clamp.cjs");function t(t,n,r){return n===r?0:e.clamp((t-n)/(r-n),0,1)}exports.normalize=t;
2
+ //# sourceMappingURL=normalize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.cjs","names":[],"sources":["../../src/math/normalize.ts"],"sourcesContent":["import { clamp } from './clamp';\n\n/**\n * Normalizes a value from the range `[min, max]` into `[0, 1]`. The result is clamped, so\n * values outside `[min, max]` map to `0` or `1` rather than extrapolating.\n *\n * @example\n * ```ts\n * normalize(5, 0, 10); // 0.5\n * normalize(-5, 0, 10); // 0 (clamped)\n * normalize(15, 0, 10); // 1 (clamped)\n * ```\n *\n * @param value - The value to normalize.\n * @param min - The lower bound of the source range.\n * @param max - The upper bound of the source range.\n * @returns The normalized value in `[0, 1]`, or `0` if `min === max`.\n */\nexport function normalize(value: number, min: number, max: number): number {\n if (min === max) return 0;\n\n return clamp((value - min) / (max - min), 0, 1);\n}\n"],"mappings":"+BAkBA,SAAgB,EAAU,EAAe,EAAa,EAAqB,CAGzE,OAFI,IAAQ,EAAY,EAEjB,EAAA,OAAO,EAAQ,IAAQ,EAAM,GAAM,EAAG,CAAC,CAChD"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Normalizes a value from the range `[min, max]` into `[0, 1]`. The result is clamped, so
3
+ * values outside `[min, max]` map to `0` or `1` rather than extrapolating.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * normalize(5, 0, 10); // 0.5
8
+ * normalize(-5, 0, 10); // 0 (clamped)
9
+ * normalize(15, 0, 10); // 1 (clamped)
10
+ * ```
11
+ *
12
+ * @param value - The value to normalize.
13
+ * @param min - The lower bound of the source range.
14
+ * @param max - The upper bound of the source range.
15
+ * @returns The normalized value in `[0, 1]`, or `0` if `min === max`.
16
+ */
17
+ export declare function normalize(value: number, min: number, max: number): number;
18
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/math/normalize.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIzE"}
@@ -0,0 +1,9 @@
1
+ import { clamp as e } from "./clamp.js";
2
+ //#region src/math/normalize.ts
3
+ function t(t, n, r) {
4
+ return n === r ? 0 : e((t - n) / (r - n), 0, 1);
5
+ }
6
+ //#endregion
7
+ export { t as normalize };
8
+
9
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","names":[],"sources":["../../src/math/normalize.ts"],"sourcesContent":["import { clamp } from './clamp';\n\n/**\n * Normalizes a value from the range `[min, max]` into `[0, 1]`. The result is clamped, so\n * values outside `[min, max]` map to `0` or `1` rather than extrapolating.\n *\n * @example\n * ```ts\n * normalize(5, 0, 10); // 0.5\n * normalize(-5, 0, 10); // 0 (clamped)\n * normalize(15, 0, 10); // 1 (clamped)\n * ```\n *\n * @param value - The value to normalize.\n * @param min - The lower bound of the source range.\n * @param max - The upper bound of the source range.\n * @returns The normalized value in `[0, 1]`, or `0` if `min === max`.\n */\nexport function normalize(value: number, min: number, max: number): number {\n if (min === max) return 0;\n\n return clamp((value - min) / (max - min), 0, 1);\n}\n"],"mappings":";;AAkBA,SAAgB,EAAU,GAAe,GAAa,GAAqB;CAGzE,OAFI,MAAQ,IAAY,IAEjB,GAAO,IAAQ,MAAQ,IAAM,IAAM,GAAG,CAAC;AAChD"}
@@ -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,GAC3B"}
@@ -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;CAG5D,OAFI,MAAU,IAAU,IAEhB,IAAQ,IAAS;AAC3B"}
@@ -0,0 +1,2 @@
1
+ const e=require("../errors.cjs");function t(t,n,r){let[i,a,o]=n===void 0?[0,t,1]:r===void 0?[t,n,1]:[t,n,r];if(!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(o))throw new e.ArsenalValidationError(`range: start, stop, and step must be finite numbers`);if(o===0)throw new e.ArsenalValidationError(`range: step cannot be 0`);if(i===a)return[];let s=(a-i)/o,c=Math.max(0,Number.isInteger(s)?s:Math.ceil(s+2**-52));if(c>1e7)throw new e.ArsenalValidationError(`range: exceeds maximum allowed size of 10,000,000`);return Array.from({length:c},(e,t)=>i+t*o)}exports.range=t;
2
+ //# sourceMappingURL=range.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.cjs","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Creates an array of numbers from `0` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(5) // [0, 1, 2, 3, 4]\n * ```\n */\nexport function range(stop: number): number[];\n/**\n * Creates an array of numbers from `start` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(2, 6) // [2, 3, 4, 5]\n * ```\n */\nexport function range(start: number, stop: number): number[];\n/**\n * Creates an array of numbers progressing from `start` up to, but not including, `stop` with a given `step`.\n *\n * @example\n * ```ts\n * range(0, 10, 2) // [0, 2, 4, 6, 8]\n * range(10, 0, -2) // [10, 8, 6, 4, 2]\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range (exclusive).\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {ArsenalValidationError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number): number[];\nexport function range(startOrStop: number, stop?: number, step?: number): number[] {\n const [resolvedStart, resolvedStop, resolvedStep] =\n stop === undefined ? [0, startOrStop, 1] : step === undefined ? [startOrStop, stop, 1] : [startOrStop, stop, step];\n\n if (!Number.isFinite(resolvedStart) || !Number.isFinite(resolvedStop) || !Number.isFinite(resolvedStep)) {\n throw new ArsenalValidationError('range: start, stop, and step must be finite numbers');\n }\n\n if (resolvedStep === 0) throw new ArsenalValidationError('range: step cannot be 0');\n\n if (resolvedStart === resolvedStop) {\n return [];\n }\n\n const raw = (resolvedStop - resolvedStart) / resolvedStep;\n const length = Math.max(0, Number.isInteger(raw) ? raw : Math.ceil(raw + Number.EPSILON));\n\n if (length > 10_000_000) throw new ArsenalValidationError('range: exceeds maximum allowed size of 10,000,000');\n\n return Array.from({ length }, (_, i) => resolvedStart + i * resolvedStep);\n}\n"],"mappings":"iCAsCA,SAAgB,EAAM,EAAqB,EAAe,EAAyB,CACjF,GAAM,CAAC,EAAe,EAAc,GAClC,IAAS,IAAA,GAAY,CAAC,EAAG,EAAa,CAAC,EAAI,IAAS,IAAA,GAAY,CAAC,EAAa,EAAM,CAAC,EAAI,CAAC,EAAa,EAAM,CAAI,EAEnH,GAAI,CAAC,OAAO,SAAS,CAAa,GAAK,CAAC,OAAO,SAAS,CAAY,GAAK,CAAC,OAAO,SAAS,CAAY,EACpG,MAAM,IAAI,EAAA,uBAAuB,qDAAqD,EAGxF,GAAI,IAAiB,EAAG,MAAM,IAAI,EAAA,uBAAuB,yBAAyB,EAElF,GAAI,IAAkB,EACpB,MAAO,CAAC,EAGV,IAAM,GAAO,EAAe,GAAiB,EACvC,EAAS,KAAK,IAAI,EAAG,OAAO,UAAU,CAAG,EAAI,EAAM,KAAK,KAAK,QAAoB,CAAC,EAExF,GAAI,EAAS,IAAY,MAAM,IAAI,EAAA,uBAAuB,mDAAmD,EAE7G,OAAO,MAAM,KAAK,CAAE,QAAO,GAAI,EAAG,IAAM,EAAgB,EAAI,CAAY,CAC1E"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Creates an array of numbers from `0` up to, but not including, `stop` with step `1`.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * range(5) // [0, 1, 2, 3, 4]
7
+ * ```
8
+ */
9
+ export declare function range(stop: number): number[];
10
+ /**
11
+ * Creates an array of numbers from `start` up to, but not including, `stop` with step `1`.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * range(2, 6) // [2, 3, 4, 5]
16
+ * ```
17
+ */
18
+ export declare function range(start: number, stop: number): number[];
19
+ /**
20
+ * Creates an array of numbers progressing from `start` up to, but not including, `stop` with a given `step`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * range(0, 10, 2) // [0, 2, 4, 6, 8]
25
+ * range(10, 0, -2) // [10, 8, 6, 4, 2]
26
+ * ```
27
+ *
28
+ * @param start - The start of the range.
29
+ * @param stop - The end of the range (exclusive).
30
+ * @param step - The value to increment or decrement by.
31
+ *
32
+ * @returns The range of numbers.
33
+ *
34
+ * @throws {ArsenalValidationError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.
35
+ */
36
+ export declare function range(start: number, stop: number, step: number): number[];
37
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/math/range.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9C;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAC7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { ArsenalValidationError as e } from "../errors.js";
2
+ //#region src/math/range.ts
3
+ function t(t, n, r) {
4
+ let [i, a, o] = n === void 0 ? [
5
+ 0,
6
+ t,
7
+ 1
8
+ ] : r === void 0 ? [
9
+ t,
10
+ n,
11
+ 1
12
+ ] : [
13
+ t,
14
+ n,
15
+ r
16
+ ];
17
+ if (!Number.isFinite(i) || !Number.isFinite(a) || !Number.isFinite(o)) throw new e("range: start, stop, and step must be finite numbers");
18
+ if (o === 0) throw new e("range: step cannot be 0");
19
+ if (i === a) return [];
20
+ let s = (a - i) / o, c = Math.max(0, Number.isInteger(s) ? s : Math.ceil(s + 2 ** -52));
21
+ if (c > 1e7) throw new e("range: exceeds maximum allowed size of 10,000,000");
22
+ return Array.from({ length: c }, (e, t) => i + t * o);
23
+ }
24
+ //#endregion
25
+ export { t as range };
26
+
27
+ //# sourceMappingURL=range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.js","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Creates an array of numbers from `0` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(5) // [0, 1, 2, 3, 4]\n * ```\n */\nexport function range(stop: number): number[];\n/**\n * Creates an array of numbers from `start` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(2, 6) // [2, 3, 4, 5]\n * ```\n */\nexport function range(start: number, stop: number): number[];\n/**\n * Creates an array of numbers progressing from `start` up to, but not including, `stop` with a given `step`.\n *\n * @example\n * ```ts\n * range(0, 10, 2) // [0, 2, 4, 6, 8]\n * range(10, 0, -2) // [10, 8, 6, 4, 2]\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range (exclusive).\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {ArsenalValidationError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number): number[];\nexport function range(startOrStop: number, stop?: number, step?: number): number[] {\n const [resolvedStart, resolvedStop, resolvedStep] =\n stop === undefined ? [0, startOrStop, 1] : step === undefined ? [startOrStop, stop, 1] : [startOrStop, stop, step];\n\n if (!Number.isFinite(resolvedStart) || !Number.isFinite(resolvedStop) || !Number.isFinite(resolvedStep)) {\n throw new ArsenalValidationError('range: start, stop, and step must be finite numbers');\n }\n\n if (resolvedStep === 0) throw new ArsenalValidationError('range: step cannot be 0');\n\n if (resolvedStart === resolvedStop) {\n return [];\n }\n\n const raw = (resolvedStop - resolvedStart) / resolvedStep;\n const length = Math.max(0, Number.isInteger(raw) ? raw : Math.ceil(raw + Number.EPSILON));\n\n if (length > 10_000_000) throw new ArsenalValidationError('range: exceeds maximum allowed size of 10,000,000');\n\n return Array.from({ length }, (_, i) => resolvedStart + i * resolvedStep);\n}\n"],"mappings":";;AAsCA,SAAgB,EAAM,GAAqB,GAAe,GAAyB;CACjF,IAAM,CAAC,GAAe,GAAc,KAClC,MAAS,KAAA,IAAY;EAAC;EAAG;EAAa;CAAC,IAAI,MAAS,KAAA,IAAY;EAAC;EAAa;EAAM;CAAC,IAAI;EAAC;EAAa;EAAM;CAAI;CAEnH,IAAI,CAAC,OAAO,SAAS,CAAa,KAAK,CAAC,OAAO,SAAS,CAAY,KAAK,CAAC,OAAO,SAAS,CAAY,GACpG,MAAM,IAAI,EAAuB,qDAAqD;CAGxF,IAAI,MAAiB,GAAG,MAAM,IAAI,EAAuB,yBAAyB;CAElF,IAAI,MAAkB,GACpB,OAAO,CAAC;CAGV,IAAM,KAAO,IAAe,KAAiB,GACvC,IAAS,KAAK,IAAI,GAAG,OAAO,UAAU,CAAG,IAAI,IAAM,KAAK,KAAK,YAAoB,CAAC;CAExF,IAAI,IAAS,KAAY,MAAM,IAAI,EAAuB,mDAAmD;CAE7G,OAAO,MAAM,KAAK,EAAE,UAAO,IAAI,GAAG,MAAM,IAAgB,IAAI,CAAY;AAC1E"}
@@ -0,0 +1,2 @@
1
+ function e(e,t=0,n=Math.round){if(t===0)return n(e);let r=10**Math.max(-323,Math.min(t,292));return n(e*r)/r}exports.round=e;
2
+ //# sourceMappingURL=round.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.cjs","names":[],"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified number of decimal places.\n *\n * The `precision` argument is limited to be within the range of -323 to +292 to avoid NaN results.\n *\n * @example\n * ```ts\n * round(123.456) // 123\n * round(123.456, -1) // 120\n * round(123.456, 1, Math.ceil) // 123.5\n * round(123.456, 1, Math.floor) // 123.4\n * ```\n *\n * @param value - The number to round.\n * @param precision - The number of decimal places to round to.\n * @param [parser] - (optional) function to convert the number to a value.\n *\n * @returns The rounded number.\n */\nexport function round(value: number, precision = 0, parser: (value: number) => number = Math.round): number {\n if (precision === 0) return parser(value);\n\n const factor = 10 ** Math.max(-323, Math.min(precision, 292));\n\n return parser(value * factor) / factor;\n}\n"],"mappings":"AAmBA,SAAgB,EAAM,EAAe,EAAY,EAAG,EAAoC,KAAK,MAAe,CAC1G,GAAI,IAAc,EAAG,OAAO,EAAO,CAAK,EAExC,IAAM,EAAS,IAAM,KAAK,IAAI,KAAM,KAAK,IAAI,EAAW,GAAG,CAAC,EAE5D,OAAO,EAAO,EAAQ,CAAM,EAAI,CAClC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rounds a number to a specified number of decimal places.
3
+ *
4
+ * The `precision` argument is limited to be within the range of -323 to +292 to avoid NaN results.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * round(123.456) // 123
9
+ * round(123.456, -1) // 120
10
+ * round(123.456, 1, Math.ceil) // 123.5
11
+ * round(123.456, 1, Math.floor) // 123.4
12
+ * ```
13
+ *
14
+ * @param value - The number to round.
15
+ * @param precision - The number of decimal places to round to.
16
+ * @param [parser] - (optional) function to convert the number to a value.
17
+ *
18
+ * @returns The rounded number.
19
+ */
20
+ export declare function round(value: number, precision?: number, parser?: (value: number) => number): number;
21
+ //# sourceMappingURL=round.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.d.ts","sourceRoot":"","sources":["../../src/math/round.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI,EAAE,MAAM,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAmB,GAAG,MAAM,CAM1G"}
@@ -0,0 +1,10 @@
1
+ //#region src/math/round.ts
2
+ function e(e, t = 0, n = Math.round) {
3
+ if (t === 0) return n(e);
4
+ let r = 10 ** Math.max(-323, Math.min(t, 292));
5
+ return n(e * r) / r;
6
+ }
7
+ //#endregion
8
+ export { e as round };
9
+
10
+ //# sourceMappingURL=round.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.js","names":[],"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified number of decimal places.\n *\n * The `precision` argument is limited to be within the range of -323 to +292 to avoid NaN results.\n *\n * @example\n * ```ts\n * round(123.456) // 123\n * round(123.456, -1) // 120\n * round(123.456, 1, Math.ceil) // 123.5\n * round(123.456, 1, Math.floor) // 123.4\n * ```\n *\n * @param value - The number to round.\n * @param precision - The number of decimal places to round to.\n * @param [parser] - (optional) function to convert the number to a value.\n *\n * @returns The rounded number.\n */\nexport function round(value: number, precision = 0, parser: (value: number) => number = Math.round): number {\n if (precision === 0) return parser(value);\n\n const factor = 10 ** Math.max(-323, Math.min(precision, 292));\n\n return parser(value * factor) / factor;\n}\n"],"mappings":";AAmBA,SAAgB,EAAM,GAAe,IAAY,GAAG,IAAoC,KAAK,OAAe;CAC1G,IAAI,MAAc,GAAG,OAAO,EAAO,CAAK;CAExC,IAAM,IAAS,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,GAAW,GAAG,CAAC;CAE5D,OAAO,EAAO,IAAQ,CAAM,IAAI;AAClC"}
@@ -0,0 +1,2 @@
1
+ const e=require("./variance.cjs");function t(t,n){return Math.sqrt(e.variance(t,n))}exports.standardDeviation=t;
2
+ //# sourceMappingURL=standardDeviation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardDeviation.cjs","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":"kCAgBA,SAAgB,EAAqB,EAAY,EAAwC,CACvF,OAAO,KAAK,KAAK,EAAA,SAAS,EAAO,CAAQ,CAAC,CAC5C"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Computes the population standard deviation (square root of `variance`) of an array of
3
+ * numbers, or of values mapped by a callback.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2
8
+ * standardDeviation([]); // 0
9
+ * ```
10
+ *
11
+ * @param array - The array to compute standard deviation over.
12
+ * @param callback - An optional callback to map each item to a number.
13
+ * @returns The population standard deviation, or `0` for an empty array.
14
+ */
15
+ export declare function standardDeviation<T>(array: T[], callback?: (item: T) => number): number;
16
+ //# sourceMappingURL=standardDeviation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardDeviation.d.ts","sourceRoot":"","sources":["../../src/math/standardDeviation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAEvF"}
@@ -0,0 +1,9 @@
1
+ import { variance as e } from "./variance.js";
2
+ //#region src/math/standardDeviation.ts
3
+ function t(t, n) {
4
+ return Math.sqrt(e(t, n));
5
+ }
6
+ //#endregion
7
+ export { t as standardDeviation };
8
+
9
+ //# sourceMappingURL=standardDeviation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardDeviation.js","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":";;AAgBA,SAAgB,EAAqB,GAAY,GAAwC;CACvF,OAAO,KAAK,KAAK,EAAS,GAAO,CAAQ,CAAC;AAC5C"}
@@ -0,0 +1,2 @@
1
+ const e=require("../errors.cjs");function t(t,n){return t.length===0?0:t.reduce((t,r)=>{let i=n?n(r):r;if(typeof i!=`number`||Number.isNaN(i))throw new e.ArsenalValidationError(`sum: encountered a non-numeric value; provide a callback to map non-number items`);return t+i},0)}exports.sum=t;
2
+ //# sourceMappingURL=sum.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.cjs","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // ArsenalValidationError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {ArsenalValidationError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (typeof val !== 'number' || Number.isNaN(val)) {\n throw new ArsenalValidationError(\n 'sum: encountered a non-numeric value; provide a callback to map non-number items',\n );\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":"iCAmBA,SAAgB,EAAO,EAAY,EAAwC,CAGzE,OAFI,EAAM,SAAW,EAAU,EAExB,EAAM,QAAgB,EAAK,IAAS,CACzC,IAAM,EAAM,EAAW,EAAS,CAAI,EAAK,EAEzC,GAAI,OAAO,GAAQ,UAAY,OAAO,MAAM,CAAG,EAC7C,MAAM,IAAI,EAAA,uBACR,kFACF,EAGF,OAAO,EAAM,CACf,EAAG,CAAC,CACN"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Sum numbers in an array or numbers mapped by a callback function.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * sum([1, 2, 3]) // 6
7
+ * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6
8
+ * sum(['apple', 'banana', 'cherry']) // ArsenalValidationError
9
+ * ```
10
+ *
11
+ * @param array - The array to sum.
12
+ * @param callback - An optional callback function to map the values.
13
+ *
14
+ * @returns The sum of the numbers in the array or the sum of the mapped values.
15
+ *
16
+ * @throws {ArsenalValidationError} If (after an optional `callback` mapping) any item is not a finite number.
17
+ */
18
+ export declare function sum<T>(array: T[], callback?: (item: T) => number): number;
19
+ //# sourceMappingURL=sum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.d.ts","sourceRoot":"","sources":["../../src/math/sum.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAczE"}
@@ -0,0 +1,13 @@
1
+ import { ArsenalValidationError as e } from "../errors.js";
2
+ //#region src/math/sum.ts
3
+ function t(t, n) {
4
+ return t.length === 0 ? 0 : t.reduce((t, r) => {
5
+ let i = n ? n(r) : r;
6
+ if (typeof i != "number" || Number.isNaN(i)) throw new e("sum: encountered a non-numeric value; provide a callback to map non-number items");
7
+ return t + i;
8
+ }, 0);
9
+ }
10
+ //#endregion
11
+ export { t as sum };
12
+
13
+ //# sourceMappingURL=sum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.js","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // ArsenalValidationError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {ArsenalValidationError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (typeof val !== 'number' || Number.isNaN(val)) {\n throw new ArsenalValidationError(\n 'sum: encountered a non-numeric value; provide a callback to map non-number items',\n );\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":";;AAmBA,SAAgB,EAAO,GAAY,GAAwC;CAGzE,OAFI,EAAM,WAAW,IAAU,IAExB,EAAM,QAAgB,GAAK,MAAS;EACzC,IAAM,IAAM,IAAW,EAAS,CAAI,IAAK;EAEzC,IAAI,OAAO,KAAQ,YAAY,OAAO,MAAM,CAAG,GAC7C,MAAM,IAAI,EACR,kFACF;EAGF,OAAO,IAAM;CACf,GAAG,CAAC;AACN"}
@@ -0,0 +1,2 @@
1
+ const e=require("./average.cjs");function t(t,n){if(t.length===0)return 0;let r=n?t.map(n):t,i=e.average(r)??0;return e.average(r.map(e=>(e-i)**2))??0}exports.variance=t;
2
+ //# sourceMappingURL=variance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variance.cjs","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":"iCAiBA,SAAgB,EAAY,EAAY,EAAwC,CAC9E,GAAI,EAAM,SAAW,EAAG,MAAO,GAE/B,IAAM,EAAS,EAAW,EAAM,IAAI,CAAQ,EAAK,EAC3C,EAAO,EAAA,QAAQ,CAAM,GAAK,EAEhC,OAAO,EAAA,QAAQ,EAAO,IAAK,IAAW,EAAQ,IAAS,CAAC,CAAC,GAAK,CAChE"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Computes the population variance (average squared deviation from the mean) of an array of
3
+ * numbers, or of values mapped by a callback.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4
8
+ * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1
9
+ * variance([]); // 0
10
+ * ```
11
+ *
12
+ * @param array - The array to compute variance over.
13
+ * @param callback - An optional callback to map each item to a number.
14
+ * @returns The population variance, or `0` for an empty array.
15
+ */
16
+ export declare function variance<T>(array: T[], callback?: (item: T) => number): number;
17
+ //# sourceMappingURL=variance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variance.d.ts","sourceRoot":"","sources":["../../src/math/variance.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAO9E"}
@@ -0,0 +1,11 @@
1
+ import { average as e } from "./average.js";
2
+ //#region src/math/variance.ts
3
+ function t(t, n) {
4
+ if (t.length === 0) return 0;
5
+ let r = n ? t.map(n) : t, i = e(r) ?? 0;
6
+ return e(r.map((e) => (e - i) ** 2)) ?? 0;
7
+ }
8
+ //#endregion
9
+ export { t as variance };
10
+
11
+ //# sourceMappingURL=variance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variance.js","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAY,GAAY,GAAwC;CAC9E,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,IAAS,IAAW,EAAM,IAAI,CAAQ,IAAK,GAC3C,IAAO,EAAQ,CAAM,KAAK;CAEhC,OAAO,EAAQ,EAAO,KAAK,OAAW,IAAQ,MAAS,CAAC,CAAC,KAAK;AAChE"}
@@ -0,0 +1,2 @@
1
+ const e=require("../_common/unsafePaths.cjs"),t=require("../guards/isPlainObject.cjs");function n(n,...r){let i={...n};for(let n of r)if(t.isPlainObject(n))for(let t of Object.keys(n))e.isUnsafeKey(t)||i[t]===void 0&&(i[t]=n[t]);return i}exports.defaults=n;
2
+ //# sourceMappingURL=defaults.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.cjs","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":"uFAmBA,SAAgB,EAAwB,EAAW,GAAG,EAA+B,CACnF,IAAM,EAAM,CAAE,GAAG,CAAO,EAExB,IAAK,IAAM,KAAU,EACd,KAAA,cAAc,CAAM,EAEzB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAC9B,EAAA,YAAY,CAAkB,GAE9B,EAAI,KAAS,IAAA,KACf,EAAI,GAAO,EAAO,IAKxB,OAAO,CACT"}
@@ -0,0 +1,17 @@
1
+ import type { Obj } from '../types';
2
+ /**
3
+ * Fills in `undefined` properties in `target` with values from `sources`. First source wins
4
+ * — unlike `shallowMerge`, already-set keys are never overwritten.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });
9
+ * // { a: 1, b: 2, c: 3 }
10
+ * ```
11
+ *
12
+ * @param target - The object to fill in.
13
+ * @param sources - One or more partial objects supplying default values.
14
+ * @returns A new object with missing keys filled from `sources`.
15
+ */
16
+ export declare function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T;
17
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/object/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAKpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAgBnF"}
@@ -0,0 +1,12 @@
1
+ import { isUnsafeKey as e } from "../_common/unsafePaths.js";
2
+ import { isPlainObject as t } from "../guards/isPlainObject.js";
3
+ //#region src/object/defaults.ts
4
+ function n(n, ...r) {
5
+ let i = { ...n };
6
+ for (let n of r) if (t(n)) for (let t of Object.keys(n)) e(t) || i[t] === void 0 && (i[t] = n[t]);
7
+ return i;
8
+ }
9
+ //#endregion
10
+ export { n as defaults };
11
+
12
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":";;;AAmBA,SAAgB,EAAwB,GAAW,GAAG,GAA+B;CACnF,IAAM,IAAM,EAAE,GAAG,EAAO;CAExB,KAAK,IAAM,KAAU,GACd,MAAc,CAAM,GAEzB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAC9B,EAAY,CAAkB,KAE9B,EAAI,OAAS,KAAA,MACf,EAAI,KAAO,EAAO;CAKxB,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("../guards/isEqual.cjs"),t=require("../_common/unsafePaths.cjs");function n(n={},r={},i=e.isEqual){let a=[],o=[],s={},c=new Set(Object.keys(n)),l=new Set(Object.keys(r));for(let e of l)c.has(e)?!t.isUnsafeKey(e)&&!i(n[e],r[e])&&(s[e]={after:r[e],before:n[e]}):a.push(e);for(let e of c)l.has(e)||o.push(e);return{added:a,changed:s,removed:o}}function r(t,n,r){let i=r?.compareFn??((t,n)=>e.isEqual(t,n));return{added:n.filter(e=>!t.some(t=>i(t,e))),removed:t.filter(e=>!n.some(t=>i(e,t)))}}exports.diff=n,exports.diffArrays=r;
2
+ //# sourceMappingURL=diff.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.cjs","names":[],"sources":["../../src/object/diff.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isEqual } from '../guards/isEqual';\n\nexport type DiffResult<T extends Obj> = {\n /** Keys present in `after` but not in `before`. */\n added: Array<keyof T & string>;\n /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */\n changed: { [K in keyof T]?: { after: T[K]; before: T[K] } };\n /** Keys present in `before` but not in `after`. */\n removed: Array<keyof T & string>;\n};\n\n/**\n * Computes the structural difference between two plain objects.\n * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.\n *\n * @example\n * ```ts\n * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });\n * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }\n *\n * diff({ x: { n: 1 } }, { x: { n: 2 } });\n * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }\n * ```\n *\n * @param before - The original object.\n * @param after - The updated object.\n * @param compareFn - Custom equality function. Defaults to deep `isEqual`.\n */\nexport function diff<T extends Obj>(\n before: T = {} as T,\n after: T = {} as T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): DiffResult<T> {\n const added: Array<keyof T & string> = [];\n const removed: Array<keyof T & string> = [];\n const changed: Record<string, { after: unknown; before: unknown }> = {};\n\n const beforeKeys = new Set(Object.keys(before));\n const afterKeys = new Set(Object.keys(after));\n\n for (const key of afterKeys) {\n if (!beforeKeys.has(key)) {\n added.push(key as keyof T & string);\n } else if (!isUnsafeKey(key) && !compareFn(before[key], after[key])) {\n changed[key] = { after: after[key], before: before[key] };\n }\n }\n\n for (const key of beforeKeys) {\n if (!afterKeys.has(key)) {\n removed.push(key as keyof T & string);\n }\n }\n\n return { added, changed: changed as DiffResult<T>['changed'], removed };\n}\n\nexport type ArrayDiff<T> = {\n added: T[];\n removed: T[];\n};\n\nexport type ArrayDiffOptions<T> = {\n compareFn?: (a: T, b: T) => boolean;\n};\n\n/**\n * Computes the set-difference between two arrays.\n * Items present in `after` but not `before` are `added`.\n * Items present in `before` but not `after` are `removed`.\n * Order-independent; uses deep equality by default.\n *\n * @example\n * ```ts\n * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }\n * diffArrays(\n * [{ id: 1 }, { id: 2 }],\n * [{ id: 2 }, { id: 3 }],\n * { compareFn: (a, b) => a.id === b.id },\n * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }\n * ```\n *\n * @param before - The original array.\n * @param after - The updated array.\n * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.\n * @returns An object with `added` and `removed` arrays.\n */\nexport function diffArrays<T>(before: T[], after: T[], options?: ArrayDiffOptions<T>): ArrayDiff<T> {\n const compareFn = options?.compareFn ?? ((a: T, b: T) => isEqual(a, b));\n\n return {\n added: after.filter((item) => !before.some((b) => compareFn(b, item))),\n removed: before.filter((item) => !after.some((a) => compareFn(item, a))),\n };\n}\n"],"mappings":"iFAgCA,SAAgB,EACd,EAAY,CAAC,EACb,EAAW,CAAC,EACZ,EAAiD,EAAA,QAClC,CACf,IAAM,EAAiC,CAAC,EAClC,EAAmC,CAAC,EACpC,EAA+D,CAAC,EAEhE,EAAa,IAAI,IAAI,OAAO,KAAK,CAAM,CAAC,EACxC,EAAY,IAAI,IAAI,OAAO,KAAK,CAAK,CAAC,EAE5C,IAAK,IAAM,KAAO,EACX,EAAW,IAAI,CAAG,EAEZ,CAAC,EAAA,YAAY,CAAG,GAAK,CAAC,EAAU,EAAO,GAAM,EAAM,EAAI,IAChE,EAAQ,GAAO,CAAE,MAAO,EAAM,GAAM,OAAQ,EAAO,EAAK,GAFxD,EAAM,KAAK,CAAuB,EAMtC,IAAK,IAAM,KAAO,EACX,EAAU,IAAI,CAAG,GACpB,EAAQ,KAAK,CAAuB,EAIxC,MAAO,CAAE,QAAgB,UAAqC,SAAQ,CACxE,CAgCA,SAAgB,EAAc,EAAa,EAAY,EAA6C,CAClG,IAAM,EAAY,GAAS,aAAe,EAAM,IAAS,EAAA,QAAQ,EAAG,CAAC,GAErE,MAAO,CACL,MAAO,EAAM,OAAQ,GAAS,CAAC,EAAO,KAAM,GAAM,EAAU,EAAG,CAAI,CAAC,CAAC,EACrE,QAAS,EAAO,OAAQ,GAAS,CAAC,EAAM,KAAM,GAAM,EAAU,EAAM,CAAC,CAAC,CAAC,CACzE,CACF"}
@@ -0,0 +1,63 @@
1
+ import type { Obj } from '../types';
2
+ export type DiffResult<T extends Obj> = {
3
+ /** Keys present in `after` but not in `before`. */
4
+ added: Array<keyof T & string>;
5
+ /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */
6
+ changed: {
7
+ [K in keyof T]?: {
8
+ after: T[K];
9
+ before: T[K];
10
+ };
11
+ };
12
+ /** Keys present in `before` but not in `after`. */
13
+ removed: Array<keyof T & string>;
14
+ };
15
+ /**
16
+ * Computes the structural difference between two plain objects.
17
+ * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.
18
+ * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });
23
+ * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }
24
+ *
25
+ * diff({ x: { n: 1 } }, { x: { n: 2 } });
26
+ * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }
27
+ * ```
28
+ *
29
+ * @param before - The original object.
30
+ * @param after - The updated object.
31
+ * @param compareFn - Custom equality function. Defaults to deep `isEqual`.
32
+ */
33
+ export declare function diff<T extends Obj>(before?: T, after?: T, compareFn?: (a: unknown, b: unknown) => boolean): DiffResult<T>;
34
+ export type ArrayDiff<T> = {
35
+ added: T[];
36
+ removed: T[];
37
+ };
38
+ export type ArrayDiffOptions<T> = {
39
+ compareFn?: (a: T, b: T) => boolean;
40
+ };
41
+ /**
42
+ * Computes the set-difference between two arrays.
43
+ * Items present in `after` but not `before` are `added`.
44
+ * Items present in `before` but not `after` are `removed`.
45
+ * Order-independent; uses deep equality by default.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }
50
+ * diffArrays(
51
+ * [{ id: 1 }, { id: 2 }],
52
+ * [{ id: 2 }, { id: 3 }],
53
+ * { compareFn: (a, b) => a.id === b.id },
54
+ * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }
55
+ * ```
56
+ *
57
+ * @param before - The original array.
58
+ * @param after - The updated array.
59
+ * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.
60
+ * @returns An object with `added` and `removed` arrays.
61
+ */
62
+ export declare function diffArrays<T>(before: T[], after: T[], options?: ArrayDiffOptions<T>): ArrayDiff<T>;
63
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/object/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAKpC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI;IACtC,mDAAmD;IACnD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAC/B,wFAAwF;IACxF,OAAO,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KAAE,CAAC;IAC5D,mDAAmD;IACnD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAChC,MAAM,GAAE,CAAW,EACnB,KAAK,GAAE,CAAW,EAClB,SAAS,GAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAiB,GACvD,UAAU,CAAC,CAAC,CAAC,CAuBf;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAOlG"}