@vielzeug/arsenal 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +5 -18
  2. package/dist/array/chunk.cjs.map +1 -1
  3. package/dist/array/chunk.d.ts +1 -1
  4. package/dist/array/chunk.d.ts.map +1 -1
  5. package/dist/array/chunk.js.map +1 -1
  6. package/dist/array/compact.cjs.map +1 -1
  7. package/dist/array/compact.d.ts +1 -1
  8. package/dist/array/compact.d.ts.map +1 -1
  9. package/dist/array/compact.js.map +1 -1
  10. package/dist/array/contains.cjs.map +1 -1
  11. package/dist/array/contains.d.ts +1 -1
  12. package/dist/array/contains.d.ts.map +1 -1
  13. package/dist/array/contains.js.map +1 -1
  14. package/dist/array/countBy.cjs.map +1 -1
  15. package/dist/array/countBy.d.ts +1 -1
  16. package/dist/array/countBy.d.ts.map +1 -1
  17. package/dist/array/countBy.js.map +1 -1
  18. package/dist/array/difference.cjs.map +1 -1
  19. package/dist/array/difference.d.ts +4 -2
  20. package/dist/array/difference.d.ts.map +1 -1
  21. package/dist/array/difference.js.map +1 -1
  22. package/dist/array/drop.cjs.map +1 -1
  23. package/dist/array/drop.d.ts +1 -1
  24. package/dist/array/drop.d.ts.map +1 -1
  25. package/dist/array/drop.js.map +1 -1
  26. package/dist/array/dropLast.cjs.map +1 -1
  27. package/dist/array/dropLast.d.ts +1 -1
  28. package/dist/array/dropLast.d.ts.map +1 -1
  29. package/dist/array/dropLast.js.map +1 -1
  30. package/dist/array/filterMap.cjs.map +1 -1
  31. package/dist/array/filterMap.d.ts +3 -1
  32. package/dist/array/filterMap.d.ts.map +1 -1
  33. package/dist/array/filterMap.js.map +1 -1
  34. package/dist/array/first.cjs.map +1 -1
  35. package/dist/array/first.d.ts +1 -1
  36. package/dist/array/first.d.ts.map +1 -1
  37. package/dist/array/first.js.map +1 -1
  38. package/dist/array/groupBy.cjs.map +1 -1
  39. package/dist/array/groupBy.d.ts +1 -1
  40. package/dist/array/groupBy.d.ts.map +1 -1
  41. package/dist/array/groupBy.js.map +1 -1
  42. package/dist/array/index.cjs +1 -1
  43. package/dist/array/index.d.ts +0 -1
  44. package/dist/array/index.d.ts.map +1 -1
  45. package/dist/array/index.js +17 -18
  46. package/dist/array/indexBy.cjs.map +1 -1
  47. package/dist/array/indexBy.d.ts +1 -1
  48. package/dist/array/indexBy.d.ts.map +1 -1
  49. package/dist/array/indexBy.js.map +1 -1
  50. package/dist/array/intersection.cjs.map +1 -1
  51. package/dist/array/intersection.d.ts +4 -2
  52. package/dist/array/intersection.d.ts.map +1 -1
  53. package/dist/array/intersection.js.map +1 -1
  54. package/dist/array/last.cjs.map +1 -1
  55. package/dist/array/last.d.ts +1 -1
  56. package/dist/array/last.d.ts.map +1 -1
  57. package/dist/array/last.js.map +1 -1
  58. package/dist/array/partition.cjs.map +1 -1
  59. package/dist/array/partition.d.ts +3 -1
  60. package/dist/array/partition.d.ts.map +1 -1
  61. package/dist/array/partition.js.map +1 -1
  62. package/dist/array/replace.cjs.map +1 -1
  63. package/dist/array/replace.d.ts +2 -15
  64. package/dist/array/replace.d.ts.map +1 -1
  65. package/dist/array/replace.js.map +1 -1
  66. package/dist/array/rotate.cjs.map +1 -1
  67. package/dist/array/rotate.d.ts +5 -17
  68. package/dist/array/rotate.d.ts.map +1 -1
  69. package/dist/array/rotate.js.map +1 -1
  70. package/dist/array/sort.cjs.map +1 -1
  71. package/dist/array/sort.d.ts +2 -2
  72. package/dist/array/sort.d.ts.map +1 -1
  73. package/dist/array/sort.js.map +1 -1
  74. package/dist/array/take.cjs.map +1 -1
  75. package/dist/array/take.d.ts +1 -1
  76. package/dist/array/take.d.ts.map +1 -1
  77. package/dist/array/take.js.map +1 -1
  78. package/dist/array/takeLast.cjs.map +1 -1
  79. package/dist/array/takeLast.d.ts +1 -1
  80. package/dist/array/takeLast.d.ts.map +1 -1
  81. package/dist/array/takeLast.js.map +1 -1
  82. package/dist/array/toggle.cjs.map +1 -1
  83. package/dist/array/toggle.d.ts +1 -1
  84. package/dist/array/toggle.d.ts.map +1 -1
  85. package/dist/array/toggle.js.map +1 -1
  86. package/dist/array/union.cjs.map +1 -1
  87. package/dist/array/union.d.ts +4 -2
  88. package/dist/array/union.d.ts.map +1 -1
  89. package/dist/array/union.js.map +1 -1
  90. package/dist/array/uniq.cjs.map +1 -1
  91. package/dist/array/uniq.d.ts +1 -1
  92. package/dist/array/uniq.d.ts.map +1 -1
  93. package/dist/array/uniq.js.map +1 -1
  94. package/dist/array/zip.cjs.map +1 -1
  95. package/dist/array/zip.d.ts +1 -1
  96. package/dist/array/zip.d.ts.map +1 -1
  97. package/dist/array/zip.js.map +1 -1
  98. package/dist/arsenal.cjs +1 -1
  99. package/dist/arsenal.cjs.map +1 -1
  100. package/dist/arsenal.iife.js +1 -1
  101. package/dist/arsenal.iife.js.map +1 -1
  102. package/dist/arsenal.js +1 -1
  103. package/dist/arsenal.js.map +1 -1
  104. package/dist/async/abortError.cjs +1 -1
  105. package/dist/async/abortError.cjs.map +1 -1
  106. package/dist/async/abortError.d.ts +3 -2
  107. package/dist/async/abortError.d.ts.map +1 -1
  108. package/dist/async/abortError.js +2 -2
  109. package/dist/async/abortError.js.map +1 -1
  110. package/dist/async/abortable.cjs +2 -0
  111. package/dist/async/abortable.cjs.map +1 -0
  112. package/dist/async/abortable.d.ts +26 -0
  113. package/dist/async/abortable.d.ts.map +1 -0
  114. package/dist/async/abortable.js +12 -0
  115. package/dist/async/abortable.js.map +1 -0
  116. package/dist/async/backoff.cjs +1 -1
  117. package/dist/async/backoff.cjs.map +1 -1
  118. package/dist/async/backoff.js +1 -2
  119. package/dist/async/backoff.js.map +1 -1
  120. package/dist/async/index.cjs +1 -1
  121. package/dist/async/index.d.ts +1 -0
  122. package/dist/async/index.d.ts.map +1 -1
  123. package/dist/async/index.js +9 -8
  124. package/dist/async/taskPool.cjs.map +1 -1
  125. package/dist/async/taskPool.d.ts +4 -4
  126. package/dist/async/taskPool.d.ts.map +1 -1
  127. package/dist/async/taskPool.js.map +1 -1
  128. package/dist/cache/cache.cjs +1 -1
  129. package/dist/cache/cache.cjs.map +1 -1
  130. package/dist/cache/cache.d.ts +1 -0
  131. package/dist/cache/cache.d.ts.map +1 -1
  132. package/dist/cache/cache.js +2 -1
  133. package/dist/cache/cache.js.map +1 -1
  134. package/dist/cache/memo.cjs.map +1 -1
  135. package/dist/cache/memo.d.ts.map +1 -1
  136. package/dist/cache/memo.js.map +1 -1
  137. package/dist/errors.cjs +1 -1
  138. package/dist/errors.cjs.map +1 -1
  139. package/dist/errors.d.ts +0 -1
  140. package/dist/errors.d.ts.map +1 -1
  141. package/dist/errors.js +1 -4
  142. package/dist/errors.js.map +1 -1
  143. package/dist/function/assert.cjs.map +1 -1
  144. package/dist/function/assert.d.ts +1 -1
  145. package/dist/function/assert.js.map +1 -1
  146. package/dist/function/debounce.cjs.map +1 -1
  147. package/dist/function/debounce.d.ts.map +1 -1
  148. package/dist/function/debounce.js.map +1 -1
  149. package/dist/function/pipe.cjs +1 -1
  150. package/dist/function/pipe.cjs.map +1 -1
  151. package/dist/function/pipe.js +1 -1
  152. package/dist/function/pipe.js.map +1 -1
  153. package/dist/function/runAll.cjs +1 -1
  154. package/dist/function/runAll.cjs.map +1 -1
  155. package/dist/function/runAll.js +1 -1
  156. package/dist/function/runAll.js.map +1 -1
  157. package/dist/guards/index.cjs +1 -1
  158. package/dist/guards/index.js +7 -7
  159. package/dist/guards/isEmpty.cjs +1 -1
  160. package/dist/guards/isEmpty.cjs.map +1 -1
  161. package/dist/guards/isEmpty.d.ts.map +1 -1
  162. package/dist/guards/isEmpty.js +4 -5
  163. package/dist/guards/isEmpty.js.map +1 -1
  164. package/dist/guards/isFunction.cjs.map +1 -1
  165. package/dist/guards/isFunction.d.ts +1 -1
  166. package/dist/guards/isFunction.d.ts.map +1 -1
  167. package/dist/guards/isFunction.js.map +1 -1
  168. package/dist/guards/isPrimitive.cjs +1 -1
  169. package/dist/guards/isPrimitive.cjs.map +1 -1
  170. package/dist/guards/isPrimitive.d.ts +4 -17
  171. package/dist/guards/isPrimitive.d.ts.map +1 -1
  172. package/dist/guards/isPrimitive.js +1 -2
  173. package/dist/guards/isPrimitive.js.map +1 -1
  174. package/dist/index.cjs +1 -1
  175. package/dist/index.d.ts +7 -2
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +27 -22
  178. package/dist/math/average.cjs +1 -1
  179. package/dist/math/average.cjs.map +1 -1
  180. package/dist/math/average.d.ts +3 -2
  181. package/dist/math/average.d.ts.map +1 -1
  182. package/dist/math/average.js +1 -6
  183. package/dist/math/average.js.map +1 -1
  184. package/dist/math/gcd.cjs +1 -1
  185. package/dist/math/gcd.cjs.map +1 -1
  186. package/dist/math/gcd.d.ts.map +1 -1
  187. package/dist/math/gcd.js +1 -0
  188. package/dist/math/gcd.js.map +1 -1
  189. package/dist/math/index.cjs +1 -1
  190. package/dist/math/index.d.ts +0 -1
  191. package/dist/math/index.d.ts.map +1 -1
  192. package/dist/math/index.js +7 -8
  193. package/dist/math/lcm.cjs +1 -1
  194. package/dist/math/lcm.cjs.map +1 -1
  195. package/dist/math/lcm.d.ts.map +1 -1
  196. package/dist/math/lcm.js +5 -1
  197. package/dist/math/lcm.js.map +1 -1
  198. package/dist/math/linspace.cjs +1 -1
  199. package/dist/math/linspace.cjs.map +1 -1
  200. package/dist/math/linspace.d.ts.map +1 -1
  201. package/dist/math/linspace.js +2 -1
  202. package/dist/math/linspace.js.map +1 -1
  203. package/dist/math/median.cjs.map +1 -1
  204. package/dist/math/median.d.ts +1 -1
  205. package/dist/math/median.d.ts.map +1 -1
  206. package/dist/math/median.js.map +1 -1
  207. package/dist/math/standardDeviation.cjs.map +1 -1
  208. package/dist/math/standardDeviation.d.ts +1 -1
  209. package/dist/math/standardDeviation.d.ts.map +1 -1
  210. package/dist/math/standardDeviation.js.map +1 -1
  211. package/dist/math/sum.cjs +1 -1
  212. package/dist/math/sum.cjs.map +1 -1
  213. package/dist/math/sum.d.ts +1 -1
  214. package/dist/math/sum.d.ts.map +1 -1
  215. package/dist/math/sum.js +1 -1
  216. package/dist/math/sum.js.map +1 -1
  217. package/dist/math/variance.cjs.map +1 -1
  218. package/dist/math/variance.d.ts +1 -1
  219. package/dist/math/variance.d.ts.map +1 -1
  220. package/dist/math/variance.js.map +1 -1
  221. package/dist/object/defaults.cjs.map +1 -1
  222. package/dist/object/defaults.d.ts.map +1 -1
  223. package/dist/object/defaults.js.map +1 -1
  224. package/dist/object/diff.cjs.map +1 -1
  225. package/dist/object/diff.d.ts +1 -1
  226. package/dist/object/diff.d.ts.map +1 -1
  227. package/dist/object/diff.js.map +1 -1
  228. package/dist/object/filterValues.cjs.map +1 -1
  229. package/dist/object/filterValues.d.ts.map +1 -1
  230. package/dist/object/filterValues.js.map +1 -1
  231. package/dist/object/getPath.cjs.map +1 -1
  232. package/dist/object/getPath.d.ts.map +1 -1
  233. package/dist/object/getPath.js.map +1 -1
  234. package/dist/object/mapKeys.cjs.map +1 -1
  235. package/dist/object/mapKeys.d.ts.map +1 -1
  236. package/dist/object/mapKeys.js.map +1 -1
  237. package/dist/object/mapValues.cjs.map +1 -1
  238. package/dist/object/mapValues.d.ts.map +1 -1
  239. package/dist/object/mapValues.js.map +1 -1
  240. package/dist/object/merge.cjs.map +1 -1
  241. package/dist/object/merge.d.ts.map +1 -1
  242. package/dist/object/merge.js.map +1 -1
  243. package/dist/object/omit.cjs.map +1 -1
  244. package/dist/object/omit.d.ts.map +1 -1
  245. package/dist/object/omit.js.map +1 -1
  246. package/dist/object/pick.cjs.map +1 -1
  247. package/dist/object/pick.d.ts.map +1 -1
  248. package/dist/object/pick.js.map +1 -1
  249. package/dist/object/prune.cjs +1 -1
  250. package/dist/object/prune.cjs.map +1 -1
  251. package/dist/object/prune.d.ts.map +1 -1
  252. package/dist/object/prune.js +16 -17
  253. package/dist/object/prune.js.map +1 -1
  254. package/dist/random/_index.cjs +1 -1
  255. package/dist/random/_index.cjs.map +1 -1
  256. package/dist/random/_index.d.ts +1 -1
  257. package/dist/random/_index.d.ts.map +1 -1
  258. package/dist/random/_index.js +4 -5
  259. package/dist/random/_index.js.map +1 -1
  260. package/dist/random/draw.cjs.map +1 -1
  261. package/dist/random/draw.d.ts.map +1 -1
  262. package/dist/random/draw.js.map +1 -1
  263. package/dist/random/index.cjs +1 -1
  264. package/dist/random/index.d.ts +0 -1
  265. package/dist/random/index.d.ts.map +1 -1
  266. package/dist/random/index.js +2 -2
  267. package/dist/random/random.cjs.map +1 -1
  268. package/dist/random/random.d.ts.map +1 -1
  269. package/dist/random/random.js.map +1 -1
  270. package/dist/random/shuffle.cjs.map +1 -1
  271. package/dist/random/shuffle.d.ts.map +1 -1
  272. package/dist/random/shuffle.js.map +1 -1
  273. package/dist/random/source.cjs +2 -0
  274. package/dist/random/source.cjs.map +1 -0
  275. package/dist/random/source.d.ts +2 -0
  276. package/dist/random/source.d.ts.map +1 -1
  277. package/dist/random/source.js +10 -0
  278. package/dist/random/source.js.map +1 -0
  279. package/dist/string/index.cjs +1 -1
  280. package/dist/string/index.d.ts +1 -1
  281. package/dist/string/index.d.ts.map +1 -1
  282. package/dist/string/index.js +2 -2
  283. package/dist/string/{pad.cjs → padCenter.cjs} +2 -2
  284. package/dist/string/padCenter.cjs.map +1 -0
  285. package/dist/string/padCenter.d.ts +3 -0
  286. package/dist/string/padCenter.d.ts.map +1 -0
  287. package/dist/string/{pad.js → padCenter.js} +3 -3
  288. package/dist/string/padCenter.js.map +1 -0
  289. package/package.json +32 -27
  290. package/dist/_common/_abortable.d.ts +0 -5
  291. package/dist/_common/_abortable.d.ts.map +0 -1
  292. package/dist/array/flatten.cjs +0 -2
  293. package/dist/array/flatten.cjs.map +0 -1
  294. package/dist/array/flatten.d.ts +0 -5
  295. package/dist/array/flatten.d.ts.map +0 -1
  296. package/dist/array/flatten.js +0 -11
  297. package/dist/array/flatten.js.map +0 -1
  298. package/dist/math/percent.cjs +0 -2
  299. package/dist/math/percent.cjs.map +0 -1
  300. package/dist/math/percent.d.ts +0 -19
  301. package/dist/math/percent.d.ts.map +0 -1
  302. package/dist/math/percent.js +0 -8
  303. package/dist/math/percent.js.map +0 -1
  304. package/dist/random/uuid.cjs +0 -2
  305. package/dist/random/uuid.cjs.map +0 -1
  306. package/dist/random/uuid.d.ts +0 -12
  307. package/dist/random/uuid.d.ts.map +0 -1
  308. package/dist/random/uuid.js +0 -8
  309. package/dist/random/uuid.js.map +0 -1
  310. package/dist/string/pad.cjs.map +0 -1
  311. package/dist/string/pad.d.ts +0 -5
  312. package/dist/string/pad.d.ts.map +0 -1
  313. package/dist/string/pad.js.map +0 -1
@@ -59,5 +59,5 @@ export type ArrayDiffOptions<T> = {
59
59
  * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.
60
60
  * @returns An object with `added` and `removed` arrays.
61
61
  */
62
- export declare function diffArrays<T>(before: T[], after: T[], options?: ArrayDiffOptions<T>): ArrayDiff<T>;
62
+ export declare function diffArrays<T>(before: readonly T[], after: readonly T[], options?: ArrayDiffOptions<T>): ArrayDiff<T>;
63
63
  //# sourceMappingURL=diff.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/object/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAKpC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI;IACtC,mDAAmD;IACnD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAC/B,wFAAwF;IACxF,OAAO,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KAAE,CAAC;IAC5D,mDAAmD;IACnD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAChC,MAAM,GAAE,CAAW,EACnB,KAAK,GAAE,CAAW,EAClB,SAAS,GAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAiB,GACvD,UAAU,CAAC,CAAC,CAAC,CAuBf;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAOlG"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/object/diff.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI;IACtC,mDAAmD;IACnD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IAC/B,wFAAwF;IACxF,OAAO,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KAAE,CAAC;IAC5D,mDAAmD;IACnD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAChC,MAAM,GAAE,CAAW,EACnB,KAAK,GAAE,CAAW,EAClB,SAAS,GAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAiB,GACvD,UAAU,CAAC,CAAC,CAAC,CAuBf;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAOpH"}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","names":[],"sources":["../../src/object/diff.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isEqual } from '../guards/isEqual';\n\nexport type DiffResult<T extends Obj> = {\n /** Keys present in `after` but not in `before`. */\n added: Array<keyof T & string>;\n /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */\n changed: { [K in keyof T]?: { after: T[K]; before: T[K] } };\n /** Keys present in `before` but not in `after`. */\n removed: Array<keyof T & string>;\n};\n\n/**\n * Computes the structural difference between two plain objects.\n * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.\n *\n * @example\n * ```ts\n * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });\n * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }\n *\n * diff({ x: { n: 1 } }, { x: { n: 2 } });\n * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }\n * ```\n *\n * @param before - The original object.\n * @param after - The updated object.\n * @param compareFn - Custom equality function. Defaults to deep `isEqual`.\n */\nexport function diff<T extends Obj>(\n before: T = {} as T,\n after: T = {} as T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): DiffResult<T> {\n const added: Array<keyof T & string> = [];\n const removed: Array<keyof T & string> = [];\n const changed: Record<string, { after: unknown; before: unknown }> = {};\n\n const beforeKeys = new Set(Object.keys(before));\n const afterKeys = new Set(Object.keys(after));\n\n for (const key of afterKeys) {\n if (!beforeKeys.has(key)) {\n added.push(key as keyof T & string);\n } else if (!isUnsafeKey(key) && !compareFn(before[key], after[key])) {\n changed[key] = { after: after[key], before: before[key] };\n }\n }\n\n for (const key of beforeKeys) {\n if (!afterKeys.has(key)) {\n removed.push(key as keyof T & string);\n }\n }\n\n return { added, changed: changed as DiffResult<T>['changed'], removed };\n}\n\nexport type ArrayDiff<T> = {\n added: T[];\n removed: T[];\n};\n\nexport type ArrayDiffOptions<T> = {\n compareFn?: (a: T, b: T) => boolean;\n};\n\n/**\n * Computes the set-difference between two arrays.\n * Items present in `after` but not `before` are `added`.\n * Items present in `before` but not `after` are `removed`.\n * Order-independent; uses deep equality by default.\n *\n * @example\n * ```ts\n * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }\n * diffArrays(\n * [{ id: 1 }, { id: 2 }],\n * [{ id: 2 }, { id: 3 }],\n * { compareFn: (a, b) => a.id === b.id },\n * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }\n * ```\n *\n * @param before - The original array.\n * @param after - The updated array.\n * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.\n * @returns An object with `added` and `removed` arrays.\n */\nexport function diffArrays<T>(before: T[], after: T[], options?: ArrayDiffOptions<T>): ArrayDiff<T> {\n const compareFn = options?.compareFn ?? ((a: T, b: T) => isEqual(a, b));\n\n return {\n added: after.filter((item) => !before.some((b) => compareFn(b, item))),\n removed: before.filter((item) => !after.some((a) => compareFn(item, a))),\n };\n}\n"],"mappings":";;;AAgCA,SAAgB,EACd,IAAY,CAAC,GACb,IAAW,CAAC,GACZ,IAAiD,GAClC;CACf,IAAM,IAAiC,CAAC,GAClC,IAAmC,CAAC,GACpC,IAA+D,CAAC,GAEhE,IAAa,IAAI,IAAI,OAAO,KAAK,CAAM,CAAC,GACxC,IAAY,IAAI,IAAI,OAAO,KAAK,CAAK,CAAC;CAE5C,KAAK,IAAM,KAAO,GAChB,AAAK,EAAW,IAAI,CAAG,IAEZ,CAAC,EAAY,CAAG,KAAK,CAAC,EAAU,EAAO,IAAM,EAAM,EAAI,MAChE,EAAQ,KAAO;EAAE,OAAO,EAAM;EAAM,QAAQ,EAAO;CAAK,KAFxD,EAAM,KAAK,CAAuB;CAMtC,KAAK,IAAM,KAAO,GAChB,AAAK,EAAU,IAAI,CAAG,KACpB,EAAQ,KAAK,CAAuB;CAIxC,OAAO;EAAE;EAAgB;EAAqC;CAAQ;AACxE;AAgCA,SAAgB,EAAc,GAAa,GAAY,GAA6C;CAClG,IAAM,IAAY,GAAS,eAAe,GAAM,MAAS,EAAQ,GAAG,CAAC;CAErE,OAAO;EACL,OAAO,EAAM,QAAQ,MAAS,CAAC,EAAO,MAAM,MAAM,EAAU,GAAG,CAAI,CAAC,CAAC;EACrE,SAAS,EAAO,QAAQ,MAAS,CAAC,EAAM,MAAM,MAAM,EAAU,GAAM,CAAC,CAAC,CAAC;CACzE;AACF"}
1
+ {"version":3,"file":"diff.js","names":[],"sources":["../../src/object/diff.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isEqual } from '../guards/isEqual';\nimport type { Obj } from '../types';\n\nexport type DiffResult<T extends Obj> = {\n /** Keys present in `after` but not in `before`. */\n added: Array<keyof T & string>;\n /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */\n changed: { [K in keyof T]?: { after: T[K]; before: T[K] } };\n /** Keys present in `before` but not in `after`. */\n removed: Array<keyof T & string>;\n};\n\n/**\n * Computes the structural difference between two plain objects.\n * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.\n *\n * @example\n * ```ts\n * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });\n * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }\n *\n * diff({ x: { n: 1 } }, { x: { n: 2 } });\n * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }\n * ```\n *\n * @param before - The original object.\n * @param after - The updated object.\n * @param compareFn - Custom equality function. Defaults to deep `isEqual`.\n */\nexport function diff<T extends Obj>(\n before: T = {} as T,\n after: T = {} as T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): DiffResult<T> {\n const added: Array<keyof T & string> = [];\n const removed: Array<keyof T & string> = [];\n const changed: Record<string, { after: unknown; before: unknown }> = {};\n\n const beforeKeys = new Set(Object.keys(before));\n const afterKeys = new Set(Object.keys(after));\n\n for (const key of afterKeys) {\n if (!beforeKeys.has(key)) {\n added.push(key as keyof T & string);\n } else if (!isUnsafeKey(key) && !compareFn(before[key], after[key])) {\n changed[key] = { after: after[key], before: before[key] };\n }\n }\n\n for (const key of beforeKeys) {\n if (!afterKeys.has(key)) {\n removed.push(key as keyof T & string);\n }\n }\n\n return { added, changed: changed as DiffResult<T>['changed'], removed };\n}\n\nexport type ArrayDiff<T> = {\n added: T[];\n removed: T[];\n};\n\nexport type ArrayDiffOptions<T> = {\n compareFn?: (a: T, b: T) => boolean;\n};\n\n/**\n * Computes the set-difference between two arrays.\n * Items present in `after` but not `before` are `added`.\n * Items present in `before` but not `after` are `removed`.\n * Order-independent; uses deep equality by default.\n *\n * @example\n * ```ts\n * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }\n * diffArrays(\n * [{ id: 1 }, { id: 2 }],\n * [{ id: 2 }, { id: 3 }],\n * { compareFn: (a, b) => a.id === b.id },\n * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }\n * ```\n *\n * @param before - The original array.\n * @param after - The updated array.\n * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.\n * @returns An object with `added` and `removed` arrays.\n */\nexport function diffArrays<T>(before: readonly T[], after: readonly T[], options?: ArrayDiffOptions<T>): ArrayDiff<T> {\n const compareFn = options?.compareFn ?? ((a: T, b: T) => isEqual(a, b));\n\n return {\n added: after.filter((item) => !before.some((b) => compareFn(b, item))),\n removed: before.filter((item) => !after.some((a) => compareFn(item, a))),\n };\n}\n"],"mappings":";;;AA+BA,SAAgB,EACd,IAAY,CAAC,GACb,IAAW,CAAC,GACZ,IAAiD,GAClC;CACf,IAAM,IAAiC,CAAC,GAClC,IAAmC,CAAC,GACpC,IAA+D,CAAC,GAEhE,IAAa,IAAI,IAAI,OAAO,KAAK,CAAM,CAAC,GACxC,IAAY,IAAI,IAAI,OAAO,KAAK,CAAK,CAAC;CAE5C,KAAK,IAAM,KAAO,GAChB,AAAK,EAAW,IAAI,CAAG,IAEZ,CAAC,EAAY,CAAG,KAAK,CAAC,EAAU,EAAO,IAAM,EAAM,EAAI,MAChE,EAAQ,KAAO;EAAE,OAAO,EAAM;EAAM,QAAQ,EAAO;CAAK,KAFxD,EAAM,KAAK,CAAuB;CAMtC,KAAK,IAAM,KAAO,GAChB,AAAK,EAAU,IAAI,CAAG,KACpB,EAAQ,KAAK,CAAuB;CAIxC,OAAO;EAAE;EAAgB;EAAqC;CAAQ;AACxE;AAgCA,SAAgB,EAAc,GAAsB,GAAqB,GAA6C;CACpH,IAAM,IAAY,GAAS,eAAe,GAAM,MAAS,EAAQ,GAAG,CAAC;CAErE,OAAO;EACL,OAAO,EAAM,QAAQ,MAAS,CAAC,EAAO,MAAM,MAAM,EAAU,GAAG,CAAI,CAAC,CAAC;EACrE,SAAS,EAAO,QAAQ,MAAS,CAAC,EAAM,MAAM,MAAM,EAAU,GAAM,CAAC,CAAC,CAAC;CACzE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterValues.cjs","names":[],"sources":["../../src/object/filterValues.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Filters object entries using a value predicate. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * filterValues({ a: 1, b: 2, c: 3 }, (value) => value > 1); // { b: 2, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param predicate - Returns `true` to keep an entry.\n * @returns A new object containing only entries for which `predicate` returned `true`.\n */\nexport function filterValues<T extends Obj>(\n obj: T,\n predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean,\n): Partial<T> {\n const out: Partial<T> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (predicate(obj[key], key, obj)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EACd,EACA,EACY,CACZ,IAAM,EAAkB,CAAC,EAEzB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,GAE9B,EAAU,EAAI,GAAM,EAAK,CAAG,IAC9B,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
1
+ {"version":3,"file":"filterValues.cjs","names":[],"sources":["../../src/object/filterValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Filters object entries using a value predicate. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * filterValues({ a: 1, b: 2, c: 3 }, (value) => value > 1); // { b: 2, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param predicate - Returns `true` to keep an entry.\n * @returns A new object containing only entries for which `predicate` returned `true`.\n */\nexport function filterValues<T extends Obj>(\n obj: T,\n predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean,\n): Partial<T> {\n const out: Partial<T> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (predicate(obj[key], key, obj)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,EACd,EACA,EACY,CACZ,IAAM,EAAkB,CAAC,EAEzB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,GAE9B,EAAU,EAAI,GAAM,EAAK,CAAG,IAC9B,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterValues.d.ts","sourceRoot":"","sources":["../../src/object/filterValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,GAAG,EACxC,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,GAC9D,OAAO,CAAC,CAAC,CAAC,CAYZ"}
1
+ {"version":3,"file":"filterValues.d.ts","sourceRoot":"","sources":["../../src/object/filterValues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,GAAG,EACxC,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,GAC9D,OAAO,CAAC,CAAC,CAAC,CAYZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"filterValues.js","names":[],"sources":["../../src/object/filterValues.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Filters object entries using a value predicate. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * filterValues({ a: 1, b: 2, c: 3 }, (value) => value > 1); // { b: 2, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param predicate - Returns `true` to keep an entry.\n * @returns A new object containing only entries for which `predicate` returned `true`.\n */\nexport function filterValues<T extends Obj>(\n obj: T,\n predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean,\n): Partial<T> {\n const out: Partial<T> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (predicate(obj[key], key, obj)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EACd,GACA,GACY;CACZ,IAAM,IAAkB,CAAC;CAEzB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,KAE9B,EAAU,EAAI,IAAM,GAAK,CAAG,MAC9B,EAAI,KAAO,EAAI;CAInB,OAAO;AACT"}
1
+ {"version":3,"file":"filterValues.js","names":[],"sources":["../../src/object/filterValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Filters object entries using a value predicate. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * filterValues({ a: 1, b: 2, c: 3 }, (value) => value > 1); // { b: 2, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param predicate - Returns `true` to keep an entry.\n * @returns A new object containing only entries for which `predicate` returned `true`.\n */\nexport function filterValues<T extends Obj>(\n obj: T,\n predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean,\n): Partial<T> {\n const out: Partial<T> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (predicate(obj[key], key, obj)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAgBA,SAAgB,EACd,GACA,GACY;CACZ,IAAM,IAAkB,CAAC;CAEzB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,KAE9B,EAAU,EAAI,IAAM,GAAK,CAAG,MAC9B,EAAI,KAAO,EAAI;CAInB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPath.cjs","names":[],"sources":["../../src/object/getPath.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { UNSAFE_PATH_SEGMENTS } from '../_common/unsafePaths';\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\nfunction pathSegments(path: string): string[] {\n return path\n .replace(/\\[(\\d+)\\]/g, '.$1')\n .replace(/^\\.|\\.$/g, '')\n .split('.')\n .filter(Boolean);\n}\n\nfunction readPath(item: Obj, path: string): unknown {\n let current: unknown = item;\n\n for (const segment of pathSegments(path)) {\n if (UNSAFE_PATH_SEGMENTS.has(segment) || current == null || typeof current !== 'object') return undefined;\n\n current = (current as Record<string, unknown>)[segment];\n\n if (current === undefined) return undefined;\n }\n\n return current;\n}\n\n/**\n * Retrieves a value at a dot-notation or numeric bracket-notation path.\n * Returns `undefined` when the path is missing or contains an unsafe segment.\n * Use `getPathOr` to supply a fallback or `requirePath` to throw on a missing path.\n */\nexport function getPath<T extends Obj, P extends string>(item: T, path: P): PathValue<T, P> | undefined {\n return readPath(item, path) as PathValue<T, P> | undefined;\n}\n\n/**\n * Retrieves a value at a path or returns `fallback` when the path is missing.\n */\nexport function getPathOr<T extends Obj, P extends string, F>(item: T, path: P, fallback: F): PathValue<T, P> | F {\n const value = readPath(item, path);\n\n return (value === undefined ? fallback : value) as PathValue<T, P> | F;\n}\n\n/**\n * Retrieves a value at a path or throws when the path is missing.\n */\nexport function requirePath<T extends Obj, P extends string>(item: T, path: P): Exclude<PathValue<T, P>, undefined> {\n const value = readPath(item, path);\n\n if (value === undefined) throw new TypeError(`Path does not exist: '${path}'`);\n\n return value as Exclude<PathValue<T, P>, undefined>;\n}\n"],"mappings":"8CAYA,SAAS,EAAa,EAAwB,CAC5C,OAAO,EACJ,QAAQ,aAAc,KAAK,CAAC,CAC5B,QAAQ,WAAY,EAAE,CAAC,CACvB,MAAM,GAAG,CAAC,CACV,OAAO,OAAO,CACnB,CAEA,SAAS,EAAS,EAAW,EAAuB,CAClD,IAAI,EAAmB,EAEvB,IAAK,IAAM,KAAW,EAAa,CAAI,EAKrC,GAJI,EAAA,qBAAqB,IAAI,CAAO,GAAwB,OAAO,GAAY,WAAtC,IAEzC,EAAW,EAAoC,GAE3C,IAAY,IAAA,IAAW,OAG7B,OAAO,CACT,CAOA,SAAgB,EAAyC,EAAS,EAAsC,CACtG,OAAO,EAAS,EAAM,CAAI,CAC5B,CAKA,SAAgB,EAA8C,EAAS,EAAS,EAAkC,CAChH,IAAM,EAAQ,EAAS,EAAM,CAAI,EAEjC,OAAQ,IAAU,IAAA,GAAY,EAAW,CAC3C,CAKA,SAAgB,EAA6C,EAAS,EAA8C,CAClH,IAAM,EAAQ,EAAS,EAAM,CAAI,EAEjC,GAAI,IAAU,IAAA,GAAW,MAAU,UAAU,yBAAyB,EAAK,EAAE,EAE7E,OAAO,CACT"}
1
+ {"version":3,"file":"getPath.cjs","names":[],"sources":["../../src/object/getPath.ts"],"sourcesContent":["import { UNSAFE_PATH_SEGMENTS } from '../_common/unsafePaths';\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\nfunction pathSegments(path: string): string[] {\n return path\n .replace(/\\[(\\d+)\\]/g, '.$1')\n .replace(/^\\.|\\.$/g, '')\n .split('.')\n .filter(Boolean);\n}\n\nfunction readPath(item: Obj, path: string): unknown {\n let current: unknown = item;\n\n for (const segment of pathSegments(path)) {\n if (UNSAFE_PATH_SEGMENTS.has(segment) || current == null || typeof current !== 'object') return undefined;\n\n current = (current as Record<string, unknown>)[segment];\n\n if (current === undefined) return undefined;\n }\n\n return current;\n}\n\n/**\n * Retrieves a value at a dot-notation or numeric bracket-notation path.\n * Returns `undefined` when the path is missing or contains an unsafe segment.\n * Use `getPathOr` to supply a fallback or `requirePath` to throw on a missing path.\n */\nexport function getPath<T extends Obj, P extends string>(item: T, path: P): PathValue<T, P> | undefined {\n return readPath(item, path) as PathValue<T, P> | undefined;\n}\n\n/**\n * Retrieves a value at a path or returns `fallback` when the path is missing.\n */\nexport function getPathOr<T extends Obj, P extends string, F>(item: T, path: P, fallback: F): PathValue<T, P> | F {\n const value = readPath(item, path);\n\n return (value === undefined ? fallback : value) as PathValue<T, P> | F;\n}\n\n/**\n * Retrieves a value at a path or throws when the path is missing.\n */\nexport function requirePath<T extends Obj, P extends string>(item: T, path: P): Exclude<PathValue<T, P>, undefined> {\n const value = readPath(item, path);\n\n if (value === undefined) throw new TypeError(`Path does not exist: '${path}'`);\n\n return value as Exclude<PathValue<T, P>, undefined>;\n}\n"],"mappings":"8CAWA,SAAS,EAAa,EAAwB,CAC5C,OAAO,EACJ,QAAQ,aAAc,KAAK,CAAC,CAC5B,QAAQ,WAAY,EAAE,CAAC,CACvB,MAAM,GAAG,CAAC,CACV,OAAO,OAAO,CACnB,CAEA,SAAS,EAAS,EAAW,EAAuB,CAClD,IAAI,EAAmB,EAEvB,IAAK,IAAM,KAAW,EAAa,CAAI,EAKrC,GAJI,EAAA,qBAAqB,IAAI,CAAO,GAAwB,OAAO,GAAY,WAAtC,IAEzC,EAAW,EAAoC,GAE3C,IAAY,IAAA,IAAW,OAG7B,OAAO,CACT,CAOA,SAAgB,EAAyC,EAAS,EAAsC,CACtG,OAAO,EAAS,EAAM,CAAI,CAC5B,CAKA,SAAgB,EAA8C,EAAS,EAAS,EAAkC,CAChH,IAAM,EAAQ,EAAS,EAAM,CAAI,EAEjC,OAAQ,IAAU,IAAA,GAAY,EAAW,CAC3C,CAKA,SAAgB,EAA6C,EAAS,EAA8C,CAClH,IAAM,EAAQ,EAAS,EAAM,CAAI,EAEjC,GAAI,IAAU,IAAA,GAAW,MAAU,UAAU,yBAAyB,EAAK,EAAE,EAE7E,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPath.d.ts","sourceRoot":"","sources":["../../src/object/getPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,MAAM,IAAI,EAAE,GACxE,GAAG,SAAS,MAAM,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GACvB,SAAS,GACX,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,SAAS,CAAC;AAwBhB;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAEtG;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAIhH;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAMlH"}
1
+ {"version":3,"file":"getPath.d.ts","sourceRoot":"","sources":["../../src/object/getPath.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,IAAI,MAAM,IAAI,EAAE,GACxE,GAAG,SAAS,MAAM,CAAC,GACjB,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GACvB,SAAS,GACX,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,SAAS,CAAC;AAwBhB;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAEtG;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAIhH;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAMlH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPath.js","names":[],"sources":["../../src/object/getPath.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { UNSAFE_PATH_SEGMENTS } from '../_common/unsafePaths';\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\nfunction pathSegments(path: string): string[] {\n return path\n .replace(/\\[(\\d+)\\]/g, '.$1')\n .replace(/^\\.|\\.$/g, '')\n .split('.')\n .filter(Boolean);\n}\n\nfunction readPath(item: Obj, path: string): unknown {\n let current: unknown = item;\n\n for (const segment of pathSegments(path)) {\n if (UNSAFE_PATH_SEGMENTS.has(segment) || current == null || typeof current !== 'object') return undefined;\n\n current = (current as Record<string, unknown>)[segment];\n\n if (current === undefined) return undefined;\n }\n\n return current;\n}\n\n/**\n * Retrieves a value at a dot-notation or numeric bracket-notation path.\n * Returns `undefined` when the path is missing or contains an unsafe segment.\n * Use `getPathOr` to supply a fallback or `requirePath` to throw on a missing path.\n */\nexport function getPath<T extends Obj, P extends string>(item: T, path: P): PathValue<T, P> | undefined {\n return readPath(item, path) as PathValue<T, P> | undefined;\n}\n\n/**\n * Retrieves a value at a path or returns `fallback` when the path is missing.\n */\nexport function getPathOr<T extends Obj, P extends string, F>(item: T, path: P, fallback: F): PathValue<T, P> | F {\n const value = readPath(item, path);\n\n return (value === undefined ? fallback : value) as PathValue<T, P> | F;\n}\n\n/**\n * Retrieves a value at a path or throws when the path is missing.\n */\nexport function requirePath<T extends Obj, P extends string>(item: T, path: P): Exclude<PathValue<T, P>, undefined> {\n const value = readPath(item, path);\n\n if (value === undefined) throw new TypeError(`Path does not exist: '${path}'`);\n\n return value as Exclude<PathValue<T, P>, undefined>;\n}\n"],"mappings":";;AAYA,SAAS,EAAa,GAAwB;CAC5C,OAAO,EACJ,QAAQ,cAAc,KAAK,CAAC,CAC5B,QAAQ,YAAY,EAAE,CAAC,CACvB,MAAM,GAAG,CAAC,CACV,OAAO,OAAO;AACnB;AAEA,SAAS,EAAS,GAAW,GAAuB;CAClD,IAAI,IAAmB;CAEvB,KAAK,IAAM,KAAW,EAAa,CAAI,GAKrC,IAJI,EAAqB,IAAI,CAAO,KAAwB,OAAO,KAAY,aAAtC,MAEzC,IAAW,EAAoC,IAE3C,MAAY,KAAA,IAAW;CAG7B,OAAO;AACT;AAOA,SAAgB,EAAyC,GAAS,GAAsC;CACtG,OAAO,EAAS,GAAM,CAAI;AAC5B;AAKA,SAAgB,EAA8C,GAAS,GAAS,GAAkC;CAChH,IAAM,IAAQ,EAAS,GAAM,CAAI;CAEjC,OAAQ,MAAU,KAAA,IAAY,IAAW;AAC3C;AAKA,SAAgB,EAA6C,GAAS,GAA8C;CAClH,IAAM,IAAQ,EAAS,GAAM,CAAI;CAEjC,IAAI,MAAU,KAAA,GAAW,MAAU,UAAU,yBAAyB,EAAK,EAAE;CAE7E,OAAO;AACT"}
1
+ {"version":3,"file":"getPath.js","names":[],"sources":["../../src/object/getPath.ts"],"sourcesContent":["import { UNSAFE_PATH_SEGMENTS } from '../_common/unsafePaths';\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\nfunction pathSegments(path: string): string[] {\n return path\n .replace(/\\[(\\d+)\\]/g, '.$1')\n .replace(/^\\.|\\.$/g, '')\n .split('.')\n .filter(Boolean);\n}\n\nfunction readPath(item: Obj, path: string): unknown {\n let current: unknown = item;\n\n for (const segment of pathSegments(path)) {\n if (UNSAFE_PATH_SEGMENTS.has(segment) || current == null || typeof current !== 'object') return undefined;\n\n current = (current as Record<string, unknown>)[segment];\n\n if (current === undefined) return undefined;\n }\n\n return current;\n}\n\n/**\n * Retrieves a value at a dot-notation or numeric bracket-notation path.\n * Returns `undefined` when the path is missing or contains an unsafe segment.\n * Use `getPathOr` to supply a fallback or `requirePath` to throw on a missing path.\n */\nexport function getPath<T extends Obj, P extends string>(item: T, path: P): PathValue<T, P> | undefined {\n return readPath(item, path) as PathValue<T, P> | undefined;\n}\n\n/**\n * Retrieves a value at a path or returns `fallback` when the path is missing.\n */\nexport function getPathOr<T extends Obj, P extends string, F>(item: T, path: P, fallback: F): PathValue<T, P> | F {\n const value = readPath(item, path);\n\n return (value === undefined ? fallback : value) as PathValue<T, P> | F;\n}\n\n/**\n * Retrieves a value at a path or throws when the path is missing.\n */\nexport function requirePath<T extends Obj, P extends string>(item: T, path: P): Exclude<PathValue<T, P>, undefined> {\n const value = readPath(item, path);\n\n if (value === undefined) throw new TypeError(`Path does not exist: '${path}'`);\n\n return value as Exclude<PathValue<T, P>, undefined>;\n}\n"],"mappings":";;AAWA,SAAS,EAAa,GAAwB;CAC5C,OAAO,EACJ,QAAQ,cAAc,KAAK,CAAC,CAC5B,QAAQ,YAAY,EAAE,CAAC,CACvB,MAAM,GAAG,CAAC,CACV,OAAO,OAAO;AACnB;AAEA,SAAS,EAAS,GAAW,GAAuB;CAClD,IAAI,IAAmB;CAEvB,KAAK,IAAM,KAAW,EAAa,CAAI,GAKrC,IAJI,EAAqB,IAAI,CAAO,KAAwB,OAAO,KAAY,aAAtC,MAEzC,IAAW,EAAoC,IAE3C,MAAY,KAAA,IAAW;CAG7B,OAAO;AACT;AAOA,SAAgB,EAAyC,GAAS,GAAsC;CACtG,OAAO,EAAS,GAAM,CAAI;AAC5B;AAKA,SAAgB,EAA8C,GAAS,GAAS,GAAkC;CAChH,IAAM,IAAQ,EAAS,GAAM,CAAI;CAEjC,OAAQ,MAAU,KAAA,IAAY,IAAW;AAC3C;AAKA,SAAgB,EAA6C,GAAS,GAA8C;CAClH,IAAM,IAAQ,EAAS,GAAM,CAAI;CAEjC,IAAI,MAAU,KAAA,GAAW,MAAU,UAAU,yBAAyB,EAAK,EAAE;CAE7E,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapKeys.cjs","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EACd,EACA,EACiC,CACjC,IAAM,EAAuC,CAAC,EAE9C,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAAqB,CACpD,GAAI,EAAA,YAAY,CAAkB,EAAG,SAErC,IAAM,EAAY,EAAO,EAAK,EAAI,GAAM,CAAG,EAEvC,EAAA,YAAY,CAAS,IAEzB,EAAI,GAAa,EAAI,GACvB,CAEA,OAAO,CACT"}
1
+ {"version":3,"file":"mapKeys.cjs","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,EACd,EACA,EACiC,CACjC,IAAM,EAAuC,CAAC,EAE9C,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAAqB,CACpD,GAAI,EAAA,YAAY,CAAkB,EAAG,SAErC,IAAM,EAAY,EAAO,EAAK,EAAI,GAAM,CAAG,EAEvC,EAAA,YAAY,CAAS,IAEzB,EAAI,GAAa,EAAI,GACvB,CAEA,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapKeys.d.ts","sourceRoot":"","sources":["../../src/object/mapKeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EACnC,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,WAAW,GAC/D,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAcjC"}
1
+ {"version":3,"file":"mapKeys.d.ts","sourceRoot":"","sources":["../../src/object/mapKeys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,EACnC,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,WAAW,GAC/D,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAcjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapKeys.js","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EACd,GACA,GACiC;CACjC,IAAM,IAAuC,CAAC;CAE9C,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAAqB;EACpD,IAAI,EAAY,CAAkB,GAAG;EAErC,IAAM,IAAY,EAAO,GAAK,EAAI,IAAM,CAAG;EAEvC,EAAY,CAAS,MAEzB,EAAI,KAAa,EAAI;CACvB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"mapKeys.js","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":";;AAgBA,SAAgB,EACd,GACA,GACiC;CACjC,IAAM,IAAuC,CAAC;CAE9C,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAAqB;EACpD,IAAI,EAAY,CAAkB,GAAG;EAErC,IAAM,IAAY,EAAO,GAAK,EAAI,IAAM,CAAG;EAEvC,EAAY,CAAS,MAEzB,EAAI,KAAa,EAAI;CACvB;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapValues.cjs","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EACd,EACA,EACuB,CACvB,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,IAElC,EAAI,GAAO,EAAO,EAAI,GAAM,EAAK,CAAG,GAGtC,OAAO,CACT"}
1
+ {"version":3,"file":"mapValues.cjs","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,EACd,EACA,EACuB,CACvB,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,IAElC,EAAI,GAAO,EAAO,EAAI,GAAM,EAAK,CAAG,GAGtC,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapValues.d.ts","sourceRoot":"","sources":["../../src/object/mapValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,EACxC,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GACrD;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC;CAAE,CAUvB"}
1
+ {"version":3,"file":"mapValues.d.ts","sourceRoot":"","sources":["../../src/object/mapValues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,EACxC,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GACrD;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC;CAAE,CAUvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"mapValues.js","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EACd,GACA,GACuB;CACvB,IAAM,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,MAElC,EAAI,KAAO,EAAO,EAAI,IAAM,GAAK,CAAG;CAGtC,OAAO;AACT"}
1
+ {"version":3,"file":"mapValues.js","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":";;AAgBA,SAAgB,EACd,GACA,GACuB;CACvB,IAAM,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,MAElC,EAAI,KAAO,EAAO,EAAI,IAAM,GAAK,CAAG;CAGtC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge.cjs","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\nexport type DeepMergeOptions = {\n /** How to handle arrays when both source and target contain one. Default: `'replace'`. */\n arrayStrategy?: 'concat' | 'replace';\n};\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\nfunction mergeObjects<T extends Obj, U extends Obj>(target: T, source: U, options: DeepMergeOptions): DeepMerge<T, U> {\n if (!isPlainObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key of Object.keys(source)) {\n // Guard against prototype pollution: skip dangerous keys\n if (isUnsafeKey(key)) {\n continue;\n }\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n (result as Record<string, unknown>)[key] =\n Array.isArray(sourceValue) && Array.isArray(targetValue)\n ? options.arrayStrategy === 'concat'\n ? [...targetValue, ...sourceValue]\n : sourceValue\n : isPlainObject(sourceValue) && isPlainObject(targetValue)\n ? mergeObjects(targetValue as Obj, sourceValue as Obj, options)\n : sourceValue;\n }\n\n return result;\n}\n\n/**\n * Deeply merges two or more objects. Arrays in source objects **replace** the target array by default.\n * Pass `{ arrayStrategy: 'concat' }` as the last argument to concatenate arrays instead.\n *\n * @example\n * ```ts\n * deepMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 }, c: 3 });\n * // { a: 1, b: { x: 1, y: 2 }, c: 3 }\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] });\n * // { tags: ['b'] } ← arrays replaced\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] }, { arrayStrategy: 'concat' });\n * // { tags: ['a', 'b'] }\n * ```\n */\nexport function deepMerge<T extends Obj[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) as Merge<T>;\n}\n\n/**\n * Shallowly merges two or more objects. Later sources win for duplicate keys.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * shallowMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 } });\n * // { a: 1, b: { y: 2 } } ← nested object replaced, not merged\n *\n * shallowMerge(defaults, overrides, extras);\n * ```\n */\nexport function shallowMerge<T extends Obj[]>(...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n const result: Obj = {};\n\n for (const item of items) {\n for (const key of Object.keys(item)) {\n if (isUnsafeKey(key)) continue;\n\n result[key] = item[key];\n }\n }\n\n return result as Merge<T>;\n}\n"],"mappings":"uFAgCA,SAAS,EAA2C,EAAW,EAAW,EAA4C,CACpH,GAAI,CAAC,EAAA,cAAc,CAAM,EAAG,OAAO,EAEnC,IAAM,EAAS,CAAE,GAAG,CAAO,EAE3B,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAAG,CAErC,GAAI,EAAA,YAAY,CAAG,EACjB,SAGF,IAAM,EAAc,EAAO,GACrB,EAAc,EAAO,GAE3B,EAAoC,GAClC,MAAM,QAAQ,CAAW,GAAK,MAAM,QAAQ,CAAW,EACnD,EAAQ,gBAAkB,SACxB,CAAC,GAAG,EAAa,GAAG,CAAW,EAC/B,EACF,EAAA,cAAc,CAAW,GAAK,EAAA,cAAc,CAAW,EACrD,EAAa,EAAoB,EAAoB,CAAO,EAC5D,CACV,CAEA,OAAO,CACT,CAkBA,SAAgB,EAA2B,EAAwB,EAA4B,CAAC,EAAa,CAC3G,OAAO,EAAM,QAAQ,EAAU,IAAS,EAAa,EAAK,EAAM,CAAO,EAAU,CAAC,CAAQ,CAC5F,CAcA,SAAgB,EAA8B,GAAG,EAAyB,CACxE,GAAI,EAAM,SAAW,EAAG,MAAO,CAAC,EAEhC,IAAM,EAAc,CAAC,EAErB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAI,EAC5B,EAAA,YAAY,CAAG,IAEnB,EAAO,GAAO,EAAK,IAIvB,OAAO,CACT"}
1
+ {"version":3,"file":"merge.cjs","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\n\nexport type DeepMergeOptions = {\n /** How to handle arrays when both source and target contain one. Default: `'replace'`. */\n arrayStrategy?: 'concat' | 'replace';\n};\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\nfunction mergeObjects<T extends Obj, U extends Obj>(target: T, source: U, options: DeepMergeOptions): DeepMerge<T, U> {\n if (!isPlainObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key of Object.keys(source)) {\n // Guard against prototype pollution: skip dangerous keys\n if (isUnsafeKey(key)) {\n continue;\n }\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n (result as Record<string, unknown>)[key] =\n Array.isArray(sourceValue) && Array.isArray(targetValue)\n ? options.arrayStrategy === 'concat'\n ? [...targetValue, ...sourceValue]\n : sourceValue\n : isPlainObject(sourceValue) && isPlainObject(targetValue)\n ? mergeObjects(targetValue as Obj, sourceValue as Obj, options)\n : sourceValue;\n }\n\n return result;\n}\n\n/**\n * Deeply merges two or more objects. Arrays in source objects **replace** the target array by default.\n * Pass `{ arrayStrategy: 'concat' }` as the last argument to concatenate arrays instead.\n *\n * @example\n * ```ts\n * deepMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 }, c: 3 });\n * // { a: 1, b: { x: 1, y: 2 }, c: 3 }\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] });\n * // { tags: ['b'] } ← arrays replaced\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] }, { arrayStrategy: 'concat' });\n * // { tags: ['a', 'b'] }\n * ```\n */\nexport function deepMerge<T extends Obj[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) as Merge<T>;\n}\n\n/**\n * Shallowly merges two or more objects. Later sources win for duplicate keys.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * shallowMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 } });\n * // { a: 1, b: { y: 2 } } ← nested object replaced, not merged\n *\n * shallowMerge(defaults, overrides, extras);\n * ```\n */\nexport function shallowMerge<T extends Obj[]>(...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n const result: Obj = {};\n\n for (const item of items) {\n for (const key of Object.keys(item)) {\n if (isUnsafeKey(key)) continue;\n\n result[key] = item[key];\n }\n }\n\n return result as Merge<T>;\n}\n"],"mappings":"uFA+BA,SAAS,EAA2C,EAAW,EAAW,EAA4C,CACpH,GAAI,CAAC,EAAA,cAAc,CAAM,EAAG,OAAO,EAEnC,IAAM,EAAS,CAAE,GAAG,CAAO,EAE3B,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAAG,CAErC,GAAI,EAAA,YAAY,CAAG,EACjB,SAGF,IAAM,EAAc,EAAO,GACrB,EAAc,EAAO,GAE3B,EAAoC,GAClC,MAAM,QAAQ,CAAW,GAAK,MAAM,QAAQ,CAAW,EACnD,EAAQ,gBAAkB,SACxB,CAAC,GAAG,EAAa,GAAG,CAAW,EAC/B,EACF,EAAA,cAAc,CAAW,GAAK,EAAA,cAAc,CAAW,EACrD,EAAa,EAAoB,EAAoB,CAAO,EAC5D,CACV,CAEA,OAAO,CACT,CAkBA,SAAgB,EAA2B,EAAwB,EAA4B,CAAC,EAAa,CAC3G,OAAO,EAAM,QAAQ,EAAU,IAAS,EAAa,EAAK,EAAM,CAAO,EAAU,CAAC,CAAQ,CAC5F,CAcA,SAAgB,EAA8B,GAAG,EAAyB,CACxE,GAAI,EAAM,SAAW,EAAG,MAAO,CAAC,EAEhC,IAAM,EAAc,CAAC,EAErB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAI,EAC5B,EAAA,YAAY,CAAG,IAEnB,EAAO,GAAO,EAAK,IAIvB,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/object/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAKpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,0FAA0F;IAC1F,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,GAChC,CAAC,SAAS,GAAG,GACX;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GACvC,CAAC,SAAS,MAAM,CAAC,GACf,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,CAAC,CAAC,GACN,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,KAAK;CACZ,GACD,CAAC,GACH,CAAC,CAAC;AAEN,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAChE,KAAK,SAAS,GAAG,GACf,IAAI,SAAS,GAAG,EAAE,GAChB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAC7B,KAAK,GACP,GAAG,GACL,GAAG,CAAC;AA6BR;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAE,gBAAqB,GAAG,KAAK,CAAC,CAAC,CAAC,CAE3G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAcxE"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/object/merge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,0FAA0F;IAC1F,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,GAChC,CAAC,SAAS,GAAG,GACX;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GACvC,CAAC,SAAS,MAAM,CAAC,GACf,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,CAAC,CAAC,GACN,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,KAAK;CACZ,GACD,CAAC,GACH,CAAC,CAAC;AAEN,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAChE,KAAK,SAAS,GAAG,GACf,IAAI,SAAS,GAAG,EAAE,GAChB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAC7B,KAAK,GACP,GAAG,GACL,GAAG,CAAC;AA6BR;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAE,gBAAqB,GAAG,KAAK,CAAC,CAAC,CAAC,CAE3G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAcxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\nexport type DeepMergeOptions = {\n /** How to handle arrays when both source and target contain one. Default: `'replace'`. */\n arrayStrategy?: 'concat' | 'replace';\n};\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\nfunction mergeObjects<T extends Obj, U extends Obj>(target: T, source: U, options: DeepMergeOptions): DeepMerge<T, U> {\n if (!isPlainObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key of Object.keys(source)) {\n // Guard against prototype pollution: skip dangerous keys\n if (isUnsafeKey(key)) {\n continue;\n }\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n (result as Record<string, unknown>)[key] =\n Array.isArray(sourceValue) && Array.isArray(targetValue)\n ? options.arrayStrategy === 'concat'\n ? [...targetValue, ...sourceValue]\n : sourceValue\n : isPlainObject(sourceValue) && isPlainObject(targetValue)\n ? mergeObjects(targetValue as Obj, sourceValue as Obj, options)\n : sourceValue;\n }\n\n return result;\n}\n\n/**\n * Deeply merges two or more objects. Arrays in source objects **replace** the target array by default.\n * Pass `{ arrayStrategy: 'concat' }` as the last argument to concatenate arrays instead.\n *\n * @example\n * ```ts\n * deepMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 }, c: 3 });\n * // { a: 1, b: { x: 1, y: 2 }, c: 3 }\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] });\n * // { tags: ['b'] } ← arrays replaced\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] }, { arrayStrategy: 'concat' });\n * // { tags: ['a', 'b'] }\n * ```\n */\nexport function deepMerge<T extends Obj[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) as Merge<T>;\n}\n\n/**\n * Shallowly merges two or more objects. Later sources win for duplicate keys.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * shallowMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 } });\n * // { a: 1, b: { y: 2 } } ← nested object replaced, not merged\n *\n * shallowMerge(defaults, overrides, extras);\n * ```\n */\nexport function shallowMerge<T extends Obj[]>(...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n const result: Obj = {};\n\n for (const item of items) {\n for (const key of Object.keys(item)) {\n if (isUnsafeKey(key)) continue;\n\n result[key] = item[key];\n }\n }\n\n return result as Merge<T>;\n}\n"],"mappings":";;;AAgCA,SAAS,EAA2C,GAAW,GAAW,GAA4C;CACpH,IAAI,CAAC,EAAc,CAAM,GAAG,OAAO;CAEnC,IAAM,IAAS,EAAE,GAAG,EAAO;CAE3B,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAAG;EAErC,IAAI,EAAY,CAAG,GACjB;EAGF,IAAM,IAAc,EAAO,IACrB,IAAc,EAAO;EAE3B,EAAoC,KAClC,MAAM,QAAQ,CAAW,KAAK,MAAM,QAAQ,CAAW,IACnD,EAAQ,kBAAkB,WACxB,CAAC,GAAG,GAAa,GAAG,CAAW,IAC/B,IACF,EAAc,CAAW,KAAK,EAAc,CAAW,IACrD,EAAa,GAAoB,GAAoB,CAAO,IAC5D;CACV;CAEA,OAAO;AACT;AAkBA,SAAgB,EAA2B,GAAwB,IAA4B,CAAC,GAAa;CAC3G,OAAO,EAAM,QAAQ,GAAU,MAAS,EAAa,GAAK,GAAM,CAAO,GAAU,CAAC,CAAQ;AAC5F;AAcA,SAAgB,EAA8B,GAAG,GAAyB;CACxE,IAAI,EAAM,WAAW,GAAG,OAAO,CAAC;CAEhC,IAAM,IAAc,CAAC;CAErB,KAAK,IAAM,KAAQ,GACjB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAI,GAC5B,EAAY,CAAG,MAEnB,EAAO,KAAO,EAAK;CAIvB,OAAO;AACT"}
1
+ {"version":3,"file":"merge.js","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\n\nexport type DeepMergeOptions = {\n /** How to handle arrays when both source and target contain one. Default: `'replace'`. */\n arrayStrategy?: 'concat' | 'replace';\n};\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\nfunction mergeObjects<T extends Obj, U extends Obj>(target: T, source: U, options: DeepMergeOptions): DeepMerge<T, U> {\n if (!isPlainObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key of Object.keys(source)) {\n // Guard against prototype pollution: skip dangerous keys\n if (isUnsafeKey(key)) {\n continue;\n }\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n (result as Record<string, unknown>)[key] =\n Array.isArray(sourceValue) && Array.isArray(targetValue)\n ? options.arrayStrategy === 'concat'\n ? [...targetValue, ...sourceValue]\n : sourceValue\n : isPlainObject(sourceValue) && isPlainObject(targetValue)\n ? mergeObjects(targetValue as Obj, sourceValue as Obj, options)\n : sourceValue;\n }\n\n return result;\n}\n\n/**\n * Deeply merges two or more objects. Arrays in source objects **replace** the target array by default.\n * Pass `{ arrayStrategy: 'concat' }` as the last argument to concatenate arrays instead.\n *\n * @example\n * ```ts\n * deepMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 }, c: 3 });\n * // { a: 1, b: { x: 1, y: 2 }, c: 3 }\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] });\n * // { tags: ['b'] } ← arrays replaced\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] }, { arrayStrategy: 'concat' });\n * // { tags: ['a', 'b'] }\n * ```\n */\nexport function deepMerge<T extends Obj[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) as Merge<T>;\n}\n\n/**\n * Shallowly merges two or more objects. Later sources win for duplicate keys.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * shallowMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 } });\n * // { a: 1, b: { y: 2 } } ← nested object replaced, not merged\n *\n * shallowMerge(defaults, overrides, extras);\n * ```\n */\nexport function shallowMerge<T extends Obj[]>(...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n const result: Obj = {};\n\n for (const item of items) {\n for (const key of Object.keys(item)) {\n if (isUnsafeKey(key)) continue;\n\n result[key] = item[key];\n }\n }\n\n return result as Merge<T>;\n}\n"],"mappings":";;;AA+BA,SAAS,EAA2C,GAAW,GAAW,GAA4C;CACpH,IAAI,CAAC,EAAc,CAAM,GAAG,OAAO;CAEnC,IAAM,IAAS,EAAE,GAAG,EAAO;CAE3B,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAAG;EAErC,IAAI,EAAY,CAAG,GACjB;EAGF,IAAM,IAAc,EAAO,IACrB,IAAc,EAAO;EAE3B,EAAoC,KAClC,MAAM,QAAQ,CAAW,KAAK,MAAM,QAAQ,CAAW,IACnD,EAAQ,kBAAkB,WACxB,CAAC,GAAG,GAAa,GAAG,CAAW,IAC/B,IACF,EAAc,CAAW,KAAK,EAAc,CAAW,IACrD,EAAa,GAAoB,GAAoB,CAAO,IAC5D;CACV;CAEA,OAAO;AACT;AAkBA,SAAgB,EAA2B,GAAwB,IAA4B,CAAC,GAAa;CAC3G,OAAO,EAAM,QAAQ,GAAU,MAAS,EAAa,GAAK,GAAM,CAAO,GAAU,CAAC,CAAQ;AAC5F;AAcA,SAAgB,EAA8B,GAAG,GAAyB;CACxE,IAAI,EAAM,WAAW,GAAG,OAAO,CAAC;CAEhC,IAAM,IAAc,CAAC;CAErB,KAAK,IAAM,KAAQ,GACjB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAI,GAC5B,EAAY,CAAG,MAEnB,EAAO,KAAO,EAAK;CAIvB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"omit.cjs","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EAAuC,EAAQ,EAAuC,CACpG,IAAM,EAAY,IAAI,IAAiB,CAAqC,EACtE,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,GAE7B,EAAU,IAAI,CAAG,IACpB,EAAW,GAAO,EAAI,IAI1B,OAAO,CACT"}
1
+ {"version":3,"file":"omit.cjs","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,EAAuC,EAAQ,EAAuC,CACpG,IAAM,EAAY,IAAI,IAAiB,CAAqC,EACtE,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,GAE7B,EAAU,IAAI,CAAG,IACpB,EAAW,GAAO,EAAI,IAI1B,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../../src/object/omit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAapG"}
1
+ {"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../../src/object/omit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAapG"}
@@ -1 +1 @@
1
- {"version":3,"file":"omit.js","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAuC,GAAQ,GAAuC;CACpG,IAAM,IAAY,IAAI,IAAiB,CAAqC,GACtE,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,KAE7B,EAAU,IAAI,CAAG,MACpB,EAAW,KAAO,EAAI;CAI1B,OAAO;AACT"}
1
+ {"version":3,"file":"omit.js","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAgBA,SAAgB,EAAuC,GAAQ,GAAuC;CACpG,IAAM,IAAY,IAAI,IAAiB,CAAqC,GACtE,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,KAE7B,EAAU,IAAI,CAAG,MACpB,EAAW,KAAO,EAAI;CAI1B,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"pick.cjs","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAkBA,SAAgB,EAAuC,EAAQ,EAAwC,CACrG,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,EACZ,EAAA,YAAY,CAAkB,GAE9B,OAAO,OAAO,EAAK,CAAG,IACxB,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
1
+ {"version":3,"file":"pick.cjs","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EAAuC,EAAQ,EAAwC,CACrG,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,EACZ,EAAA,YAAY,CAAkB,GAE9B,OAAO,OAAO,EAAK,CAAG,IACxB,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/object/pick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAYrG"}
1
+ {"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/object/pick.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAYrG"}
@@ -1 +1 @@
1
- {"version":3,"file":"pick.js","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAkBA,SAAgB,EAAuC,GAAQ,GAAwC;CACrG,IAAM,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,GACZ,EAAY,CAAkB,KAE9B,OAAO,OAAO,GAAK,CAAG,MACxB,EAAI,KAAO,EAAI;CAInB,OAAO;AACT"}
1
+ {"version":3,"file":"pick.js","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAuC,GAAQ,GAAwC;CACrG,IAAM,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,GACZ,EAAY,CAAkB,KAE9B,OAAO,OAAO,GAAK,CAAG,MACxB,EAAI,KAAO,EAAI;CAInB,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- const e=require("../_common/unsafePaths.cjs"),t=require("../array/filterMap.cjs"),n=require("../guards/isNil.cjs"),r=require("../guards/isPlainObject.cjs"),i=require("../guards/isEmpty.cjs");function a(o){if(!n.isNil(o)){if(typeof o==`string`){let e=o.trim();return e===``?void 0:e}if(Array.isArray(o)){let e=t.filterMap(o,e=>{let t=a(e);return i.isEmpty(t)?void 0:t});return e.length===0?void 0:e}if(r.isPlainObject(o)){let t={};for(let[n,r]of Object.entries(o)){if(e.isUnsafeKey(n))continue;let o=a(r);i.isEmpty(o)||(t[n]=o)}return Object.keys(t).length===0?void 0:t}return o}}exports.prune=a;
1
+ const e=require("../_common/unsafePaths.cjs"),t=require("../array/filterMap.cjs"),n=require("../guards/isPlainObject.cjs"),r=require("../guards/isEmpty.cjs");function i(a){if(a!=null){if(typeof a==`string`){let e=a.trim();return e===``?void 0:e}if(Array.isArray(a)){let e=t.filterMap(a,e=>{let t=i(e);return r.isEmpty(t)?void 0:t});return e.length===0?void 0:e}if(n.isPlainObject(a)){let t={};for(let[n,o]of Object.entries(a)){if(e.isUnsafeKey(n))continue;let a=i(o);r.isEmpty(a)||(t[n]=a)}return Object.keys(t).length===0?void 0:t}return a}}exports.prune=i;
2
2
  //# sourceMappingURL=prune.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"prune.cjs","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isNil } from '../guards/isNil';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (isNil(value)) return undefined;\n\n if (typeof value === 'string') {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":"+LA+BA,SAAgB,EAAS,EAAyB,CAC5C,MAAA,MAAM,CAAK,EAEf,IAAI,OAAO,GAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,KAAK,EAE3B,OAAQ,IAAY,GAAK,IAAA,GAAY,CACvC,CAEA,GAAI,MAAM,QAAQ,CAAK,EAAG,CACxB,IAAM,EAAU,EAAA,UAAU,EAAqB,GAAS,CACtD,IAAM,EAAS,EAAM,CAAI,EAEzB,OAAO,EAAA,QAAQ,CAAM,EAAI,IAAA,GAAa,CACxC,CAAC,EAED,OAAQ,EAAQ,SAAW,EAAI,IAAA,GAAY,CAC7C,CAEA,GAAI,EAAA,cAAc,CAAK,EAAG,CACxB,IAAM,EAAmC,CAAC,EAE1C,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAK,EAAG,CAC9C,GAAI,EAAA,YAAY,CAAG,EAAG,SAEtB,IAAM,EAAe,EAAM,CAAG,EAEzB,EAAA,QAAQ,CAAY,IACvB,EAAQ,GAAO,EAEnB,CAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,SAAW,EAAI,IAAA,GAAY,CAC1D,CAEA,OAAO,CA5BP,CA6BF"}
1
+ {"version":3,"file":"prune.cjs","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (value === null || value === undefined) return undefined;\n\n if (typeof value === 'string') {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":"8JA8BA,SAAgB,EAAS,EAAyB,CAC5C,MAAU,KAEd,IAAI,OAAO,GAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,KAAK,EAE3B,OAAQ,IAAY,GAAK,IAAA,GAAY,CACvC,CAEA,GAAI,MAAM,QAAQ,CAAK,EAAG,CACxB,IAAM,EAAU,EAAA,UAAU,EAAqB,GAAS,CACtD,IAAM,EAAS,EAAM,CAAI,EAEzB,OAAO,EAAA,QAAQ,CAAM,EAAI,IAAA,GAAa,CACxC,CAAC,EAED,OAAQ,EAAQ,SAAW,EAAI,IAAA,GAAY,CAC7C,CAEA,GAAI,EAAA,cAAc,CAAK,EAAG,CACxB,IAAM,EAAmC,CAAC,EAE1C,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAK,EAAG,CAC9C,GAAI,EAAA,YAAY,CAAG,EAAG,SAEtB,IAAM,EAAe,EAAM,CAAG,EAEzB,EAAA,QAAQ,CAAY,IACvB,EAAQ,GAAO,EAEnB,CAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,SAAW,EAAI,IAAA,GAAY,CAC1D,CAEA,OAAO,CA5BP,CA6BF"}
@@ -1 +1 @@
1
- {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/object/prune.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACzD,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACxE,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAC3F,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC"}
1
+ {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/object/prune.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACzD,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACxE,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAC3F,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC"}
@@ -1,35 +1,34 @@
1
1
  import { isUnsafeKey as e } from "../_common/unsafePaths.js";
2
2
  import { filterMap as t } from "../array/filterMap.js";
3
- import { isNil as n } from "../guards/isNil.js";
4
- import { isPlainObject as r } from "../guards/isPlainObject.js";
5
- import { isEmpty as i } from "../guards/isEmpty.js";
3
+ import { isPlainObject as n } from "../guards/isPlainObject.js";
4
+ import { isEmpty as r } from "../guards/isEmpty.js";
6
5
  //#region src/object/prune.ts
7
- function a(o) {
8
- if (!n(o)) {
9
- if (typeof o == "string") {
10
- let e = o.trim();
6
+ function i(a) {
7
+ if (a != null) {
8
+ if (typeof a == "string") {
9
+ let e = a.trim();
11
10
  return e === "" ? void 0 : e;
12
11
  }
13
- if (Array.isArray(o)) {
14
- let e = t(o, (e) => {
15
- let t = a(e);
16
- return i(t) ? void 0 : t;
12
+ if (Array.isArray(a)) {
13
+ let e = t(a, (e) => {
14
+ let t = i(e);
15
+ return r(t) ? void 0 : t;
17
16
  });
18
17
  return e.length === 0 ? void 0 : e;
19
18
  }
20
- if (r(o)) {
19
+ if (n(a)) {
21
20
  let t = {};
22
- for (let [n, r] of Object.entries(o)) {
21
+ for (let [n, o] of Object.entries(a)) {
23
22
  if (e(n)) continue;
24
- let o = a(r);
25
- i(o) || (t[n] = o);
23
+ let a = i(o);
24
+ r(a) || (t[n] = a);
26
25
  }
27
26
  return Object.keys(t).length === 0 ? void 0 : t;
28
27
  }
29
- return o;
28
+ return a;
30
29
  }
31
30
  }
32
31
  //#endregion
33
- export { a as prune };
32
+ export { i as prune };
34
33
 
35
34
  //# sourceMappingURL=prune.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prune.js","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isNil } from '../guards/isNil';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (isNil(value)) return undefined;\n\n if (typeof value === 'string') {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":";;;;;;AA+BA,SAAgB,EAAS,GAAyB;CAC5C,OAAM,CAAK,GAEf;MAAI,OAAO,KAAU,UAAU;GAC7B,IAAM,IAAU,EAAM,KAAK;GAE3B,OAAQ,MAAY,KAAK,KAAA,IAAY;EACvC;EAEA,IAAI,MAAM,QAAQ,CAAK,GAAG;GACxB,IAAM,IAAU,EAAU,IAAqB,MAAS;IACtD,IAAM,IAAS,EAAM,CAAI;IAEzB,OAAO,EAAQ,CAAM,IAAI,KAAA,IAAa;GACxC,CAAC;GAED,OAAQ,EAAQ,WAAW,IAAI,KAAA,IAAY;EAC7C;EAEA,IAAI,EAAc,CAAK,GAAG;GACxB,IAAM,IAAmC,CAAC;GAE1C,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAAG;IAC9C,IAAI,EAAY,CAAG,GAAG;IAEtB,IAAM,IAAe,EAAM,CAAG;IAE9B,AAAK,EAAQ,CAAY,MACvB,EAAQ,KAAO;GAEnB;GAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,WAAW,IAAI,KAAA,IAAY;EAC1D;EAEA,OAAO;CA5BP;AA6BF"}
1
+ {"version":3,"file":"prune.js","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (value === null || value === undefined) return undefined;\n\n if (typeof value === 'string') {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":";;;;;AA8BA,SAAgB,EAAS,GAAyB;CAC5C,SAAU,MAEd;MAAI,OAAO,KAAU,UAAU;GAC7B,IAAM,IAAU,EAAM,KAAK;GAE3B,OAAQ,MAAY,KAAK,KAAA,IAAY;EACvC;EAEA,IAAI,MAAM,QAAQ,CAAK,GAAG;GACxB,IAAM,IAAU,EAAU,IAAqB,MAAS;IACtD,IAAM,IAAS,EAAM,CAAI;IAEzB,OAAO,EAAQ,CAAM,IAAI,KAAA,IAAa;GACxC,CAAC;GAED,OAAQ,EAAQ,WAAW,IAAI,KAAA,IAAY;EAC7C;EAEA,IAAI,EAAc,CAAK,GAAG;GACxB,IAAM,IAAmC,CAAC;GAE1C,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAAG;IAC9C,IAAI,EAAY,CAAG,GAAG;IAEtB,IAAM,IAAe,EAAM,CAAG;IAE9B,AAAK,EAAQ,CAAY,MACvB,EAAQ,KAAO;GAEnB;GAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,WAAW,IAAI,KAAA,IAAY;EAC1D;EAEA,OAAO;CA5BP;AA6BF"}
@@ -1,2 +1,2 @@
1
- function e(e,t){let n=t?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296;if(!Number.isFinite(n)||n<0||n>=1)throw RangeError(`random source must return a finite number in [0, 1)`);return Math.floor(n*e)}exports.randomIndex=e;
1
+ const e=require("./source.cjs");function t(t,n){return Math.floor(e.randomFloat(n)*t)}exports.randomIndex=t;
2
2
  //# sourceMappingURL=_index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"_index.cjs","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n const value = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n if (!Number.isFinite(value) || value < 0 || value >= 1) {\n throw new RangeError('random source must return a finite number in [0, 1)');\n }\n\n return Math.floor(value * exclusiveMax);\n}\n"],"mappings":"AAEA,SAAgB,EAAY,EAAsB,EAA+B,CAC/E,IAAM,EAAQ,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,WAEjF,GAAI,CAAC,OAAO,SAAS,CAAK,GAAK,EAAQ,GAAK,GAAS,EACnD,MAAU,WAAW,qDAAqD,EAG5E,OAAO,KAAK,MAAM,EAAQ,CAAY,CACxC"}
1
+ {"version":3,"file":"_index.cjs","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import { type RandomSource, randomFloat } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n return Math.floor(randomFloat(source) * exclusiveMax);\n}\n"],"mappings":"gCAEA,SAAgB,EAAY,EAAsB,EAA+B,CAC/E,OAAO,KAAK,MAAM,EAAA,YAAY,CAAM,EAAI,CAAY,CACtD"}
@@ -1,3 +1,3 @@
1
- import type { RandomSource } from './source';
1
+ import { type RandomSource } from './source';
2
2
  export declare function randomIndex(exclusiveMax: number, source?: RandomSource): number;
3
3
  //# sourceMappingURL=_index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../src/random/_index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAQ/E"}
1
+ {"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../src/random/_index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,UAAU,CAAC;AAE1D,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE/E"}
@@ -1,10 +1,9 @@
1
+ import { randomFloat as e } from "./source.js";
1
2
  //#region src/random/_index.ts
2
- function e(e, t) {
3
- let n = t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296;
4
- if (!Number.isFinite(n) || n < 0 || n >= 1) throw RangeError("random source must return a finite number in [0, 1)");
5
- return Math.floor(n * e);
3
+ function t(t, n) {
4
+ return Math.floor(e(n) * t);
6
5
  }
7
6
  //#endregion
8
- export { e as randomIndex };
7
+ export { t as randomIndex };
9
8
 
10
9
  //# sourceMappingURL=_index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_index.js","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n const value = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n if (!Number.isFinite(value) || value < 0 || value >= 1) {\n throw new RangeError('random source must return a finite number in [0, 1)');\n }\n\n return Math.floor(value * exclusiveMax);\n}\n"],"mappings":";AAEA,SAAgB,EAAY,GAAsB,GAA+B;CAC/E,IAAM,IAAQ,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM;CAEjF,IAAI,CAAC,OAAO,SAAS,CAAK,KAAK,IAAQ,KAAK,KAAS,GACnD,MAAU,WAAW,qDAAqD;CAG5E,OAAO,KAAK,MAAM,IAAQ,CAAY;AACxC"}
1
+ {"version":3,"file":"_index.js","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import { type RandomSource, randomFloat } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n return Math.floor(randomFloat(source) * exclusiveMax);\n}\n"],"mappings":";;AAEA,SAAgB,EAAY,GAAsB,GAA+B;CAC/E,OAAO,KAAK,MAAM,EAAY,CAAM,IAAI,CAAY;AACtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number, source?: RandomSource): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"0DAeA,SAAgB,EAAQ,EAAY,EAAsC,CACpE,KAAM,SAAW,EAErB,OAAO,EAAM,EAAA,OAAO,EAAG,EAAM,OAAS,EAAG,CAAM,EACjD,CAaA,SAAgB,EAAY,EAAY,EAAW,EAA4B,CAC7E,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,IAAI,EAAM,OAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,EAE/D,GAAI,IAAU,EAAG,MAAO,CAAC,EAEzB,GAAI,IAAU,EAAM,OAAQ,MAAO,CAAC,GAAG,CAAK,EAE5C,IAAM,EAAO,CAAC,GAAG,CAAK,EAEtB,IAAK,IAAI,EAAQ,EAAK,OAAS,EAAG,EAAQ,EAAG,IAAS,CACpD,IAAM,EAAgB,EAAA,YAAY,EAAQ,EAAG,CAAM,EAC7C,EAAO,EAAK,GAElB,EAAK,GAAS,EAAK,GACnB,EAAK,GAAiB,CACxB,CAEA,OAAO,EAAK,MAAM,EAAG,CAAK,CAC5B"}
1
+ {"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number, source?: RandomSource): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"0DAcA,SAAgB,EAAQ,EAAY,EAAsC,CACpE,KAAM,SAAW,EAErB,OAAO,EAAM,EAAA,OAAO,EAAG,EAAM,OAAS,EAAG,CAAM,EACjD,CAaA,SAAgB,EAAY,EAAY,EAAW,EAA4B,CAC7E,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,IAAI,EAAM,OAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,EAE/D,GAAI,IAAU,EAAG,MAAO,CAAC,EAEzB,GAAI,IAAU,EAAM,OAAQ,MAAO,CAAC,GAAG,CAAK,EAE5C,IAAM,EAAO,CAAC,GAAG,CAAK,EAEtB,IAAK,IAAI,EAAQ,EAAK,OAAS,EAAG,EAAQ,EAAG,IAAS,CACpD,IAAM,EAAgB,EAAA,YAAY,EAAQ,EAAG,CAAM,EAC7C,EAAO,EAAK,GAElB,EAAK,GAAS,EAAK,GACnB,EAAK,GAAiB,CACxB,CAEA,OAAO,EAAK,MAAM,EAAG,CAAK,CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/random/draw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAIxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAkB7E"}
1
+ {"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/random/draw.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAIxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAkB7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number, source?: RandomSource): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":";;;AAeA,SAAgB,EAAQ,GAAY,GAAsC;CACpE,MAAM,WAAW,GAErB,OAAO,EAAM,EAAO,GAAG,EAAM,SAAS,GAAG,CAAM;AACjD;AAaA,SAAgB,EAAY,GAAY,GAAW,GAA4B;CAC7E,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;CAE/D,IAAI,MAAU,GAAG,OAAO,CAAC;CAEzB,IAAI,MAAU,EAAM,QAAQ,OAAO,CAAC,GAAG,CAAK;CAE5C,IAAM,IAAO,CAAC,GAAG,CAAK;CAEtB,KAAK,IAAI,IAAQ,EAAK,SAAS,GAAG,IAAQ,GAAG,KAAS;EACpD,IAAM,IAAgB,EAAY,IAAQ,GAAG,CAAM,GAC7C,IAAO,EAAK;EAGlB,AADA,EAAK,KAAS,EAAK,IACnB,EAAK,KAAiB;CACxB;CAEA,OAAO,EAAK,MAAM,GAAG,CAAK;AAC5B"}
1
+ {"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number, source?: RandomSource): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":";;;AAcA,SAAgB,EAAQ,GAAY,GAAsC;CACpE,MAAM,WAAW,GAErB,OAAO,EAAM,EAAO,GAAG,EAAM,SAAS,GAAG,CAAM;AACjD;AAaA,SAAgB,EAAY,GAAY,GAAW,GAA4B;CAC7E,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;CAE/D,IAAI,MAAU,GAAG,OAAO,CAAC;CAEzB,IAAI,MAAU,EAAM,QAAQ,OAAO,CAAC,GAAG,CAAK;CAE5C,IAAM,IAAO,CAAC,GAAG,CAAK;CAEtB,KAAK,IAAI,IAAQ,EAAK,SAAS,GAAG,IAAQ,GAAG,KAAS;EACpD,IAAM,IAAgB,EAAY,IAAQ,GAAG,CAAM,GAC7C,IAAO,EAAK;EAGlB,AADA,EAAK,KAAS,EAAK,IACnB,EAAK,KAAiB;CACxB;CAEA,OAAO,EAAK,MAAM,GAAG,CAAK;AAC5B"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./uuid.cjs"),t=require("./random.cjs"),n=require("./draw.cjs"),r=require("./shuffle.cjs");exports.draw=n.draw,exports.drawMany=n.drawMany,exports.random=t.random,exports.shuffle=r.shuffle,exports.uuid=e.uuid;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./source.cjs"),t=require("./random.cjs"),n=require("./draw.cjs"),r=require("./shuffle.cjs");exports.draw=n.draw,exports.drawMany=n.drawMany,exports.random=t.random,exports.randomFloat=e.randomFloat,exports.shuffle=r.shuffle;
@@ -2,5 +2,4 @@ export * from './draw';
2
2
  export * from './random';
3
3
  export * from './shuffle';
4
4
  export * from './source';
5
- export * from './uuid';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/random/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/random/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
- import { uuid as e } from "./uuid.js";
1
+ import { randomFloat as e } from "./source.js";
2
2
  import { random as t } from "./random.js";
3
3
  import { draw as n, drawMany as r } from "./draw.js";
4
4
  import { shuffle as i } from "./shuffle.js";
5
- export { n as draw, r as drawMany, t as random, i as shuffle, e as uuid };
5
+ export { n as draw, r as drawMany, t as random, e as randomFloat, i as shuffle };
@@ -1 +1 @@
1
- {"version":3,"file":"random.cjs","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\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, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":"gCAgBA,SAAgB,EAAO,EAAa,EAAa,EAA+B,CAC9E,GAAI,EAAM,EAAK,MAAU,WAAW,8DAA8D,EAElG,OAAO,EAAA,YAAY,EAAM,EAAM,EAAG,CAAM,EAAI,CAC9C"}
1
+ {"version":3,"file":"random.cjs","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport type { RandomSource } from './source';\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, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":"gCAeA,SAAgB,EAAO,EAAa,EAAa,EAA+B,CAC9E,GAAI,EAAM,EAAK,MAAU,WAAW,8DAA8D,EAElG,OAAO,EAAA,YAAY,EAAM,EAAM,EAAG,CAAM,EAAI,CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random/random.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAI9E"}
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random/random.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAI9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"random.js","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\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, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":";;AAgBA,SAAgB,EAAO,GAAa,GAAa,GAA+B;CAC9E,IAAI,IAAM,GAAK,MAAU,WAAW,8DAA8D;CAElG,OAAO,EAAY,IAAM,IAAM,GAAG,CAAM,IAAI;AAC9C"}
1
+ {"version":3,"file":"random.js","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport type { RandomSource } from './source';\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, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":";;AAeA,SAAgB,EAAO,GAAa,GAAa,GAA+B;CAC9E,IAAI,IAAM,GAAK,MAAU,WAAW,8DAA8D;CAElG,OAAO,EAAY,IAAM,IAAM,GAAG,CAAM,IAAI;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"shuffle.cjs","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":"gCAcA,SAAgB,EAAW,EAAY,EAA4B,CACjE,IAAM,EAAS,CAAC,GAAG,CAAK,EAExB,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAAK,CAC1C,IAAM,EAAI,EAAA,YAAY,EAAI,EAAG,CAAM,EAEnC,CAAC,EAAO,GAAI,EAAO,IAAM,CAAC,EAAO,GAAI,EAAO,EAAE,CAChD,CAEA,OAAO,CACT"}
1
+ {"version":3,"file":"shuffle.cjs","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport type { RandomSource } from './source';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":"gCAaA,SAAgB,EAAW,EAAY,EAA4B,CACjE,IAAM,EAAS,CAAC,GAAG,CAAK,EAExB,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAAK,CAC1C,IAAM,EAAI,EAAA,YAAY,EAAI,EAAG,CAAM,EAEnC,CAAC,EAAO,GAAI,EAAO,IAAM,CAAC,EAAO,GAAI,EAAO,EAAE,CAChD,CAEA,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAUjE"}
1
+ {"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAUjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"shuffle.js","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;AAcA,SAAgB,EAAW,GAAY,GAA4B;CACjE,IAAM,IAAS,CAAC,GAAG,CAAK;CAExB,KAAK,IAAI,IAAI,EAAO,SAAS,GAAG,IAAI,GAAG,KAAK;EAC1C,IAAM,IAAI,EAAY,IAAI,GAAG,CAAM;EAEnC,CAAC,EAAO,IAAI,EAAO,MAAM,CAAC,EAAO,IAAI,EAAO,EAAE;CAChD;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"shuffle.js","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport type { RandomSource } from './source';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;AAaA,SAAgB,EAAW,GAAY,GAA4B;CACjE,IAAM,IAAS,CAAC,GAAG,CAAK;CAExB,KAAK,IAAI,IAAI,EAAO,SAAS,GAAG,IAAI,GAAG,KAAK;EAC1C,IAAM,IAAI,EAAY,IAAI,GAAG,CAAM;EAEnC,CAAC,EAAO,IAAI,EAAO,MAAM,CAAC,EAAO,IAAI,EAAO,EAAE;CAChD;CAEA,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ function e(e){let t=e?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296;if(!Number.isFinite(t)||t<0||t>=1)throw RangeError(`random source must return a finite number in [0, 1)`);return t}exports.randomFloat=e;
2
+ //# sourceMappingURL=source.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.cjs","names":[],"sources":["../../src/random/source.ts"],"sourcesContent":["export type RandomSource = {\n next(): number;\n};\n\n/** Returns a validated random float in `[0, 1)`. */\nexport function randomFloat(source?: RandomSource): number {\n const value = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n if (!Number.isFinite(value) || value < 0 || value >= 1) {\n throw new RangeError('random source must return a finite number in [0, 1)');\n }\n\n return value;\n}\n"],"mappings":"AAKA,SAAgB,EAAY,EAA+B,CACzD,IAAM,EAAQ,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,WAEjF,GAAI,CAAC,OAAO,SAAS,CAAK,GAAK,EAAQ,GAAK,GAAS,EACnD,MAAU,WAAW,qDAAqD,EAG5E,OAAO,CACT"}
@@ -1,4 +1,6 @@
1
1
  export type RandomSource = {
2
2
  next(): number;
3
3
  };
4
+ /** Returns a validated random float in `[0, 1)`. */
5
+ export declare function randomFloat(source?: RandomSource): number;
4
6
  //# sourceMappingURL=source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/random/source.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/random/source.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC;AAEF,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAQzD"}