@vielzeug/toolkit 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/dist/array/aggregate.cjs +2 -0
  2. package/dist/array/aggregate.cjs.map +1 -0
  3. package/dist/array/aggregate.js +16 -0
  4. package/dist/array/aggregate.js.map +1 -0
  5. package/dist/array/alternate.cjs +2 -0
  6. package/dist/array/alternate.cjs.map +1 -0
  7. package/dist/array/alternate.js +9 -0
  8. package/dist/array/alternate.js.map +1 -0
  9. package/dist/array/chunk.cjs +2 -0
  10. package/dist/array/chunk.cjs.map +1 -0
  11. package/dist/array/chunk.js +22 -0
  12. package/dist/array/chunk.js.map +1 -0
  13. package/dist/array/compact.cjs +2 -0
  14. package/dist/array/compact.cjs.map +1 -0
  15. package/dist/array/compact.js +9 -0
  16. package/dist/array/compact.js.map +1 -0
  17. package/dist/array/contains.cjs +2 -0
  18. package/dist/array/contains.cjs.map +1 -0
  19. package/dist/array/contains.js +11 -0
  20. package/dist/array/contains.js.map +1 -0
  21. package/dist/array/every.cjs +2 -0
  22. package/dist/array/every.cjs.map +1 -0
  23. package/dist/array/every.js +14 -0
  24. package/dist/array/every.js.map +1 -0
  25. package/dist/array/filter.cjs +2 -0
  26. package/dist/array/filter.cjs.map +1 -0
  27. package/dist/array/filter.js +14 -0
  28. package/dist/array/filter.js.map +1 -0
  29. package/dist/array/find.cjs +2 -0
  30. package/dist/array/find.cjs.map +1 -0
  31. package/dist/array/find.js +14 -0
  32. package/dist/array/find.js.map +1 -0
  33. package/dist/array/findIndex.cjs +2 -0
  34. package/dist/array/findIndex.cjs.map +1 -0
  35. package/dist/array/findIndex.js +14 -0
  36. package/dist/array/findIndex.js.map +1 -0
  37. package/dist/array/findLast.cjs +2 -0
  38. package/dist/array/findLast.cjs.map +1 -0
  39. package/dist/array/findLast.js +14 -0
  40. package/dist/array/findLast.js.map +1 -0
  41. package/dist/array/flatten.cjs +2 -0
  42. package/dist/array/flatten.cjs.map +1 -0
  43. package/dist/array/flatten.js +7 -0
  44. package/dist/array/flatten.js.map +1 -0
  45. package/dist/array/group.cjs +2 -0
  46. package/dist/array/group.cjs.map +1 -0
  47. package/dist/array/group.js +16 -0
  48. package/dist/array/group.js.map +1 -0
  49. package/dist/array/list.cjs +2 -0
  50. package/dist/array/list.cjs.map +1 -0
  51. package/dist/array/list.js +70 -0
  52. package/dist/array/list.js.map +1 -0
  53. package/dist/array/map.cjs +2 -0
  54. package/dist/array/map.cjs.map +1 -0
  55. package/dist/array/map.js +18 -0
  56. package/dist/array/map.js.map +1 -0
  57. package/dist/array/pick.cjs +2 -0
  58. package/dist/array/pick.cjs.map +1 -0
  59. package/dist/array/pick.js +15 -0
  60. package/dist/array/pick.js.map +1 -0
  61. package/dist/array/reduce.cjs +2 -0
  62. package/dist/array/reduce.cjs.map +1 -0
  63. package/dist/array/reduce.js +16 -0
  64. package/dist/array/reduce.js.map +1 -0
  65. package/dist/array/search.cjs +2 -0
  66. package/dist/array/search.cjs.map +1 -0
  67. package/dist/array/search.js +14 -0
  68. package/dist/array/search.js.map +1 -0
  69. package/dist/array/select.cjs +2 -0
  70. package/dist/array/select.cjs.map +1 -0
  71. package/dist/array/select.js +16 -0
  72. package/dist/array/select.js.map +1 -0
  73. package/dist/array/shift.cjs +2 -0
  74. package/dist/array/shift.cjs.map +1 -0
  75. package/dist/array/shift.js +13 -0
  76. package/dist/array/shift.js.map +1 -0
  77. package/dist/array/some.cjs +2 -0
  78. package/dist/array/some.cjs.map +1 -0
  79. package/dist/array/some.js +14 -0
  80. package/dist/array/some.js.map +1 -0
  81. package/dist/array/sort.cjs +2 -0
  82. package/dist/array/sort.cjs.map +1 -0
  83. package/dist/array/sort.js +13 -0
  84. package/dist/array/sort.js.map +1 -0
  85. package/dist/array/sortBy.cjs +2 -0
  86. package/dist/array/sortBy.cjs.map +1 -0
  87. package/dist/array/sortBy.js +6 -0
  88. package/dist/array/sortBy.js.map +1 -0
  89. package/dist/array/substitute.cjs +2 -0
  90. package/dist/array/substitute.cjs.map +1 -0
  91. package/dist/array/substitute.js +13 -0
  92. package/dist/array/substitute.js.map +1 -0
  93. package/dist/array/uniq.cjs +2 -0
  94. package/dist/array/uniq.cjs.map +1 -0
  95. package/dist/array/uniq.js +18 -0
  96. package/dist/array/uniq.js.map +1 -0
  97. package/dist/date/expires.cjs +2 -0
  98. package/dist/date/expires.cjs.map +1 -0
  99. package/dist/date/expires.js +11 -0
  100. package/dist/date/expires.js.map +1 -0
  101. package/dist/date/interval.cjs +2 -0
  102. package/dist/date/interval.cjs.map +1 -0
  103. package/dist/date/interval.js +39 -0
  104. package/dist/date/interval.js.map +1 -0
  105. package/dist/date/timeDiff.cjs +2 -0
  106. package/dist/date/timeDiff.cjs.map +1 -0
  107. package/dist/date/timeDiff.js +29 -0
  108. package/dist/date/timeDiff.js.map +1 -0
  109. package/dist/function/assert.cjs +3 -0
  110. package/dist/function/assert.cjs.map +1 -0
  111. package/dist/function/assert.js +12 -0
  112. package/dist/function/assert.js.map +1 -0
  113. package/dist/function/assertParams.cjs +2 -0
  114. package/dist/function/assertParams.cjs.map +1 -0
  115. package/dist/function/assertParams.js +13 -0
  116. package/dist/function/assertParams.js.map +1 -0
  117. package/dist/function/attempt.cjs +2 -0
  118. package/dist/function/attempt.cjs.map +1 -0
  119. package/dist/function/attempt.js +15 -0
  120. package/dist/function/attempt.js.map +1 -0
  121. package/dist/function/compare.cjs +2 -0
  122. package/dist/function/compare.cjs.map +1 -0
  123. package/dist/function/compare.js +22 -0
  124. package/dist/function/compare.js.map +1 -0
  125. package/dist/function/compareBy.cjs +2 -0
  126. package/dist/function/compareBy.cjs.map +1 -0
  127. package/dist/function/compareBy.js +15 -0
  128. package/dist/function/compareBy.js.map +1 -0
  129. package/dist/function/compose.cjs +2 -0
  130. package/dist/function/compose.cjs.map +1 -0
  131. package/dist/function/compose.js +14 -0
  132. package/dist/function/compose.js.map +1 -0
  133. package/dist/function/curry.cjs +2 -0
  134. package/dist/function/curry.cjs.map +1 -0
  135. package/dist/function/curry.js +8 -0
  136. package/dist/function/curry.js.map +1 -0
  137. package/dist/function/debounce.cjs +2 -0
  138. package/dist/function/debounce.cjs.map +1 -0
  139. package/dist/function/debounce.js +10 -0
  140. package/dist/function/debounce.js.map +1 -0
  141. package/dist/function/delay.cjs +2 -0
  142. package/dist/function/delay.cjs.map +1 -0
  143. package/dist/function/delay.js +8 -0
  144. package/dist/function/delay.js.map +1 -0
  145. package/dist/function/fp.cjs +2 -0
  146. package/dist/function/fp.cjs.map +1 -0
  147. package/dist/function/fp.js +10 -0
  148. package/dist/function/fp.js.map +1 -0
  149. package/dist/function/memo.cjs +2 -0
  150. package/dist/function/memo.cjs.map +1 -0
  151. package/dist/function/memo.js +24 -0
  152. package/dist/function/memo.js.map +1 -0
  153. package/dist/function/once.cjs +2 -0
  154. package/dist/function/once.cjs.map +1 -0
  155. package/dist/function/once.js +11 -0
  156. package/dist/function/once.js.map +1 -0
  157. package/dist/function/pipe.cjs +2 -0
  158. package/dist/function/pipe.cjs.map +1 -0
  159. package/dist/function/pipe.js +11 -0
  160. package/dist/function/pipe.js.map +1 -0
  161. package/dist/function/predict.cjs +2 -0
  162. package/dist/function/predict.cjs.map +1 -0
  163. package/dist/function/predict.js +13 -0
  164. package/dist/function/predict.js.map +1 -0
  165. package/dist/function/proxy.cjs +2 -0
  166. package/dist/function/proxy.cjs.map +1 -0
  167. package/dist/function/proxy.js +22 -0
  168. package/dist/function/proxy.js.map +1 -0
  169. package/dist/function/retry.cjs +2 -0
  170. package/dist/function/retry.cjs.map +1 -0
  171. package/dist/function/retry.js +25 -0
  172. package/dist/function/retry.js.map +1 -0
  173. package/dist/function/sleep.cjs +2 -0
  174. package/dist/function/sleep.cjs.map +1 -0
  175. package/dist/function/sleep.js +7 -0
  176. package/dist/function/sleep.js.map +1 -0
  177. package/dist/function/throttle.cjs +2 -0
  178. package/dist/function/throttle.cjs.map +1 -0
  179. package/dist/function/throttle.js +11 -0
  180. package/dist/function/throttle.js.map +1 -0
  181. package/dist/function/worker.cjs +14 -0
  182. package/dist/function/worker.cjs.map +1 -0
  183. package/dist/function/worker.js +29 -0
  184. package/dist/function/worker.js.map +1 -0
  185. package/dist/index.cjs +2 -0
  186. package/dist/index.cjs.map +1 -0
  187. package/dist/index.d.ts +2278 -0
  188. package/dist/index.js +217 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/logit/dist/logit.cjs +2 -0
  191. package/dist/logit/dist/logit.cjs.map +1 -0
  192. package/dist/logit/dist/logit.js +178 -0
  193. package/dist/logit/dist/logit.js.map +1 -0
  194. package/dist/math/average.cjs +2 -0
  195. package/dist/math/average.cjs.map +1 -0
  196. package/dist/math/average.js +19 -0
  197. package/dist/math/average.js.map +1 -0
  198. package/dist/math/boil.cjs +2 -0
  199. package/dist/math/boil.cjs.map +1 -0
  200. package/dist/math/boil.js +17 -0
  201. package/dist/math/boil.js.map +1 -0
  202. package/dist/math/clamp.cjs +2 -0
  203. package/dist/math/clamp.cjs.map +1 -0
  204. package/dist/math/clamp.js +7 -0
  205. package/dist/math/clamp.js.map +1 -0
  206. package/dist/math/max.cjs +2 -0
  207. package/dist/math/max.cjs.map +1 -0
  208. package/dist/math/max.js +12 -0
  209. package/dist/math/max.js.map +1 -0
  210. package/dist/math/median.cjs +2 -0
  211. package/dist/math/median.cjs.map +1 -0
  212. package/dist/math/median.js +11 -0
  213. package/dist/math/median.js.map +1 -0
  214. package/dist/math/min.cjs +2 -0
  215. package/dist/math/min.cjs.map +1 -0
  216. package/dist/math/min.js +12 -0
  217. package/dist/math/min.js.map +1 -0
  218. package/dist/math/range.cjs +2 -0
  219. package/dist/math/range.cjs.map +1 -0
  220. package/dist/math/range.js +10 -0
  221. package/dist/math/range.js.map +1 -0
  222. package/dist/math/rate.cjs +2 -0
  223. package/dist/math/rate.cjs.map +1 -0
  224. package/dist/math/rate.js +9 -0
  225. package/dist/math/rate.js.map +1 -0
  226. package/dist/math/round.cjs +2 -0
  227. package/dist/math/round.cjs.map +1 -0
  228. package/dist/math/round.js +9 -0
  229. package/dist/math/round.js.map +1 -0
  230. package/dist/math/sum.cjs +2 -0
  231. package/dist/math/sum.cjs.map +1 -0
  232. package/dist/math/sum.js +22 -0
  233. package/dist/math/sum.js.map +1 -0
  234. package/dist/object/clone.cjs +2 -0
  235. package/dist/object/clone.cjs.map +1 -0
  236. package/dist/object/clone.js +7 -0
  237. package/dist/object/clone.js.map +1 -0
  238. package/dist/object/diff.cjs +2 -0
  239. package/dist/object/diff.cjs.map +1 -0
  240. package/dist/object/diff.js +18 -0
  241. package/dist/object/diff.js.map +1 -0
  242. package/dist/object/entries.cjs +2 -0
  243. package/dist/object/entries.cjs.map +1 -0
  244. package/dist/object/entries.js +9 -0
  245. package/dist/object/entries.js.map +1 -0
  246. package/dist/object/keys.cjs +2 -0
  247. package/dist/object/keys.cjs.map +1 -0
  248. package/dist/object/keys.js +9 -0
  249. package/dist/object/keys.js.map +1 -0
  250. package/dist/object/merge.cjs +2 -0
  251. package/dist/object/merge.cjs.map +1 -0
  252. package/dist/object/merge.js +29 -0
  253. package/dist/object/merge.js.map +1 -0
  254. package/dist/object/parseJSON.cjs +2 -0
  255. package/dist/object/parseJSON.cjs.map +1 -0
  256. package/dist/object/parseJSON.js +19 -0
  257. package/dist/object/parseJSON.js.map +1 -0
  258. package/dist/object/path.cjs +2 -0
  259. package/dist/object/path.cjs.map +1 -0
  260. package/dist/object/path.js +24 -0
  261. package/dist/object/path.js.map +1 -0
  262. package/dist/object/seek.cjs +2 -0
  263. package/dist/object/seek.cjs.map +1 -0
  264. package/dist/object/seek.js +11 -0
  265. package/dist/object/seek.js.map +1 -0
  266. package/dist/object/values.cjs +2 -0
  267. package/dist/object/values.cjs.map +1 -0
  268. package/dist/object/values.js +9 -0
  269. package/dist/object/values.js.map +1 -0
  270. package/dist/random/draw.cjs +2 -0
  271. package/dist/random/draw.cjs.map +1 -0
  272. package/dist/random/draw.js +11 -0
  273. package/dist/random/draw.js.map +1 -0
  274. package/dist/random/random.cjs +2 -0
  275. package/dist/random/random.cjs.map +1 -0
  276. package/dist/random/random.js +10 -0
  277. package/dist/random/random.js.map +1 -0
  278. package/dist/random/shuffle.cjs +2 -0
  279. package/dist/random/shuffle.cjs.map +1 -0
  280. package/dist/random/shuffle.js +15 -0
  281. package/dist/random/shuffle.js.map +1 -0
  282. package/dist/random/uuid.cjs +2 -0
  283. package/dist/random/uuid.cjs.map +1 -0
  284. package/dist/random/uuid.js +7 -0
  285. package/dist/random/uuid.js.map +1 -0
  286. package/dist/string/_caseUtils.cjs +2 -0
  287. package/dist/string/_caseUtils.cjs.map +1 -0
  288. package/dist/string/_caseUtils.js +9 -0
  289. package/dist/string/_caseUtils.js.map +1 -0
  290. package/dist/string/camelCase.cjs +2 -0
  291. package/dist/string/camelCase.cjs.map +1 -0
  292. package/dist/string/camelCase.js +8 -0
  293. package/dist/string/camelCase.js.map +1 -0
  294. package/dist/string/kebabCase.cjs +2 -0
  295. package/dist/string/kebabCase.cjs.map +1 -0
  296. package/dist/string/kebabCase.js +8 -0
  297. package/dist/string/kebabCase.js.map +1 -0
  298. package/dist/string/pascalCase.cjs +2 -0
  299. package/dist/string/pascalCase.cjs.map +1 -0
  300. package/dist/string/pascalCase.js +8 -0
  301. package/dist/string/pascalCase.js.map +1 -0
  302. package/dist/string/similarity.cjs +2 -0
  303. package/dist/string/similarity.cjs.map +1 -0
  304. package/dist/string/similarity.js +34 -0
  305. package/dist/string/similarity.js.map +1 -0
  306. package/dist/string/snakeCase.cjs +2 -0
  307. package/dist/string/snakeCase.cjs.map +1 -0
  308. package/dist/string/snakeCase.js +8 -0
  309. package/dist/string/snakeCase.js.map +1 -0
  310. package/dist/string/truncate.cjs +2 -0
  311. package/dist/string/truncate.cjs.map +1 -0
  312. package/dist/string/truncate.js +9 -0
  313. package/dist/string/truncate.js.map +1 -0
  314. package/dist/typed/ge.cjs +2 -0
  315. package/dist/typed/ge.cjs.map +1 -0
  316. package/dist/typed/ge.js +7 -0
  317. package/dist/typed/ge.js.map +1 -0
  318. package/dist/typed/gt.cjs +2 -0
  319. package/dist/typed/gt.cjs.map +1 -0
  320. package/dist/typed/gt.js +7 -0
  321. package/dist/typed/gt.js.map +1 -0
  322. package/dist/typed/is.cjs +2 -0
  323. package/dist/typed/is.cjs.map +1 -0
  324. package/dist/typed/is.js +44 -0
  325. package/dist/typed/is.js.map +1 -0
  326. package/dist/typed/isArray.cjs +2 -0
  327. package/dist/typed/isArray.cjs.map +1 -0
  328. package/dist/typed/isArray.js +9 -0
  329. package/dist/typed/isArray.js.map +1 -0
  330. package/dist/typed/isBoolean.cjs +2 -0
  331. package/dist/typed/isBoolean.cjs.map +1 -0
  332. package/dist/typed/isBoolean.js +7 -0
  333. package/dist/typed/isBoolean.js.map +1 -0
  334. package/dist/typed/isDate.cjs +2 -0
  335. package/dist/typed/isDate.cjs.map +1 -0
  336. package/dist/typed/isDate.js +9 -0
  337. package/dist/typed/isDate.js.map +1 -0
  338. package/dist/typed/isDefined.cjs +2 -0
  339. package/dist/typed/isDefined.cjs.map +1 -0
  340. package/dist/typed/isDefined.js +7 -0
  341. package/dist/typed/isDefined.js.map +1 -0
  342. package/dist/typed/isEmpty.cjs +2 -0
  343. package/dist/typed/isEmpty.cjs.map +1 -0
  344. package/dist/typed/isEmpty.js +12 -0
  345. package/dist/typed/isEmpty.js.map +1 -0
  346. package/dist/typed/isEqual.cjs +2 -0
  347. package/dist/typed/isEqual.cjs.map +1 -0
  348. package/dist/typed/isEqual.js +25 -0
  349. package/dist/typed/isEqual.js.map +1 -0
  350. package/dist/typed/isEven.cjs +2 -0
  351. package/dist/typed/isEven.cjs.map +1 -0
  352. package/dist/typed/isEven.js +7 -0
  353. package/dist/typed/isEven.js.map +1 -0
  354. package/dist/typed/isFunction.cjs +2 -0
  355. package/dist/typed/isFunction.cjs.map +1 -0
  356. package/dist/typed/isFunction.js +9 -0
  357. package/dist/typed/isFunction.js.map +1 -0
  358. package/dist/typed/isMatch.cjs +2 -0
  359. package/dist/typed/isMatch.cjs.map +1 -0
  360. package/dist/typed/isMatch.js +19 -0
  361. package/dist/typed/isMatch.js.map +1 -0
  362. package/dist/typed/isNegative.cjs +2 -0
  363. package/dist/typed/isNegative.cjs.map +1 -0
  364. package/dist/typed/isNegative.js +7 -0
  365. package/dist/typed/isNegative.js.map +1 -0
  366. package/dist/typed/isNil.cjs +2 -0
  367. package/dist/typed/isNil.cjs.map +1 -0
  368. package/dist/typed/isNil.js +9 -0
  369. package/dist/typed/isNil.js.map +1 -0
  370. package/dist/typed/isNumber.cjs +2 -0
  371. package/dist/typed/isNumber.cjs.map +1 -0
  372. package/dist/typed/isNumber.js +9 -0
  373. package/dist/typed/isNumber.js.map +1 -0
  374. package/dist/typed/isObject.cjs +2 -0
  375. package/dist/typed/isObject.cjs.map +1 -0
  376. package/dist/typed/isObject.js +9 -0
  377. package/dist/typed/isObject.js.map +1 -0
  378. package/dist/typed/isOdd.cjs +2 -0
  379. package/dist/typed/isOdd.cjs.map +1 -0
  380. package/dist/typed/isOdd.js +7 -0
  381. package/dist/typed/isOdd.js.map +1 -0
  382. package/dist/typed/isPositive.cjs +2 -0
  383. package/dist/typed/isPositive.cjs.map +1 -0
  384. package/dist/typed/isPositive.js +7 -0
  385. package/dist/typed/isPositive.js.map +1 -0
  386. package/dist/typed/isPrimitive.cjs +2 -0
  387. package/dist/typed/isPrimitive.cjs.map +1 -0
  388. package/dist/typed/isPrimitive.js +10 -0
  389. package/dist/typed/isPrimitive.js.map +1 -0
  390. package/dist/typed/isPromise.cjs +2 -0
  391. package/dist/typed/isPromise.cjs.map +1 -0
  392. package/dist/typed/isPromise.js +10 -0
  393. package/dist/typed/isPromise.js.map +1 -0
  394. package/dist/typed/isRegex.cjs +2 -0
  395. package/dist/typed/isRegex.cjs.map +1 -0
  396. package/dist/typed/isRegex.js +7 -0
  397. package/dist/typed/isRegex.js.map +1 -0
  398. package/dist/typed/isString.cjs +2 -0
  399. package/dist/typed/isString.cjs.map +1 -0
  400. package/dist/typed/isString.js +9 -0
  401. package/dist/typed/isString.js.map +1 -0
  402. package/dist/typed/isWithin.cjs +2 -0
  403. package/dist/typed/isWithin.cjs.map +1 -0
  404. package/dist/typed/isWithin.js +10 -0
  405. package/dist/typed/isWithin.js.map +1 -0
  406. package/dist/typed/isZero.cjs +2 -0
  407. package/dist/typed/isZero.cjs.map +1 -0
  408. package/dist/typed/isZero.js +7 -0
  409. package/dist/typed/isZero.js.map +1 -0
  410. package/dist/typed/le.cjs +2 -0
  411. package/dist/typed/le.cjs.map +1 -0
  412. package/dist/typed/le.js +7 -0
  413. package/dist/typed/le.js.map +1 -0
  414. package/dist/typed/lt.cjs +2 -0
  415. package/dist/typed/lt.cjs.map +1 -0
  416. package/dist/typed/lt.js +7 -0
  417. package/dist/typed/lt.js.map +1 -0
  418. package/dist/typed/typeOf.cjs +2 -0
  419. package/dist/typed/typeOf.cjs.map +1 -0
  420. package/dist/typed/typeOf.js +14 -0
  421. package/dist/typed/typeOf.js.map +1 -0
  422. package/package.json +38 -0
@@ -0,0 +1,12 @@
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
+ });
8
+ }
9
+ export {
10
+ u as min
11
+ };
12
+ //# sourceMappingURL=min.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(r,n,e){if(e===0)throw new Error("Step cannot be 0");if(r===n)return[];const o=Math.max(0,Math.ceil((n-r)/e+Number.EPSILON));return Array.from({length:o},(i,t)=>r+t*e)}exports.range=a;
2
+ //# sourceMappingURL=range.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.cjs","sources":["../../src/math/range.ts"],"sourcesContent":["/**\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 */\nexport function range(start: number, stop: number, step: number) {\n if (step === 0) throw new Error('Step cannot be 0');\n if (start === stop) return [];\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"names":["range","start","stop","step","length","_","i"],"mappings":"gFAkBO,SAASA,EAAMC,EAAeC,EAAcC,EAAc,CAC/D,GAAIA,IAAS,EAAG,MAAM,IAAI,MAAM,kBAAkB,EAClD,GAAIF,IAAUC,EAAM,MAAO,CAAA,EAC3B,MAAME,EAAS,KAAK,IAAI,EAAG,KAAK,MAAMF,EAAOD,GAASE,EAAO,OAAO,OAAO,CAAC,EAC5E,OAAO,MAAM,KAAK,CAAE,OAAAC,CAAA,EAAU,CAACC,EAAGC,IAAML,EAAQK,EAAIH,CAAI,CAC1D"}
@@ -0,0 +1,10 @@
1
+ function f(r, e, n) {
2
+ if (n === 0) throw new Error("Step cannot be 0");
3
+ if (r === e) return [];
4
+ const o = Math.max(0, Math.ceil((e - r) / n + Number.EPSILON));
5
+ return Array.from({ length: o }, (c, a) => r + a * n);
6
+ }
7
+ export {
8
+ f as range
9
+ };
10
+ //# sourceMappingURL=range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.js","sources":["../../src/math/range.ts"],"sourcesContent":["/**\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 */\nexport function range(start: number, stop: number, step: number) {\n if (step === 0) throw new Error('Step cannot be 0');\n if (start === stop) return [];\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"names":["range","start","stop","step","length","_","i"],"mappings":"AAkBO,SAASA,EAAMC,GAAeC,GAAcC,GAAc;AAC/D,MAAIA,MAAS,EAAG,OAAM,IAAI,MAAM,kBAAkB;AAClD,MAAIF,MAAUC,EAAM,QAAO,CAAA;AAC3B,QAAME,IAAS,KAAK,IAAI,GAAG,KAAK,MAAMF,IAAOD,KAASE,IAAO,OAAO,OAAO,CAAC;AAC5E,SAAO,MAAM,KAAK,EAAE,QAAAC,EAAA,GAAU,CAACC,GAAGC,MAAML,IAAQK,IAAIH,CAAI;AAC1D;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(r,t,e=5){if(e===1)return[r];const o=(t-r)/(e-1);return Array.from({length:e},(a,n)=>r+n*o)}exports.rate=u;
2
+ //# sourceMappingURL=rate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate.cjs","sources":["../../src/math/rate.ts"],"sourcesContent":["/**\n * Creates an array of numbers progressing from min to max with a specified number of steps.\n *\n * @example\n * ```ts\n * const min = 0;\n * const max = 10;\n * const steps = 5;\n *\n * rate(min, max, steps) // [0, 2.5, 5, 7.5, 10];\n * ```\n *\n * @param min - The start of the range.\n * @param max - The end of the range.\n * @param [steps=5] - The number of steps between min and max.\n *\n * @returns The range of numbers.\n */\nexport function rate(min: number, max: number, steps = 5) {\n if (steps === 1) return [min];\n const stepSize = (max - min) / (steps - 1);\n return Array.from({ length: steps }, (_, i) => min + i * stepSize);\n}\n"],"names":["rate","min","max","steps","stepSize","_","i"],"mappings":"gFAkBO,SAASA,EAAKC,EAAaC,EAAaC,EAAQ,EAAG,CACxD,GAAIA,IAAU,EAAG,MAAO,CAACF,CAAG,EAC5B,MAAMG,GAAYF,EAAMD,IAAQE,EAAQ,GACxC,OAAO,MAAM,KAAK,CAAE,OAAQA,CAAA,EAAS,CAACE,EAAGC,IAAML,EAAMK,EAAIF,CAAQ,CACnE"}
@@ -0,0 +1,9 @@
1
+ function u(r, e, t = 5) {
2
+ if (t === 1) return [r];
3
+ const n = (e - r) / (t - 1);
4
+ return Array.from({ length: t }, (f, o) => r + o * n);
5
+ }
6
+ export {
7
+ u as rate
8
+ };
9
+ //# sourceMappingURL=rate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate.js","sources":["../../src/math/rate.ts"],"sourcesContent":["/**\n * Creates an array of numbers progressing from min to max with a specified number of steps.\n *\n * @example\n * ```ts\n * const min = 0;\n * const max = 10;\n * const steps = 5;\n *\n * rate(min, max, steps) // [0, 2.5, 5, 7.5, 10];\n * ```\n *\n * @param min - The start of the range.\n * @param max - The end of the range.\n * @param [steps=5] - The number of steps between min and max.\n *\n * @returns The range of numbers.\n */\nexport function rate(min: number, max: number, steps = 5) {\n if (steps === 1) return [min];\n const stepSize = (max - min) / (steps - 1);\n return Array.from({ length: steps }, (_, i) => min + i * stepSize);\n}\n"],"names":["rate","min","max","steps","stepSize","_","i"],"mappings":"AAkBO,SAASA,EAAKC,GAAaC,GAAaC,IAAQ,GAAG;AACxD,MAAIA,MAAU,EAAG,QAAO,CAACF,CAAG;AAC5B,QAAMG,KAAYF,IAAMD,MAAQE,IAAQ;AACxC,SAAO,MAAM,KAAK,EAAE,QAAQA,EAAA,GAAS,CAACE,GAAGC,MAAML,IAAMK,IAAIF,CAAQ;AACnE;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(t,n=0,o=Math.round){if(n===0)return o(t);const r=10**Math.max(-323,Math.min(n,292));return o(t*r)/r}exports.round=u;
2
+ //# sourceMappingURL=round.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.cjs","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 return parser(value * factor) / factor;\n}\n"],"names":["round","value","precision","parser","factor"],"mappings":"gFAmBO,SAASA,EAAMC,EAAeC,EAAY,EAAGC,EAAoC,KAAK,MAAe,CAC1G,GAAID,IAAc,EAAG,OAAOC,EAAOF,CAAK,EAExC,MAAMG,EAAS,IAAM,KAAK,IAAI,KAAM,KAAK,IAAIF,EAAW,GAAG,CAAC,EAC5D,OAAOC,EAAOF,EAAQG,CAAM,EAAIA,CAClC"}
@@ -0,0 +1,9 @@
1
+ function u(t, n = 0, o = Math.round) {
2
+ if (n === 0) return o(t);
3
+ const r = 10 ** Math.max(-323, Math.min(n, 292));
4
+ return o(t * r) / r;
5
+ }
6
+ export {
7
+ u as round
8
+ };
9
+ //# sourceMappingURL=round.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"round.js","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 return parser(value * factor) / factor;\n}\n"],"names":["round","value","precision","parser","factor"],"mappings":"AAmBO,SAASA,EAAMC,GAAeC,IAAY,GAAGC,IAAoC,KAAK,OAAe;AAC1G,MAAID,MAAc,EAAG,QAAOC,EAAOF,CAAK;AAExC,QAAMG,IAAS,MAAM,KAAK,IAAI,MAAM,KAAK,IAAIF,GAAW,GAAG,CAAC;AAC5D,SAAOC,EAAOF,IAAQG,CAAM,IAAIA;AAClC;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(t,e){if(t.length!==0)return t.reduce((n,u)=>{const r=e?e(u):u;if(r instanceof Date)return o(r,n);if(typeof r=="number")return s(n,r);throw new TypeError("sum only supports numbers and Date objects")},void 0)}function o(t,e){const n=t.getTime();return e===void 0?new Date(n):e instanceof Date?new Date(e.getTime()+n):new Date(e+n)}function s(t,e){return t===void 0?e:t instanceof Date?new Date(t.getTime()+e):t+e}exports.sum=i;
2
+ //# sourceMappingURL=sum.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.cjs","sources":["../../src/math/sum.ts"],"sourcesContent":["/**\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']) // TypeError\n * sum([new Date('2023-01-01'), new Date('2022-01-01')]) // 467308800000\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 */\nexport function sum<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (array.length === 0) return undefined;\n\n return array.reduce<number | Date | undefined>((acc, item) => {\n const value = callback ? callback(item) : item;\n if (value instanceof Date) {\n return sumDate(value, acc);\n }\n if (typeof value === 'number') {\n return sumNumbers(acc, value);\n }\n throw new TypeError('sum only supports numbers and Date objects');\n }, undefined);\n}\n\nfunction sumDate(value: Date, acc: number | Date | undefined) {\n const valueTime = value.getTime();\n if (acc === undefined) return new Date(valueTime);\n if (acc instanceof Date) return new Date(acc.getTime() + valueTime);\n return new Date(acc + valueTime);\n}\n\nfunction sumNumbers<T>(acc: number | Date | undefined, value: number | (T & number)) {\n if (acc === undefined) return value;\n if (acc instanceof Date) return new Date(acc.getTime() + value);\n return acc + value;\n}\n"],"names":["sum","array","callback","acc","item","value","sumDate","sumNumbers","valueTime"],"mappings":"gFAgBO,SAASA,EAAOC,EAAYC,EAAkE,CACnG,GAAID,EAAM,SAAW,EAErB,OAAOA,EAAM,OAAkC,CAACE,EAAKC,IAAS,CAC5D,MAAMC,EAAQH,EAAWA,EAASE,CAAI,EAAIA,EAC1C,GAAIC,aAAiB,KACnB,OAAOC,EAAQD,EAAOF,CAAG,EAE3B,GAAI,OAAOE,GAAU,SACnB,OAAOE,EAAWJ,EAAKE,CAAK,EAE9B,MAAM,IAAI,UAAU,4CAA4C,CAClE,EAAG,MAAS,CACd,CAEA,SAASC,EAAQD,EAAaF,EAAgC,CAC5D,MAAMK,EAAYH,EAAM,QAAA,EACxB,OAAIF,IAAQ,OAAkB,IAAI,KAAKK,CAAS,EAC5CL,aAAe,KAAa,IAAI,KAAKA,EAAI,QAAA,EAAYK,CAAS,EAC3D,IAAI,KAAKL,EAAMK,CAAS,CACjC,CAEA,SAASD,EAAcJ,EAAgCE,EAA8B,CACnF,OAAIF,IAAQ,OAAkBE,EAC1BF,aAAe,KAAa,IAAI,KAAKA,EAAI,QAAA,EAAYE,CAAK,EACvDF,EAAME,CACf"}
@@ -0,0 +1,22 @@
1
+ function f(t, e) {
2
+ if (t.length !== 0)
3
+ return t.reduce((n, u) => {
4
+ const r = e ? e(u) : u;
5
+ if (r instanceof Date)
6
+ return i(r, n);
7
+ if (typeof r == "number")
8
+ return o(n, r);
9
+ throw new TypeError("sum only supports numbers and Date objects");
10
+ }, void 0);
11
+ }
12
+ function i(t, e) {
13
+ const n = t.getTime();
14
+ return e === void 0 ? new Date(n) : e instanceof Date ? new Date(e.getTime() + n) : new Date(e + n);
15
+ }
16
+ function o(t, e) {
17
+ return t === void 0 ? e : t instanceof Date ? new Date(t.getTime() + e) : t + e;
18
+ }
19
+ export {
20
+ f as sum
21
+ };
22
+ //# sourceMappingURL=sum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.js","sources":["../../src/math/sum.ts"],"sourcesContent":["/**\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']) // TypeError\n * sum([new Date('2023-01-01'), new Date('2022-01-01')]) // 467308800000\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 */\nexport function sum<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (array.length === 0) return undefined;\n\n return array.reduce<number | Date | undefined>((acc, item) => {\n const value = callback ? callback(item) : item;\n if (value instanceof Date) {\n return sumDate(value, acc);\n }\n if (typeof value === 'number') {\n return sumNumbers(acc, value);\n }\n throw new TypeError('sum only supports numbers and Date objects');\n }, undefined);\n}\n\nfunction sumDate(value: Date, acc: number | Date | undefined) {\n const valueTime = value.getTime();\n if (acc === undefined) return new Date(valueTime);\n if (acc instanceof Date) return new Date(acc.getTime() + valueTime);\n return new Date(acc + valueTime);\n}\n\nfunction sumNumbers<T>(acc: number | Date | undefined, value: number | (T & number)) {\n if (acc === undefined) return value;\n if (acc instanceof Date) return new Date(acc.getTime() + value);\n return acc + value;\n}\n"],"names":["sum","array","callback","acc","item","value","sumDate","sumNumbers","valueTime"],"mappings":"AAgBO,SAASA,EAAOC,GAAYC,GAAkE;AACnG,MAAID,EAAM,WAAW;AAErB,WAAOA,EAAM,OAAkC,CAACE,GAAKC,MAAS;AAC5D,YAAMC,IAAQH,IAAWA,EAASE,CAAI,IAAIA;AAC1C,UAAIC,aAAiB;AACnB,eAAOC,EAAQD,GAAOF,CAAG;AAE3B,UAAI,OAAOE,KAAU;AACnB,eAAOE,EAAWJ,GAAKE,CAAK;AAE9B,YAAM,IAAI,UAAU,4CAA4C;AAAA,IAClE,GAAG,MAAS;AACd;AAEA,SAASC,EAAQD,GAAaF,GAAgC;AAC5D,QAAMK,IAAYH,EAAM,QAAA;AACxB,SAAIF,MAAQ,SAAkB,IAAI,KAAKK,CAAS,IAC5CL,aAAe,OAAa,IAAI,KAAKA,EAAI,QAAA,IAAYK,CAAS,IAC3D,IAAI,KAAKL,IAAMK,CAAS;AACjC;AAEA,SAASD,EAAcJ,GAAgCE,GAA8B;AACnF,SAAIF,MAAQ,SAAkBE,IAC1BF,aAAe,OAAa,IAAI,KAAKA,EAAI,QAAA,IAAYE,CAAK,IACvDF,IAAME;AACf;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){return structuredClone(e)}exports.clone=t;
2
+ //# sourceMappingURL=clone.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.cjs","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n */\nexport function clone<T>(item: T): T {\n return structuredClone(item);\n}\n"],"names":["clone","item"],"mappings":"gFAiBO,SAASA,EAASC,EAAY,CACnC,OAAO,gBAAgBA,CAAI,CAC7B"}
@@ -0,0 +1,7 @@
1
+ function n(e) {
2
+ return structuredClone(e);
3
+ }
4
+ export {
5
+ n as clone
6
+ };
7
+ //# sourceMappingURL=clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.js","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n */\nexport function clone<T>(item: T): T {\n return structuredClone(item);\n}\n"],"names":["clone","item"],"mappings":"AAiBO,SAASA,EAASC,GAAY;AACnC,SAAO,gBAAgBA,CAAI;AAC7B;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../typed/isEqual.cjs"),r=require("../typed/isObject.cjs");function u(s,i,f=b.isEqual){if(!s&&!i)return{};const n={};for(const e of new Set([...Object.keys(s??{}),...Object.keys(i??{})])){const t=s?.[e],c=i?.[e];if(r.isObject(t)&&r.isObject(c)){const o=u(t,c,f);Object.keys(o).length>0&&(n[e]=o)}else f(t,c)||(n[e]=t)}return n}exports.diff=u;
2
+ //# sourceMappingURL=diff.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.cjs","sources":["../../src/object/diff.ts"],"sourcesContent":["import { isEqual } from '../typed/isEqual';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Computes the difference between two objects.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: 2, c: 3 };\n * const obj2 = { b: 2, c: 3, d: 4 };\n *\n * diff(obj1, obj2); // { d: 4 }\n * ```\n *\n * @param curr - The current object.\n * @param prev - The previous object.\n * @param [compareFn] - A custom function to compare values.\n * @returns An object containing new/modified properties.\n */\nexport function diff<T extends Obj>(\n curr?: T,\n prev?: T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): Partial<T> {\n if (!curr && !prev) return {} as Partial<T>;\n\n const result: Record<string, unknown> = {};\n\n for (const key of new Set([...Object.keys(curr ?? {}), ...Object.keys(prev ?? {})])) {\n const _curr = curr?.[key];\n const _prev = prev?.[key];\n\n if (isObject(_curr) && isObject(_prev)) {\n const nestedDiff = diff(_curr, _prev, compareFn) as Partial<T[keyof T]>;\n if (Object.keys(nestedDiff).length > 0) {\n result[key] = nestedDiff;\n }\n } else if (!compareFn(_curr, _prev)) {\n result[key] = _curr;\n }\n }\n\n return result as Partial<T>;\n}\n"],"names":["diff","curr","prev","compareFn","isEqual","result","key","_curr","_prev","isObject","nestedDiff"],"mappings":"2JAoBO,SAASA,EACdC,EACAC,EACAC,EAAiDC,EAAAA,QACrC,CACZ,GAAI,CAACH,GAAQ,CAACC,QAAa,CAAA,EAE3B,MAAMG,EAAkC,CAAA,EAExC,UAAWC,KAAO,IAAI,IAAI,CAAC,GAAG,OAAO,KAAKL,GAAQ,CAAA,CAAE,EAAG,GAAG,OAAO,KAAKC,GAAQ,CAAA,CAAE,CAAC,CAAC,EAAG,CACnF,MAAMK,EAAQN,IAAOK,CAAG,EAClBE,EAAQN,IAAOI,CAAG,EAExB,GAAIG,EAAAA,SAASF,CAAK,GAAKE,EAAAA,SAASD,CAAK,EAAG,CACtC,MAAME,EAAaV,EAAKO,EAAOC,EAAOL,CAAS,EAC3C,OAAO,KAAKO,CAAU,EAAE,OAAS,IACnCL,EAAOC,CAAG,EAAII,EAElB,MAAYP,EAAUI,EAAOC,CAAK,IAChCH,EAAOC,CAAG,EAAIC,EAElB,CAEA,OAAOF,CACT"}
@@ -0,0 +1,18 @@
1
+ import { isEqual as b } from "../typed/isEqual.js";
2
+ import { isObject as r } from "../typed/isObject.js";
3
+ function j(f, s, n = b) {
4
+ if (!f && !s) return {};
5
+ const o = {};
6
+ for (const t of /* @__PURE__ */ new Set([...Object.keys(f ?? {}), ...Object.keys(s ?? {})])) {
7
+ const e = f?.[t], i = s?.[t];
8
+ if (r(e) && r(i)) {
9
+ const c = j(e, i, n);
10
+ Object.keys(c).length > 0 && (o[t] = c);
11
+ } else n(e, i) || (o[t] = e);
12
+ }
13
+ return o;
14
+ }
15
+ export {
16
+ j as diff
17
+ };
18
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sources":["../../src/object/diff.ts"],"sourcesContent":["import { isEqual } from '../typed/isEqual';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Computes the difference between two objects.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: 2, c: 3 };\n * const obj2 = { b: 2, c: 3, d: 4 };\n *\n * diff(obj1, obj2); // { d: 4 }\n * ```\n *\n * @param curr - The current object.\n * @param prev - The previous object.\n * @param [compareFn] - A custom function to compare values.\n * @returns An object containing new/modified properties.\n */\nexport function diff<T extends Obj>(\n curr?: T,\n prev?: T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): Partial<T> {\n if (!curr && !prev) return {} as Partial<T>;\n\n const result: Record<string, unknown> = {};\n\n for (const key of new Set([...Object.keys(curr ?? {}), ...Object.keys(prev ?? {})])) {\n const _curr = curr?.[key];\n const _prev = prev?.[key];\n\n if (isObject(_curr) && isObject(_prev)) {\n const nestedDiff = diff(_curr, _prev, compareFn) as Partial<T[keyof T]>;\n if (Object.keys(nestedDiff).length > 0) {\n result[key] = nestedDiff;\n }\n } else if (!compareFn(_curr, _prev)) {\n result[key] = _curr;\n }\n }\n\n return result as Partial<T>;\n}\n"],"names":["diff","curr","prev","compareFn","isEqual","result","key","_curr","_prev","isObject","nestedDiff"],"mappings":";;AAoBO,SAASA,EACdC,GACAC,GACAC,IAAiDC,GACrC;AACZ,MAAI,CAACH,KAAQ,CAACC,UAAa,CAAA;AAE3B,QAAMG,IAAkC,CAAA;AAExC,aAAWC,KAAO,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAKL,KAAQ,CAAA,CAAE,GAAG,GAAG,OAAO,KAAKC,KAAQ,CAAA,CAAE,CAAC,CAAC,GAAG;AACnF,UAAMK,IAAQN,IAAOK,CAAG,GAClBE,IAAQN,IAAOI,CAAG;AAExB,QAAIG,EAASF,CAAK,KAAKE,EAASD,CAAK,GAAG;AACtC,YAAME,IAAaV,EAAKO,GAAOC,GAAOL,CAAS;AAC/C,MAAI,OAAO,KAAKO,CAAU,EAAE,SAAS,MACnCL,EAAOC,CAAG,IAAII;AAAA,IAElB,MAAA,CAAYP,EAAUI,GAAOC,CAAK,MAChCH,EAAOC,CAAG,IAAIC;AAAA,EAElB;AAEA,SAAOF;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../function/assert.cjs"),r=require("../typed/isObject.cjs");function s(e){return t.assert(r.isObject(e),r.IS_OBJECT_ERROR_MSG,{args:{item:e},type:TypeError}),Object.entries(e)}exports.entries=s;
2
+ //# sourceMappingURL=entries.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.cjs","sources":["../../src/object/entries.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];\n\n/**\n * Returns an array of a given object's own enumerable string-keyed property [key, value] pairs.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n * entries(obj); // logs [['a', 1], ['b', 2], ['c', 3]]\n * ```\n *\n * @param item - The object whose properties are to be returned.\n *\n * @returns an array of the object's own enumerable string-keyed property [key, value] pairs.\n */\nexport function entries<T extends Obj>(item: T): Entries<T> {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.entries(item) as Entries<T>;\n}\n"],"names":["entries","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":"6JAmBO,SAASA,EAAuBC,EAAqB,CAC1DC,OAAAA,EAAAA,OAAOC,EAAAA,SAASF,CAAI,EAAGG,sBAAqB,CAAE,KAAM,CAAE,KAAAH,CAAA,EAAQ,KAAM,UAAW,EAExE,OAAO,QAAQA,CAAI,CAC5B"}
@@ -0,0 +1,9 @@
1
+ import { assert as e } from "../function/assert.js";
2
+ import { IS_OBJECT_ERROR_MSG as t, isObject as o } from "../typed/isObject.js";
3
+ function p(r) {
4
+ return e(o(r), t, { args: { item: r }, type: TypeError }), Object.entries(r);
5
+ }
6
+ export {
7
+ p as entries
8
+ };
9
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.js","sources":["../../src/object/entries.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];\n\n/**\n * Returns an array of a given object's own enumerable string-keyed property [key, value] pairs.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n * entries(obj); // logs [['a', 1], ['b', 2], ['c', 3]]\n * ```\n *\n * @param item - The object whose properties are to be returned.\n *\n * @returns an array of the object's own enumerable string-keyed property [key, value] pairs.\n */\nexport function entries<T extends Obj>(item: T): Entries<T> {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.entries(item) as Entries<T>;\n}\n"],"names":["entries","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":";;AAmBO,SAASA,EAAuBC,GAAqB;AAC1D,SAAAC,EAAOC,EAASF,CAAI,GAAGG,GAAqB,EAAE,MAAM,EAAE,MAAAH,EAAA,GAAQ,MAAM,WAAW,GAExE,OAAO,QAAQA,CAAI;AAC5B;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../function/assert.cjs"),r=require("../typed/isObject.cjs");function t(e){return s.assert(r.isObject(e),r.IS_OBJECT_ERROR_MSG,{args:{item:e},type:TypeError}),Object.keys(e)}exports.keys=t;
2
+ //# sourceMappingURL=keys.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.cjs","sources":["../../src/object/keys.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Returns an array of the keys for an object's properties.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n *\n * keys(obj); // ['a', 'b', 'c']\n * ```\n *\n * @param item - The object to query.\n *\n * @returns true if the object has the property, false otherwise.\n */\nexport function keys<T extends Obj, K extends keyof T>(item: T) {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.keys(item) as K[];\n}\n"],"names":["keys","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":"6JAkBO,SAASA,EAAuCC,EAAS,CAC9DC,OAAAA,EAAAA,OAAOC,EAAAA,SAASF,CAAI,EAAGG,sBAAqB,CAAE,KAAM,CAAE,KAAAH,CAAA,EAAQ,KAAM,UAAW,EAExE,OAAO,KAAKA,CAAI,CACzB"}
@@ -0,0 +1,9 @@
1
+ import { assert as e } from "../function/assert.js";
2
+ import { IS_OBJECT_ERROR_MSG as o, isObject as t } from "../typed/isObject.js";
3
+ function y(r) {
4
+ return e(t(r), o, { args: { item: r }, type: TypeError }), Object.keys(r);
5
+ }
6
+ export {
7
+ y as keys
8
+ };
9
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sources":["../../src/object/keys.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Returns an array of the keys for an object's properties.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n *\n * keys(obj); // ['a', 'b', 'c']\n * ```\n *\n * @param item - The object to query.\n *\n * @returns true if the object has the property, false otherwise.\n */\nexport function keys<T extends Obj, K extends keyof T>(item: T) {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.keys(item) as K[];\n}\n"],"names":["keys","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":";;AAkBO,SAASA,EAAuCC,GAAS;AAC9D,SAAAC,EAAOC,EAASF,CAAI,GAAGG,GAAqB,EAAE,MAAM,EAAE,MAAAH,EAAA,GAAQ,MAAM,WAAW,GAExE,OAAO,KAAKA,CAAI;AACzB;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../typed/isArray.cjs"),f=require("../typed/isObject.cjs");function a(r="deep",...n){return n.length===0?{}:r==="shallow"?Object.assign({},...n):n.reduce((e,i)=>l(e,i,r),{})}function l(r,n,e){if(!f.isObject(n))return n;const i={...r};for(const c in n){if(!Object.hasOwn(n,c))continue;const t=n[c],u=i[c];i[c]=o.isArray(t)&&o.isArray(u)?b(u,t,e):f.isObject(t)&&f.isObject(u)?l(u,t,e):O(u,t,e)}return i}function b(r,n,e){return r?e==="arrayConcat"?r.concat(n):e==="arrayReplace"?n:Array.from(new Set([...r,...n])):n}function O(r,n,e){return typeof e=="function"?e(r,n):e==="lastWins"||n!==void 0?n:r}exports.merge=a;
2
+ //# sourceMappingURL=merge.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.cjs","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n // @ts-expect-error\n return items.reduce<Merge<T>>(\n // @ts-expect-error\n (acc, obj) => {\n return deepMerge(acc, obj, strategy);\n },\n {} as Merge<T>,\n );\n}\n\n/**\n * Deeply merges two objects based on the provided strategy.\n *\n * - Uses **direct property access** for performance.\n * - **Avoids redundant deep merging** where unnecessary.\n * - Optimized **array merging strategies**.\n *\n * @param target - The target object.\n * @param source - The source object.\n * @param strategy - The merge strategy.\n * @returns A new merged object.\n */\nfunction deepMerge<T extends Obj, U extends Obj>(target: T, source: U, strategy: MergeStrategy): DeepMerge<T, U> {\n if (!isObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key in source) {\n if (!Object.hasOwn(source, key)) continue; // Prevent prototype pollution\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n // biome-ignore lint/suspicious/noExplicitAny: -\n (result as any)[key] =\n isArray(sourceValue) && isArray(targetValue)\n ? handleArrayMerge(targetValue, sourceValue, strategy)\n : isObject(sourceValue) && isObject(targetValue)\n ? deepMerge(targetValue, sourceValue, strategy)\n : applyMergeStrategy(targetValue, sourceValue, strategy);\n }\n\n return result;\n}\n\n/**\n * Optimized array merge based on strategy.\n *\n * - `\"arrayConcat\"` → Concatenates arrays.\n * - `\"arrayReplace\"` → Replaces the existing array.\n * - Default: **Unique merge** (Set-based optimization).\n */\nfunction handleArrayMerge<T, U>(targetArray: T[] | undefined, sourceArray: U[], strategy: MergeStrategy): (T | U)[] {\n if (!targetArray) return sourceArray;\n // biome-ignore lint/suspicious/noExplicitAny: -\n if (strategy === 'arrayConcat') return targetArray.concat(sourceArray as any);\n if (strategy === 'arrayReplace') return sourceArray;\n return Array.from(new Set([...targetArray, ...sourceArray])); // Unique merge\n}\n\n/**\n * Determines the appropriate value to assign based on the merge strategy.\n *\n * - `\"lastWins\"` → Overwrites with the latest value.\n * - Custom functions → Allows user-defined behavior.\n */\nfunction applyMergeStrategy<T, U>(target: T, source: U, strategy: MergeStrategy): T | U {\n if (typeof strategy === 'function') return strategy(target, source);\n return strategy === 'lastWins' || source !== undefined ? source : target;\n}\n"],"names":["merge","strategy","items","acc","obj","deepMerge","target","source","isObject","result","key","sourceValue","targetValue","isArray","handleArrayMerge","applyMergeStrategy","targetArray","sourceArray"],"mappings":"2JAoDO,SAASA,EAAuBC,EAA0B,UAAWC,EAAyB,CACnG,OAAIA,EAAM,SAAW,EAAU,CAAA,EAE3BD,IAAa,UACR,OAAO,OAAO,CAAA,EAAI,GAAGC,CAAK,EAI5BA,EAAM,OAEX,CAACC,EAAKC,IACGC,EAAUF,EAAKC,EAAKH,CAAQ,EAErC,CAAA,CAAC,CAEL,CAcA,SAASI,EAAwCC,EAAWC,EAAWN,EAA0C,CAC/G,GAAI,CAACO,EAAAA,SAASD,CAAM,EAAG,OAAOA,EAE9B,MAAME,EAAS,CAAE,GAAGH,CAAA,EAEpB,UAAWI,KAAOH,EAAQ,CACxB,GAAI,CAAC,OAAO,OAAOA,EAAQG,CAAG,EAAG,SAEjC,MAAMC,EAAcJ,EAAOG,CAAG,EACxBE,EAAcH,EAAOC,CAAG,EAG7BD,EAAeC,CAAG,EACjBG,EAAAA,QAAQF,CAAW,GAAKE,EAAAA,QAAQD,CAAW,EACvCE,EAAiBF,EAAaD,EAAaV,CAAQ,EACnDO,EAAAA,SAASG,CAAW,GAAKH,EAAAA,SAASI,CAAW,EAC3CP,EAAUO,EAAaD,EAAaV,CAAQ,EAC5Cc,EAAmBH,EAAaD,EAAaV,CAAQ,CAC/D,CAEA,OAAOQ,CACT,CASA,SAASK,EAAuBE,EAA8BC,EAAkBhB,EAAoC,CAClH,OAAKe,EAEDf,IAAa,cAAsBe,EAAY,OAAOC,CAAkB,EACxEhB,IAAa,eAAuBgB,EACjC,MAAM,KAAK,IAAI,IAAI,CAAC,GAAGD,EAAa,GAAGC,CAAW,CAAC,CAAC,EAJlCA,CAK3B,CAQA,SAASF,EAAyBT,EAAWC,EAAWN,EAAgC,CACtF,OAAI,OAAOA,GAAa,WAAmBA,EAASK,EAAQC,CAAM,EAC3DN,IAAa,YAAcM,IAAW,OAAYA,EAASD,CACpE"}
@@ -0,0 +1,29 @@
1
+ import { isArray as c } from "../typed/isArray.js";
2
+ import { isObject as u } from "../typed/isObject.js";
3
+ function m(r = "deep", ...n) {
4
+ return n.length === 0 ? {} : r === "shallow" ? Object.assign({}, ...n) : n.reduce(
5
+ // @ts-expect-error
6
+ (e, i) => l(e, i, r),
7
+ {}
8
+ );
9
+ }
10
+ function l(r, n, e) {
11
+ if (!u(n)) return n;
12
+ const i = { ...r };
13
+ for (const o in n) {
14
+ if (!Object.hasOwn(n, o)) continue;
15
+ const t = n[o], f = i[o];
16
+ i[o] = c(t) && c(f) ? p(f, t, e) : u(t) && u(f) ? l(f, t, e) : a(f, t, e);
17
+ }
18
+ return i;
19
+ }
20
+ function p(r, n, e) {
21
+ return r ? e === "arrayConcat" ? r.concat(n) : e === "arrayReplace" ? n : Array.from(/* @__PURE__ */ new Set([...r, ...n])) : n;
22
+ }
23
+ function a(r, n, e) {
24
+ return typeof e == "function" ? e(r, n) : e === "lastWins" || n !== void 0 ? n : r;
25
+ }
26
+ export {
27
+ m as merge
28
+ };
29
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n // @ts-expect-error\n return items.reduce<Merge<T>>(\n // @ts-expect-error\n (acc, obj) => {\n return deepMerge(acc, obj, strategy);\n },\n {} as Merge<T>,\n );\n}\n\n/**\n * Deeply merges two objects based on the provided strategy.\n *\n * - Uses **direct property access** for performance.\n * - **Avoids redundant deep merging** where unnecessary.\n * - Optimized **array merging strategies**.\n *\n * @param target - The target object.\n * @param source - The source object.\n * @param strategy - The merge strategy.\n * @returns A new merged object.\n */\nfunction deepMerge<T extends Obj, U extends Obj>(target: T, source: U, strategy: MergeStrategy): DeepMerge<T, U> {\n if (!isObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key in source) {\n if (!Object.hasOwn(source, key)) continue; // Prevent prototype pollution\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n // biome-ignore lint/suspicious/noExplicitAny: -\n (result as any)[key] =\n isArray(sourceValue) && isArray(targetValue)\n ? handleArrayMerge(targetValue, sourceValue, strategy)\n : isObject(sourceValue) && isObject(targetValue)\n ? deepMerge(targetValue, sourceValue, strategy)\n : applyMergeStrategy(targetValue, sourceValue, strategy);\n }\n\n return result;\n}\n\n/**\n * Optimized array merge based on strategy.\n *\n * - `\"arrayConcat\"` → Concatenates arrays.\n * - `\"arrayReplace\"` → Replaces the existing array.\n * - Default: **Unique merge** (Set-based optimization).\n */\nfunction handleArrayMerge<T, U>(targetArray: T[] | undefined, sourceArray: U[], strategy: MergeStrategy): (T | U)[] {\n if (!targetArray) return sourceArray;\n // biome-ignore lint/suspicious/noExplicitAny: -\n if (strategy === 'arrayConcat') return targetArray.concat(sourceArray as any);\n if (strategy === 'arrayReplace') return sourceArray;\n return Array.from(new Set([...targetArray, ...sourceArray])); // Unique merge\n}\n\n/**\n * Determines the appropriate value to assign based on the merge strategy.\n *\n * - `\"lastWins\"` → Overwrites with the latest value.\n * - Custom functions → Allows user-defined behavior.\n */\nfunction applyMergeStrategy<T, U>(target: T, source: U, strategy: MergeStrategy): T | U {\n if (typeof strategy === 'function') return strategy(target, source);\n return strategy === 'lastWins' || source !== undefined ? source : target;\n}\n"],"names":["merge","strategy","items","acc","obj","deepMerge","target","source","isObject","result","key","sourceValue","targetValue","isArray","handleArrayMerge","applyMergeStrategy","targetArray","sourceArray"],"mappings":";;AAoDO,SAASA,EAAuBC,IAA0B,WAAWC,GAAyB;AACnG,SAAIA,EAAM,WAAW,IAAU,CAAA,IAE3BD,MAAa,YACR,OAAO,OAAO,CAAA,GAAI,GAAGC,CAAK,IAI5BA,EAAM;AAAA;AAAA,IAEX,CAACC,GAAKC,MACGC,EAAUF,GAAKC,GAAKH,CAAQ;AAAA,IAErC,CAAA;AAAA,EAAC;AAEL;AAcA,SAASI,EAAwCC,GAAWC,GAAWN,GAA0C;AAC/G,MAAI,CAACO,EAASD,CAAM,EAAG,QAAOA;AAE9B,QAAME,IAAS,EAAE,GAAGH,EAAA;AAEpB,aAAWI,KAAOH,GAAQ;AACxB,QAAI,CAAC,OAAO,OAAOA,GAAQG,CAAG,EAAG;AAEjC,UAAMC,IAAcJ,EAAOG,CAAG,GACxBE,IAAcH,EAAOC,CAAG;AAG7B,IAAAD,EAAeC,CAAG,IACjBG,EAAQF,CAAW,KAAKE,EAAQD,CAAW,IACvCE,EAAiBF,GAAaD,GAAaV,CAAQ,IACnDO,EAASG,CAAW,KAAKH,EAASI,CAAW,IAC3CP,EAAUO,GAAaD,GAAaV,CAAQ,IAC5Cc,EAAmBH,GAAaD,GAAaV,CAAQ;AAAA,EAC/D;AAEA,SAAOQ;AACT;AASA,SAASK,EAAuBE,GAA8BC,GAAkBhB,GAAoC;AAClH,SAAKe,IAEDf,MAAa,gBAAsBe,EAAY,OAAOC,CAAkB,IACxEhB,MAAa,iBAAuBgB,IACjC,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAGD,GAAa,GAAGC,CAAW,CAAC,CAAC,IAJlCA;AAK3B;AAQA,SAASF,EAAyBT,GAAWC,GAAWN,GAAgC;AACtF,SAAI,OAAOA,KAAa,aAAmBA,EAASK,GAAQC,CAAM,IAC3DN,MAAa,cAAcM,MAAW,SAAYA,IAASD;AACpE;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../logit/dist/logit.cjs"),n=require("../typed/isNil.cjs"),u=require("../typed/isString.cjs");function l(e,s={}){const{defaultValue:t,reviver:a,validator:i,silent:o=!1}=s;if(!u.isString(e))return n.isNil(e)?t:e;try{const r=JSON.parse(e,a);if(i&&!i(r))throw new TypeError("Parsed JSON does not match the expected structure");return r??t}catch(r){return o||c.Logit.error("parseJSON() -> failed to parse object",r),t}}exports.parseJSON=l;
2
+ //# sourceMappingURL=parseJSON.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseJSON.cjs","sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { Logit } from '@vielzeug/logit';\nimport { isNil } from '../typed/isNil';\nimport { isString } from '../typed/isString';\n\ntype JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };\n\ninterface ParseJSONOptions<T> {\n defaultValue?: T;\n // biome-ignore lint/suspicious/noExplicitAny: -\n reviver?: (key: string, value: any) => any;\n // biome-ignore lint/suspicious/noExplicitAny: -\n validator?: (value: any) => boolean;\n silent?: boolean;\n}\n\n/**\n * Parses a JSON string and returns the resulting object.\n *\n * @example\n * ```ts\n * const json = '{\"a\":1,\"b\":2,\"c\":3}';\n * const result = parseJSON<Record<string, number>>(json, {\n * defaultValue: { a: 0, b: 0, c: 0 },\n * validator: (value) => Object.values(value).every(v => typeof v === 'number'),\n * errorHandler: (err) => console.warn('Parsing failed:', err.message),\n * silent: true\n * });\n * console.log(result); // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. If not a string, it is returned as is.\n * @param options - Configuration options for parsing.\n *\n * @returns The parsed object if successful, otherwise the default value.\n */\nexport function parseJSON<T extends JSONValue>(json: unknown, options: ParseJSONOptions<T> = {}): T | undefined {\n const { defaultValue, reviver, validator, silent = false } = options;\n\n if (!isString(json)) return isNil(json) ? defaultValue : (json as T);\n\n try {\n const parsed = JSON.parse(json as string, reviver);\n\n if (validator && !validator(parsed)) {\n throw new TypeError('Parsed JSON does not match the expected structure');\n }\n\n return parsed ?? defaultValue;\n } catch (err) {\n if (!silent) {\n Logit.error('parseJSON() -> failed to parse object', err);\n }\n\n return defaultValue;\n }\n}\n"],"names":["parseJSON","json","options","defaultValue","reviver","validator","silent","isString","isNil","parsed","err","Logit"],"mappings":"8LAoCO,SAASA,EAA+BC,EAAeC,EAA+B,GAAmB,CAC9G,KAAM,CAAE,aAAAC,EAAc,QAAAC,EAAS,UAAAC,EAAW,OAAAC,EAAS,IAAUJ,EAE7D,GAAI,CAACK,EAAAA,SAASN,CAAI,SAAUO,EAAAA,MAAMP,CAAI,EAAIE,EAAgBF,EAE1D,GAAI,CACF,MAAMQ,EAAS,KAAK,MAAMR,EAAgBG,CAAO,EAEjD,GAAIC,GAAa,CAACA,EAAUI,CAAM,EAChC,MAAM,IAAI,UAAU,mDAAmD,EAGzE,OAAOA,GAAUN,CACnB,OAASO,EAAK,CACZ,OAAKJ,GACHK,QAAM,MAAM,wCAAyCD,CAAG,EAGnDP,CACT,CACF"}
@@ -0,0 +1,19 @@
1
+ import { Logit as p } from "../logit/dist/logit.js";
2
+ import { isNil as f } from "../typed/isNil.js";
3
+ import { isString as c } from "../typed/isString.js";
4
+ function l(r, o = {}) {
5
+ const { defaultValue: t, reviver: a, validator: i, silent: s = !1 } = o;
6
+ if (!c(r)) return f(r) ? t : r;
7
+ try {
8
+ const e = JSON.parse(r, a);
9
+ if (i && !i(e))
10
+ throw new TypeError("Parsed JSON does not match the expected structure");
11
+ return e ?? t;
12
+ } catch (e) {
13
+ return s || p.error("parseJSON() -> failed to parse object", e), t;
14
+ }
15
+ }
16
+ export {
17
+ l as parseJSON
18
+ };
19
+ //# sourceMappingURL=parseJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseJSON.js","sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { Logit } from '@vielzeug/logit';\nimport { isNil } from '../typed/isNil';\nimport { isString } from '../typed/isString';\n\ntype JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };\n\ninterface ParseJSONOptions<T> {\n defaultValue?: T;\n // biome-ignore lint/suspicious/noExplicitAny: -\n reviver?: (key: string, value: any) => any;\n // biome-ignore lint/suspicious/noExplicitAny: -\n validator?: (value: any) => boolean;\n silent?: boolean;\n}\n\n/**\n * Parses a JSON string and returns the resulting object.\n *\n * @example\n * ```ts\n * const json = '{\"a\":1,\"b\":2,\"c\":3}';\n * const result = parseJSON<Record<string, number>>(json, {\n * defaultValue: { a: 0, b: 0, c: 0 },\n * validator: (value) => Object.values(value).every(v => typeof v === 'number'),\n * errorHandler: (err) => console.warn('Parsing failed:', err.message),\n * silent: true\n * });\n * console.log(result); // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. If not a string, it is returned as is.\n * @param options - Configuration options for parsing.\n *\n * @returns The parsed object if successful, otherwise the default value.\n */\nexport function parseJSON<T extends JSONValue>(json: unknown, options: ParseJSONOptions<T> = {}): T | undefined {\n const { defaultValue, reviver, validator, silent = false } = options;\n\n if (!isString(json)) return isNil(json) ? defaultValue : (json as T);\n\n try {\n const parsed = JSON.parse(json as string, reviver);\n\n if (validator && !validator(parsed)) {\n throw new TypeError('Parsed JSON does not match the expected structure');\n }\n\n return parsed ?? defaultValue;\n } catch (err) {\n if (!silent) {\n Logit.error('parseJSON() -> failed to parse object', err);\n }\n\n return defaultValue;\n }\n}\n"],"names":["parseJSON","json","options","defaultValue","reviver","validator","silent","isString","isNil","parsed","err","Logit"],"mappings":";;;AAoCO,SAASA,EAA+BC,GAAeC,IAA+B,IAAmB;AAC9G,QAAM,EAAE,cAAAC,GAAc,SAAAC,GAAS,WAAAC,GAAW,QAAAC,IAAS,OAAUJ;AAE7D,MAAI,CAACK,EAASN,CAAI,UAAUO,EAAMP,CAAI,IAAIE,IAAgBF;AAE1D,MAAI;AACF,UAAMQ,IAAS,KAAK,MAAMR,GAAgBG,CAAO;AAEjD,QAAIC,KAAa,CAACA,EAAUI,CAAM;AAChC,YAAM,IAAI,UAAU,mDAAmD;AAGzE,WAAOA,KAAUN;AAAA,EACnB,SAASO,GAAK;AACZ,WAAKJ,KACHK,EAAM,MAAM,yCAAyCD,CAAG,GAGnDP;AAAA,EACT;AACF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../function/assert.cjs"),p=require("../typed/isArray.cjs"),y=require("../typed/isNil.cjs"),i=require("../typed/isObject.cjs");function d(e,n,o,c={}){l.assert(i.isObject(e),i.IS_OBJECT_ERROR_MSG,{args:{item:e},type:TypeError});const{throwOnMissing:s=!1,allowArrayIndex:f=!1}=c,u=n.split(/[.[\]]+/).filter(Boolean);let r=e;for(const t of u){if(y.isNil(r)||typeof r!="object")return a(`Cannot read property '${t}' of ${r}`,s,o);if(r=f&&p.isArray(r)&&/^\d+$/.test(t)?r[Number(t)]:r[t],r===void 0)return a(`Property '${t}' does not exist`,s,o)}return r}function a(e,n,o){if(n)throw new Error(e);return o}exports.path=d;
2
+ //# sourceMappingURL=path.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.cjs","sources":["../../src/object/path.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isNil } from '../typed/isNil';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : undefined\n : P extends keyof T\n ? T[P]\n : undefined;\n\ntype PathOptions = {\n throwOnMissing?: boolean;\n allowArrayIndex?: boolean;\n};\n\n/**\n * Retrieves the value at a given path of the object. If the value is undefined, the default value is returned.\n *\n * @example\n * ```ts\n * const obj = { a: { b: { c: 3 } }, d: [1, 2, 3] };\n *\n * getValue(obj, 'a.b.c'); // 3\n * getValue(obj, 'a.b.d', 'default'); // 'default'\n * getValue(obj, 'd[1]', undefined, { allowArrayIndex: true }); // 2\n * getValue(obj, 'e.f.g', 'default', { throwOnMissing: true }); // throws Error\n * ```\n *\n * @template T - The type of the object to query.\n * @template P - The type of the path string.\n * @param item - The object to query.\n * @param path - The path of the property to get.\n * @param [defaultValue] - The value returned for undefined resolved values.\n * @param [options] - Additional options for value retrieval.\n *\n * @returns The resolved value.\n *\n * @throws If throwOnMissing is true and the path doesn't exist.\n */\nexport function path<T extends Obj, P extends string>(\n item: T,\n path: P,\n defaultValue?: unknown,\n options: PathOptions = {},\n): PathValue<T, P> | undefined {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n const { throwOnMissing = false, allowArrayIndex = false } = options;\n\n const fragments = path.split(/[.[\\]]+/).filter(Boolean);\n // biome-ignore lint/suspicious/noExplicitAny: -\n let current: any = item;\n\n for (const fragment of fragments) {\n if (isNil(current) || typeof current !== 'object') {\n return handleError(`Cannot read property '${fragment}' of ${current}`, throwOnMissing, defaultValue);\n }\n\n current =\n allowArrayIndex && isArray(current) && /^\\d+$/.test(fragment) ? current[Number(fragment)] : current[fragment];\n\n if (current === undefined) {\n return handleError(`Property '${fragment}' does not exist`, throwOnMissing, defaultValue);\n }\n }\n\n return current as PathValue<T, P>;\n}\n\nfunction handleError<T extends Obj, P extends string>(\n message: string,\n throwOnMissing: boolean,\n defaultValue?: unknown,\n): PathValue<T, P> | undefined {\n if (throwOnMissing) throw new Error(message);\n return defaultValue as PathValue<T, P>;\n}\n"],"names":["path","item","defaultValue","options","assert","isObject","IS_OBJECT_ERROR_MSG","throwOnMissing","allowArrayIndex","fragments","current","fragment","isNil","handleError","isArray","message"],"mappings":"+NA2CO,SAASA,EACdC,EACAD,EACAE,EACAC,EAAuB,CAAA,EACM,CAC7BC,EAAAA,OAAOC,EAAAA,SAASJ,CAAI,EAAGK,sBAAqB,CAAE,KAAM,CAAE,KAAAL,CAAA,EAAQ,KAAM,UAAW,EAE/E,KAAM,CAAE,eAAAM,EAAiB,GAAO,gBAAAC,EAAkB,IAAUL,EAEtDM,EAAYT,EAAK,MAAM,SAAS,EAAE,OAAO,OAAO,EAEtD,IAAIU,EAAeT,EAEnB,UAAWU,KAAYF,EAAW,CAChC,GAAIG,EAAAA,MAAMF,CAAO,GAAK,OAAOA,GAAY,SACvC,OAAOG,EAAY,yBAAyBF,CAAQ,QAAQD,CAAO,GAAIH,EAAgBL,CAAY,EAMrG,GAHAQ,EACEF,GAAmBM,EAAAA,QAAQJ,CAAO,GAAK,QAAQ,KAAKC,CAAQ,EAAID,EAAQ,OAAOC,CAAQ,CAAC,EAAID,EAAQC,CAAQ,EAE1GD,IAAY,OACd,OAAOG,EAAY,aAAaF,CAAQ,mBAAoBJ,EAAgBL,CAAY,CAE5F,CAEA,OAAOQ,CACT,CAEA,SAASG,EACPE,EACAR,EACAL,EAC6B,CAC7B,GAAIK,EAAgB,MAAM,IAAI,MAAMQ,CAAO,EAC3C,OAAOb,CACT"}
@@ -0,0 +1,24 @@
1
+ import { assert as m } from "../function/assert.js";
2
+ import { isArray as c } from "../typed/isArray.js";
3
+ import { isNil as l } from "../typed/isNil.js";
4
+ import { IS_OBJECT_ERROR_MSG as y, isObject as u } from "../typed/isObject.js";
5
+ function w(o, n, e, i = {}) {
6
+ m(u(o), y, { args: { item: o }, type: TypeError });
7
+ const { throwOnMissing: s = !1, allowArrayIndex: p = !1 } = i, a = n.split(/[.[\]]+/).filter(Boolean);
8
+ let r = o;
9
+ for (const t of a) {
10
+ if (l(r) || typeof r != "object")
11
+ return f(`Cannot read property '${t}' of ${r}`, s, e);
12
+ if (r = p && c(r) && /^\d+$/.test(t) ? r[Number(t)] : r[t], r === void 0)
13
+ return f(`Property '${t}' does not exist`, s, e);
14
+ }
15
+ return r;
16
+ }
17
+ function f(o, n, e) {
18
+ if (n) throw new Error(o);
19
+ return e;
20
+ }
21
+ export {
22
+ w as path
23
+ };
24
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sources":["../../src/object/path.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isNil } from '../typed/isNil';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : undefined\n : P extends keyof T\n ? T[P]\n : undefined;\n\ntype PathOptions = {\n throwOnMissing?: boolean;\n allowArrayIndex?: boolean;\n};\n\n/**\n * Retrieves the value at a given path of the object. If the value is undefined, the default value is returned.\n *\n * @example\n * ```ts\n * const obj = { a: { b: { c: 3 } }, d: [1, 2, 3] };\n *\n * getValue(obj, 'a.b.c'); // 3\n * getValue(obj, 'a.b.d', 'default'); // 'default'\n * getValue(obj, 'd[1]', undefined, { allowArrayIndex: true }); // 2\n * getValue(obj, 'e.f.g', 'default', { throwOnMissing: true }); // throws Error\n * ```\n *\n * @template T - The type of the object to query.\n * @template P - The type of the path string.\n * @param item - The object to query.\n * @param path - The path of the property to get.\n * @param [defaultValue] - The value returned for undefined resolved values.\n * @param [options] - Additional options for value retrieval.\n *\n * @returns The resolved value.\n *\n * @throws If throwOnMissing is true and the path doesn't exist.\n */\nexport function path<T extends Obj, P extends string>(\n item: T,\n path: P,\n defaultValue?: unknown,\n options: PathOptions = {},\n): PathValue<T, P> | undefined {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n const { throwOnMissing = false, allowArrayIndex = false } = options;\n\n const fragments = path.split(/[.[\\]]+/).filter(Boolean);\n // biome-ignore lint/suspicious/noExplicitAny: -\n let current: any = item;\n\n for (const fragment of fragments) {\n if (isNil(current) || typeof current !== 'object') {\n return handleError(`Cannot read property '${fragment}' of ${current}`, throwOnMissing, defaultValue);\n }\n\n current =\n allowArrayIndex && isArray(current) && /^\\d+$/.test(fragment) ? current[Number(fragment)] : current[fragment];\n\n if (current === undefined) {\n return handleError(`Property '${fragment}' does not exist`, throwOnMissing, defaultValue);\n }\n }\n\n return current as PathValue<T, P>;\n}\n\nfunction handleError<T extends Obj, P extends string>(\n message: string,\n throwOnMissing: boolean,\n defaultValue?: unknown,\n): PathValue<T, P> | undefined {\n if (throwOnMissing) throw new Error(message);\n return defaultValue as PathValue<T, P>;\n}\n"],"names":["path","item","defaultValue","options","assert","isObject","IS_OBJECT_ERROR_MSG","throwOnMissing","allowArrayIndex","fragments","current","fragment","isNil","handleError","isArray","message"],"mappings":";;;;AA2CO,SAASA,EACdC,GACAD,GACAE,GACAC,IAAuB,CAAA,GACM;AAC7B,EAAAC,EAAOC,EAASJ,CAAI,GAAGK,GAAqB,EAAE,MAAM,EAAE,MAAAL,EAAA,GAAQ,MAAM,WAAW;AAE/E,QAAM,EAAE,gBAAAM,IAAiB,IAAO,iBAAAC,IAAkB,OAAUL,GAEtDM,IAAYT,EAAK,MAAM,SAAS,EAAE,OAAO,OAAO;AAEtD,MAAIU,IAAeT;AAEnB,aAAWU,KAAYF,GAAW;AAChC,QAAIG,EAAMF,CAAO,KAAK,OAAOA,KAAY;AACvC,aAAOG,EAAY,yBAAyBF,CAAQ,QAAQD,CAAO,IAAIH,GAAgBL,CAAY;AAMrG,QAHAQ,IACEF,KAAmBM,EAAQJ,CAAO,KAAK,QAAQ,KAAKC,CAAQ,IAAID,EAAQ,OAAOC,CAAQ,CAAC,IAAID,EAAQC,CAAQ,GAE1GD,MAAY;AACd,aAAOG,EAAY,aAAaF,CAAQ,oBAAoBJ,GAAgBL,CAAY;AAAA,EAE5F;AAEA,SAAOQ;AACT;AAEA,SAASG,EACPE,GACAR,GACAL,GAC6B;AAC7B,MAAIK,EAAgB,OAAM,IAAI,MAAMQ,CAAO;AAC3C,SAAOb;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../function/assert.cjs"),c=require("../string/similarity.cjs"),s=require("../typed/is.cjs"),o=require("../typed/isWithin.cjs");function a(e,t,i=1){return f.assert(o.isWithin(i,0,1),o.IS_WITHIN_ERROR_MSG,{args:{max:1,min:0,tone:i},type:TypeError}),s.is("string",e)||s.is("number",e)?c.similarity(e,t)>=i:Object.values(e).some(r=>s.is("nil",r)?!1:s.is("array",r)?r.some(n=>s.is("object",n)?a(n,t,i):c.similarity(n,t)>=i):s.is("object",r)?a(r,t,i):c.similarity(r,t)>=i)}exports.seek=a;
2
+ //# sourceMappingURL=seek.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seek.cjs","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n return Object.values(item as Record<string, unknown>).some((value) => {\n if (is('nil', value)) return false;\n\n if (is('array', value)) {\n return value.some((v) => (is('object', v) ? seek(v, query, tone) : similarity(v, query) >= tone));\n }\n\n if (is('object', value)) {\n return seek(value, query, tone);\n }\n\n return similarity(value, query) >= tone;\n });\n}\n"],"names":["seek","item","query","tone","assert","isWithin","IS_WITHIN_ERROR_MSG","is","similarity","value","v"],"mappings":"gOA6BO,SAASA,EAAQC,EAASC,EAAeC,EAAO,EAAY,CAGjE,OAFAC,EAAAA,OAAOC,EAAAA,SAASF,EAAM,EAAG,CAAC,EAAGG,EAAAA,oBAAqB,CAAE,KAAM,CAAE,IAAK,EAAG,IAAK,EAAG,KAAAH,GAAQ,KAAM,UAAW,EAEjGI,EAAAA,GAAG,SAAUN,CAAI,GAAKM,EAAAA,GAAG,SAAUN,CAAI,EAElCO,aAAWP,EAAMC,CAAK,GAAKC,EAG7B,OAAO,OAAOF,CAA+B,EAAE,KAAMQ,GACtDF,KAAG,MAAOE,CAAK,EAAU,GAEzBF,EAAAA,GAAG,QAASE,CAAK,EACZA,EAAM,KAAMC,GAAOH,EAAAA,GAAG,SAAUG,CAAC,EAAIV,EAAKU,EAAGR,EAAOC,CAAI,EAAIK,EAAAA,WAAWE,EAAGR,CAAK,GAAKC,CAAK,EAG9FI,EAAAA,GAAG,SAAUE,CAAK,EACbT,EAAKS,EAAOP,EAAOC,CAAI,EAGzBK,aAAWC,EAAOP,CAAK,GAAKC,CACpC,CACH"}
@@ -0,0 +1,11 @@
1
+ import { assert as p } from "../function/assert.js";
2
+ import { similarity as o } from "../string/similarity.js";
3
+ import { is as s } from "../typed/is.js";
4
+ import { IS_WITHIN_ERROR_MSG as b, isWithin as c } from "../typed/isWithin.js";
5
+ function n(t, m, r = 1) {
6
+ return p(c(r, 0, 1), b, { args: { max: 1, min: 0, tone: r }, type: TypeError }), s("string", t) || s("number", t) ? o(t, m) >= r : Object.values(t).some((i) => s("nil", i) ? !1 : s("array", i) ? i.some((f) => s("object", f) ? n(f, m, r) : o(f, m) >= r) : s("object", i) ? n(i, m, r) : o(i, m) >= r);
7
+ }
8
+ export {
9
+ n as seek
10
+ };
11
+ //# sourceMappingURL=seek.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seek.js","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n return Object.values(item as Record<string, unknown>).some((value) => {\n if (is('nil', value)) return false;\n\n if (is('array', value)) {\n return value.some((v) => (is('object', v) ? seek(v, query, tone) : similarity(v, query) >= tone));\n }\n\n if (is('object', value)) {\n return seek(value, query, tone);\n }\n\n return similarity(value, query) >= tone;\n });\n}\n"],"names":["seek","item","query","tone","assert","isWithin","IS_WITHIN_ERROR_MSG","is","similarity","value","v"],"mappings":";;;;AA6BO,SAASA,EAAQC,GAASC,GAAeC,IAAO,GAAY;AAGjE,SAFAC,EAAOC,EAASF,GAAM,GAAG,CAAC,GAAGG,GAAqB,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAAH,KAAQ,MAAM,WAAW,GAEjGI,EAAG,UAAUN,CAAI,KAAKM,EAAG,UAAUN,CAAI,IAElCO,EAAWP,GAAMC,CAAK,KAAKC,IAG7B,OAAO,OAAOF,CAA+B,EAAE,KAAK,CAACQ,MACtDF,EAAG,OAAOE,CAAK,IAAU,KAEzBF,EAAG,SAASE,CAAK,IACZA,EAAM,KAAK,CAACC,MAAOH,EAAG,UAAUG,CAAC,IAAIV,EAAKU,GAAGR,GAAOC,CAAI,IAAIK,EAAWE,GAAGR,CAAK,KAAKC,CAAK,IAG9FI,EAAG,UAAUE,CAAK,IACbT,EAAKS,GAAOP,GAAOC,CAAI,IAGzBK,EAAWC,GAAOP,CAAK,KAAKC,CACpC;AACH;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../function/assert.cjs"),r=require("../typed/isObject.cjs");function t(e){return s.assert(r.isObject(e),r.IS_OBJECT_ERROR_MSG,{args:{item:e},type:TypeError}),Object.values(e)}exports.values=t;
2
+ //# sourceMappingURL=values.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.cjs","sources":["../../src/object/values.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Returns an array of values for an object's properties\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n * toValues(obj); // [1, 2, 3]\n * ```\n *\n * @param item - The object whose property values are to be returned.\n *\n * @returns an array of the object's own enumerable string-keyed property values.\n */\nexport function values<T extends Obj, K extends keyof T>(item: T) {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.values(item) as T[K][];\n}\n"],"names":["values","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":"6JAiBO,SAASA,EAAyCC,EAAS,CAChEC,OAAAA,EAAAA,OAAOC,EAAAA,SAASF,CAAI,EAAGG,sBAAqB,CAAE,KAAM,CAAE,KAAAH,CAAA,EAAQ,KAAM,UAAW,EAExE,OAAO,OAAOA,CAAI,CAC3B"}
@@ -0,0 +1,9 @@
1
+ import { assert as e } from "../function/assert.js";
2
+ import { IS_OBJECT_ERROR_MSG as o, isObject as t } from "../typed/isObject.js";
3
+ function a(r) {
4
+ return e(t(r), o, { args: { item: r }, type: TypeError }), Object.values(r);
5
+ }
6
+ export {
7
+ a as values
8
+ };
9
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sources":["../../src/object/values.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_OBJECT_ERROR_MSG, isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\n/**\n * Returns an array of values for an object's properties\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: 2, c: 3 };\n * toValues(obj); // [1, 2, 3]\n * ```\n *\n * @param item - The object whose property values are to be returned.\n *\n * @returns an array of the object's own enumerable string-keyed property values.\n */\nexport function values<T extends Obj, K extends keyof T>(item: T) {\n assert(isObject(item), IS_OBJECT_ERROR_MSG, { args: { item }, type: TypeError });\n\n return Object.values(item) as T[K][];\n}\n"],"names":["values","item","assert","isObject","IS_OBJECT_ERROR_MSG"],"mappings":";;AAiBO,SAASA,EAAyCC,GAAS;AAChE,SAAAC,EAAOC,EAASF,CAAI,GAAGG,GAAqB,EAAE,MAAM,EAAE,MAAAH,EAAA,GAAQ,MAAM,WAAW,GAExE,OAAO,OAAOA,CAAI;AAC3B;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../function/assert.cjs"),r=require("../typed/isArray.cjs"),s=require("./random.cjs"),n=e=>{if(t.assert(r.isArray(e),r.IS_ARRAY_ERROR_MSG,{args:{array:e},type:TypeError}),e.length!==0)return e[s.random(0,e.length-1)]};exports.draw=n;
2
+ //# sourceMappingURL=draw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw.cjs","sources":["../../src/random/draw.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { random } from './random';\n\n/**\n * “Draw” a random item from an array.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]) // 3\n * ```\n *\n * @param array - The array to draw from.\n *\n * @returns A random item from the array or `undefined` if the array is empty.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport const draw = <T>(array: T[]): T | undefined => {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1)];\n};\n"],"names":["draw","array","assert","isArray","IS_ARRAY_ERROR_MSG","random"],"mappings":"sLAkBaA,EAAWC,GAA8B,CAGpD,GAFAC,EAAAA,OAAOC,EAAAA,QAAQF,CAAK,EAAGG,qBAAoB,CAAE,KAAM,CAAE,MAAAH,CAAA,EAAS,KAAM,UAAW,EAE3EA,EAAM,SAAW,EAErB,OAAOA,EAAMI,EAAAA,OAAO,EAAGJ,EAAM,OAAS,CAAC,CAAC,CAC1C"}
@@ -0,0 +1,11 @@
1
+ import { assert as o } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as t, isArray as e } from "../typed/isArray.js";
3
+ import { random as m } from "./random.js";
4
+ const s = (r) => {
5
+ if (o(e(r), t, { args: { array: r }, type: TypeError }), r.length !== 0)
6
+ return r[m(0, r.length - 1)];
7
+ };
8
+ export {
9
+ s as draw
10
+ };
11
+ //# sourceMappingURL=draw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw.js","sources":["../../src/random/draw.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { random } from './random';\n\n/**\n * “Draw” a random item from an array.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]) // 3\n * ```\n *\n * @param array - The array to draw from.\n *\n * @returns A random item from the array or `undefined` if the array is empty.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport const draw = <T>(array: T[]): T | undefined => {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1)];\n};\n"],"names":["draw","array","assert","isArray","IS_ARRAY_ERROR_MSG","random"],"mappings":";;;AAkBO,MAAMA,IAAO,CAAIC,MAA8B;AAGpD,MAFAC,EAAOC,EAAQF,CAAK,GAAGG,GAAoB,EAAE,MAAM,EAAE,OAAAH,EAAA,GAAS,MAAM,WAAW,GAE3EA,EAAM,WAAW;AAErB,WAAOA,EAAMI,EAAO,GAAGJ,EAAM,SAAS,CAAC,CAAC;AAC1C;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../function/assert.cjs");function o(r,e){a.assert(r<=e,"Minimum value must be less than maximum value",{args:{max:e,min:r},type:RangeError});const t=crypto?crypto.getRandomValues(new Uint32Array(1))[0]/4294967295:Math.random();return Math.floor(t*(e-r+1))+r}exports.random=o;
2
+ //# sourceMappingURL=random.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.cjs","sources":["../../src/random/random.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number): number {\n assert(min <= max, 'Minimum value must be less than maximum value', { args: { max, min }, type: RangeError });\n\n const randomValue = crypto ? crypto.getRandomValues(new Uint32Array(1))[0] / 0xffffffff : Math.random();\n\n return Math.floor(randomValue * (max - min + 1)) + min;\n}\n"],"names":["random","min","max","assert","randomValue"],"mappings":"0HAcO,SAASA,EAAOC,EAAaC,EAAqB,CACvDC,EAAAA,OAAOF,GAAOC,EAAK,gDAAiD,CAAE,KAAM,CAAE,IAAAA,EAAK,IAAAD,CAAA,EAAO,KAAM,UAAA,CAAY,EAE5G,MAAMG,EAAc,OAAS,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,EAAI,WAAa,KAAK,OAAA,EAE/F,OAAO,KAAK,MAAMA,GAAeF,EAAMD,EAAM,EAAE,EAAIA,CACrD"}
@@ -0,0 +1,10 @@
1
+ import { assert as o } from "../function/assert.js";
2
+ function n(r, t) {
3
+ o(r <= t, "Minimum value must be less than maximum value", { args: { max: t, min: r }, type: RangeError });
4
+ const a = crypto ? crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295 : Math.random();
5
+ return Math.floor(a * (t - r + 1)) + r;
6
+ }
7
+ export {
8
+ n as random
9
+ };
10
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sources":["../../src/random/random.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number): number {\n assert(min <= max, 'Minimum value must be less than maximum value', { args: { max, min }, type: RangeError });\n\n const randomValue = crypto ? crypto.getRandomValues(new Uint32Array(1))[0] / 0xffffffff : Math.random();\n\n return Math.floor(randomValue * (max - min + 1)) + min;\n}\n"],"names":["random","min","max","assert","randomValue"],"mappings":";AAcO,SAASA,EAAOC,GAAaC,GAAqB;AACvD,EAAAC,EAAOF,KAAOC,GAAK,iDAAiD,EAAE,MAAM,EAAE,KAAAA,GAAK,KAAAD,EAAA,GAAO,MAAM,WAAA,CAAY;AAE5G,QAAMG,IAAc,SAAS,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,aAAa,KAAK,OAAA;AAE/F,SAAO,KAAK,MAAMA,KAAeF,IAAMD,IAAM,EAAE,IAAIA;AACrD;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../function/assert.cjs"),o=require("../typed/isArray.cjs");function u(t){n.assert(o.isArray(t),o.IS_ARRAY_ERROR_MSG,{args:{array:t},type:TypeError});const e=[...t];for(let r=e.length-1;r>0;r--){const s=Math.floor(Math.random()*(r+1));[e[r],e[s]]=[e[s],e[r]]}return e}exports.shuffle=u;
2
+ //# sourceMappingURL=shuffle.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shuffle.cjs","sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Shuffles an array randomly.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // a shuffled version of the array\n * ```\n *\n * @param array - The array to shuffle.\n *\n * @returns A new shuffled array.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function shuffle<T>(array: T[]): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"names":["shuffle","array","assert","isArray","IS_ARRAY_ERROR_MSG","result","i","j"],"mappings":"4JAkBO,SAASA,EAAWC,EAAiB,CAC1CC,EAAAA,OAAOC,EAAAA,QAAQF,CAAK,EAAGG,qBAAoB,CAAE,KAAM,CAAE,MAAAH,CAAA,EAAS,KAAM,UAAW,EAE/E,MAAMI,EAAS,CAAC,GAAGJ,CAAK,EAExB,QAASK,EAAID,EAAO,OAAS,EAAGC,EAAI,EAAGA,IAAK,CAC1C,MAAMC,EAAI,KAAK,MAAM,KAAK,UAAYD,EAAI,EAAE,EAC5C,CAACD,EAAOC,CAAC,EAAGD,EAAOE,CAAC,CAAC,EAAI,CAACF,EAAOE,CAAC,EAAGF,EAAOC,CAAC,CAAC,CAChD,CAEA,OAAOD,CACT"}
@@ -0,0 +1,15 @@
1
+ import { assert as s } from "../function/assert.js";
2
+ import { IS_ARRAY_ERROR_MSG as f, isArray as n } from "../typed/isArray.js";
3
+ function m(o) {
4
+ s(n(o), f, { args: { array: o }, type: TypeError });
5
+ const r = [...o];
6
+ for (let t = r.length - 1; t > 0; t--) {
7
+ const e = Math.floor(Math.random() * (t + 1));
8
+ [r[t], r[e]] = [r[e], r[t]];
9
+ }
10
+ return r;
11
+ }
12
+ export {
13
+ m as shuffle
14
+ };
15
+ //# sourceMappingURL=shuffle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shuffle.js","sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Shuffles an array randomly.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // a shuffled version of the array\n * ```\n *\n * @param array - The array to shuffle.\n *\n * @returns A new shuffled array.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function shuffle<T>(array: T[]): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"names":["shuffle","array","assert","isArray","IS_ARRAY_ERROR_MSG","result","i","j"],"mappings":";;AAkBO,SAASA,EAAWC,GAAiB;AAC1C,EAAAC,EAAOC,EAAQF,CAAK,GAAGG,GAAoB,EAAE,MAAM,EAAE,OAAAH,EAAA,GAAS,MAAM,WAAW;AAE/E,QAAMI,IAAS,CAAC,GAAGJ,CAAK;AAExB,WAASK,IAAID,EAAO,SAAS,GAAGC,IAAI,GAAGA,KAAK;AAC1C,UAAMC,IAAI,KAAK,MAAM,KAAK,YAAYD,IAAI,EAAE;AAC5C,KAACD,EAAOC,CAAC,GAAGD,EAAOE,CAAC,CAAC,IAAI,CAACF,EAAOE,CAAC,GAAGF,EAAOC,CAAC,CAAC;AAAA,EAChD;AAEA,SAAOD;AACT;"}