ts-data-forge 14.6.1 → 14.6.2

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 (393) hide show
  1. package/dist/array/impl/array-utils-creation.mjs +126 -26
  2. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  3. package/dist/array/impl/array-utils-element-access.mjs +63 -30
  4. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs +69 -53
  6. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
  8. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
  9. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +71 -33
  10. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
  11. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
  12. package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
  14. package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-modification.mjs +75 -122
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.mjs +100 -150
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-search.mjs +110 -134
  20. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-set-op.mjs +146 -38
  22. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  23. package/dist/array/impl/array-utils-size.mjs +10 -8
  24. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  25. package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
  26. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-slicing.mjs +94 -78
  28. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +291 -199
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.mjs +54 -56
  32. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  33. package/dist/array/impl/index.mjs +17 -17
  34. package/dist/array/impl/index.mjs.map +1 -1
  35. package/dist/array/index.mjs +2 -3
  36. package/dist/array/index.mjs.map +1 -1
  37. package/dist/collections/imap-mapped.mjs +335 -292
  38. package/dist/collections/imap-mapped.mjs.map +1 -1
  39. package/dist/collections/imap.mjs +280 -239
  40. package/dist/collections/imap.mjs.map +1 -1
  41. package/dist/collections/index.mjs +7 -7
  42. package/dist/collections/index.mjs.map +1 -1
  43. package/dist/collections/iset-mapped.mjs +448 -265
  44. package/dist/collections/iset-mapped.mjs.map +1 -1
  45. package/dist/collections/iset.mjs +328 -201
  46. package/dist/collections/iset.mjs.map +1 -1
  47. package/dist/collections/queue.mjs +183 -151
  48. package/dist/collections/queue.mjs.map +1 -1
  49. package/dist/collections/stack.mjs +169 -140
  50. package/dist/collections/stack.mjs.map +1 -1
  51. package/dist/entry-point.mjs +4 -77
  52. package/dist/entry-point.mjs.map +1 -1
  53. package/dist/expect-type.mjs +70 -4
  54. package/dist/expect-type.mjs.map +1 -1
  55. package/dist/functional/async-result/async-result.mjs +2 -3
  56. package/dist/functional/async-result/async-result.mjs.map +1 -1
  57. package/dist/functional/async-result/impl/async-result-flat-map.mjs +19 -21
  58. package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
  59. package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
  60. package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
  61. package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
  62. package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
  63. package/dist/functional/async-result/impl/async-result-map-err.mjs +16 -19
  64. package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
  65. package/dist/functional/async-result/impl/async-result-map.mjs +16 -19
  66. package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
  67. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +36 -9
  68. package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
  69. package/dist/functional/async-result/impl/index.mjs +8 -7
  70. package/dist/functional/async-result/impl/index.mjs.map +1 -1
  71. package/dist/functional/async-result/impl/types.mjs +2 -2
  72. package/dist/functional/async-result/impl/types.mjs.map +1 -1
  73. package/dist/functional/async-result/index.mjs +2 -3
  74. package/dist/functional/async-result/index.mjs.map +1 -1
  75. package/dist/functional/index.mjs +7 -11
  76. package/dist/functional/index.mjs.map +1 -1
  77. package/dist/functional/match.mjs +27 -13
  78. package/dist/functional/match.mjs.map +1 -1
  79. package/dist/functional/optional/impl/index.mjs +19 -18
  80. package/dist/functional/optional/impl/index.mjs.map +1 -1
  81. package/dist/functional/optional/impl/optional-expect-to-be.mjs +16 -18
  82. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  83. package/dist/functional/optional/impl/optional-filter.mjs +17 -19
  84. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  85. package/dist/functional/optional/impl/optional-flat-map.mjs +13 -15
  86. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  87. package/dist/functional/optional/impl/optional-from-nullable.mjs +26 -5
  88. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-is-none.mjs +21 -5
  90. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  91. package/dist/functional/optional/impl/optional-is-optional.mjs +26 -8
  92. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  93. package/dist/functional/optional/impl/optional-is-some.mjs +22 -5
  94. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  95. package/dist/functional/optional/impl/optional-map.mjs +16 -18
  96. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-match.mjs +16 -18
  98. package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-none.mjs +18 -5
  100. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  101. package/dist/functional/optional/impl/optional-or-else.mjs +13 -15
  102. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  103. package/dist/functional/optional/impl/optional-some.mjs +23 -7
  104. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  105. package/dist/functional/optional/impl/optional-to-nullable.mjs +28 -5
  106. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  107. package/dist/functional/optional/impl/optional-unwrap-or.mjs +12 -14
  108. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  109. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +34 -9
  110. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  111. package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
  112. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  113. package/dist/functional/optional/impl/optional-zip.mjs +36 -5
  114. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  115. package/dist/functional/optional/impl/tag.mjs +4 -5
  116. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  117. package/dist/functional/optional/impl/types.mjs +2 -2
  118. package/dist/functional/optional/impl/types.mjs.map +1 -1
  119. package/dist/functional/optional/index.mjs +2 -3
  120. package/dist/functional/optional/index.mjs.map +1 -1
  121. package/dist/functional/optional/optional.mjs +2 -3
  122. package/dist/functional/optional/optional.mjs.map +1 -1
  123. package/dist/functional/pipe.mjs +42 -14
  124. package/dist/functional/pipe.mjs.map +1 -1
  125. package/dist/functional/result/impl/index.mjs +28 -27
  126. package/dist/functional/result/impl/index.mjs.map +1 -1
  127. package/dist/functional/result/impl/result-err.mjs +29 -7
  128. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  129. package/dist/functional/result/impl/result-expect-to-be.mjs +17 -18
  130. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-flat-map.mjs +18 -21
  132. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-fold.mjs +18 -21
  134. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-from-optional.mjs +17 -20
  136. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
  137. package/dist/functional/result/impl/result-from-promise.mjs +37 -8
  138. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  139. package/dist/functional/result/impl/result-from-throwable.mjs +41 -14
  140. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  141. package/dist/functional/result/impl/result-is-err.mjs +21 -5
  142. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-is-ok.mjs +21 -5
  144. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  145. package/dist/functional/result/impl/result-is-result.mjs +25 -7
  146. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  147. package/dist/functional/result/impl/result-map-err.mjs +18 -21
  148. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  149. package/dist/functional/result/impl/result-map.mjs +18 -21
  150. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-match.mjs +17 -21
  152. package/dist/functional/result/impl/result-match.mjs.map +1 -1
  153. package/dist/functional/result/impl/result-ok.mjs +29 -7
  154. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  155. package/dist/functional/result/impl/result-or-else.mjs +14 -15
  156. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  157. package/dist/functional/result/impl/result-safe-try.mjs +32 -21
  158. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
  159. package/dist/functional/result/impl/result-safe-unwrap.mjs +40 -12
  160. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-swap.mjs +23 -8
  162. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  163. package/dist/functional/result/impl/result-to-optional.mjs +30 -7
  164. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  165. package/dist/functional/result/impl/result-unwrap-err-or.mjs +13 -14
  166. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  167. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +43 -20
  168. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  169. package/dist/functional/result/impl/result-unwrap-err.mjs +33 -8
  170. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  171. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +13 -14
  172. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  173. package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
  174. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  175. package/dist/functional/result/impl/result-unwrap-throw.mjs +38 -11
  176. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  177. package/dist/functional/result/impl/result-zip.mjs +35 -5
  178. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  179. package/dist/functional/result/impl/tag.mjs +4 -5
  180. package/dist/functional/result/impl/tag.mjs.map +1 -1
  181. package/dist/functional/result/impl/types.mjs +2 -2
  182. package/dist/functional/result/impl/types.mjs.map +1 -1
  183. package/dist/functional/result/index.mjs +2 -3
  184. package/dist/functional/result/index.mjs.map +1 -1
  185. package/dist/functional/result/result.mjs +2 -3
  186. package/dist/functional/result/result.mjs.map +1 -1
  187. package/dist/functional/ternary-result/impl/index.mjs +29 -28
  188. package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/tag.mjs +6 -6
  190. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  191. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +17 -7
  192. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +28 -32
  196. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
  198. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +21 -8
  200. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +28 -13
  202. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  203. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +19 -5
  204. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  205. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +21 -5
  206. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -8
  208. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +20 -5
  210. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
  212. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  213. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
  214. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
  216. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +18 -7
  218. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
  220. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +24 -10
  222. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +11 -14
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +30 -19
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +20 -8
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +11 -14
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +7 -9
  232. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +30 -22
  234. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +11 -14
  236. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  237. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +27 -17
  238. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  239. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +20 -8
  240. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  241. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +21 -8
  242. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  243. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +47 -19
  244. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  245. package/dist/functional/ternary-result/impl/types.mjs +2 -2
  246. package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
  247. package/dist/functional/ternary-result/impl/variant-name.mjs +12 -14
  248. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  249. package/dist/functional/ternary-result/index.mjs +2 -3
  250. package/dist/functional/ternary-result/index.mjs.map +1 -1
  251. package/dist/functional/ternary-result/ternary-result.mjs +2 -3
  252. package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
  253. package/dist/guard/has-key.mjs +43 -4
  254. package/dist/guard/has-key.mjs.map +1 -1
  255. package/dist/guard/index.mjs +8 -8
  256. package/dist/guard/index.mjs.map +1 -1
  257. package/dist/guard/is-non-empty-string.mjs +39 -4
  258. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +36 -4
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.mjs +46 -15
  262. package/dist/guard/is-primitive.mjs.map +1 -1
  263. package/dist/guard/is-record.mjs +89 -6
  264. package/dist/guard/is-record.mjs.map +1 -1
  265. package/dist/guard/is-type.mjs +404 -19
  266. package/dist/guard/is-type.mjs.map +1 -1
  267. package/dist/guard/key-is-in.mjs +42 -4
  268. package/dist/guard/key-is-in.mjs.map +1 -1
  269. package/dist/index.mjs +12 -65
  270. package/dist/index.mjs.map +1 -1
  271. package/dist/iterator/index.mjs +2 -2
  272. package/dist/iterator/index.mjs.map +1 -1
  273. package/dist/iterator/range.mjs +19 -57
  274. package/dist/iterator/range.mjs.map +1 -1
  275. package/dist/json/index.mjs +2 -2
  276. package/dist/json/index.mjs.map +1 -1
  277. package/dist/json/json.mjs +346 -105
  278. package/dist/json/json.mjs.map +1 -1
  279. package/dist/number/branded-types/finite-number.mjs +148 -137
  280. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  281. package/dist/number/branded-types/index.mjs +33 -33
  282. package/dist/number/branded-types/index.mjs.map +1 -1
  283. package/dist/number/branded-types/int.mjs +245 -209
  284. package/dist/number/branded-types/int.mjs.map +1 -1
  285. package/dist/number/branded-types/int16.mjs +141 -131
  286. package/dist/number/branded-types/int16.mjs.map +1 -1
  287. package/dist/number/branded-types/int32.mjs +141 -131
  288. package/dist/number/branded-types/int32.mjs.map +1 -1
  289. package/dist/number/branded-types/negative-finite-number.mjs +155 -149
  290. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  291. package/dist/number/branded-types/negative-int.mjs +125 -110
  292. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  293. package/dist/number/branded-types/negative-safe-int.mjs +126 -115
  294. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  295. package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
  296. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  297. package/dist/number/branded-types/non-negative-int16.mjs +137 -125
  298. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  299. package/dist/number/branded-types/non-negative-int32.mjs +137 -125
  300. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  301. package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
  302. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  303. package/dist/number/branded-types/non-positive-int.mjs +116 -99
  304. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  305. package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
  306. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  307. package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
  308. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  309. package/dist/number/branded-types/non-zero-int.mjs +102 -82
  310. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  311. package/dist/number/branded-types/non-zero-int16.mjs +118 -105
  312. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  313. package/dist/number/branded-types/non-zero-int32.mjs +118 -105
  314. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  315. package/dist/number/branded-types/non-zero-safe-int.mjs +122 -108
  316. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  317. package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
  318. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
  320. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  321. package/dist/number/branded-types/positive-finite-number.mjs +167 -160
  322. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  323. package/dist/number/branded-types/positive-int.mjs +260 -224
  324. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  325. package/dist/number/branded-types/positive-int16.mjs +134 -122
  326. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  327. package/dist/number/branded-types/positive-int32.mjs +134 -122
  328. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  329. package/dist/number/branded-types/positive-safe-int.mjs +292 -258
  330. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  331. package/dist/number/branded-types/positive-uint16.mjs +134 -122
  332. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  333. package/dist/number/branded-types/positive-uint32.mjs +134 -122
  334. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  335. package/dist/number/branded-types/safe-int.mjs +284 -255
  336. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  337. package/dist/number/branded-types/safe-uint.mjs +135 -124
  338. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  339. package/dist/number/branded-types/uint.mjs +248 -211
  340. package/dist/number/branded-types/uint.mjs.map +1 -1
  341. package/dist/number/branded-types/uint16.mjs +132 -121
  342. package/dist/number/branded-types/uint16.mjs.map +1 -1
  343. package/dist/number/branded-types/uint32.mjs +132 -121
  344. package/dist/number/branded-types/uint32.mjs.map +1 -1
  345. package/dist/number/enum/index.mjs +3 -3
  346. package/dist/number/enum/index.mjs.map +1 -1
  347. package/dist/number/enum/int8.mjs +146 -131
  348. package/dist/number/enum/int8.mjs.map +1 -1
  349. package/dist/number/enum/uint8.mjs +133 -119
  350. package/dist/number/enum/uint8.mjs.map +1 -1
  351. package/dist/number/index.mjs +6 -37
  352. package/dist/number/index.mjs.map +1 -1
  353. package/dist/number/num-arithmetic-types.mjs +42 -1
  354. package/dist/number/num-arithmetic-types.mjs.map +1 -1
  355. package/dist/number/num.mjs +541 -83
  356. package/dist/number/num.mjs.map +1 -1
  357. package/dist/number/refined-number-utils.mjs +294 -133
  358. package/dist/number/refined-number-utils.mjs.map +1 -1
  359. package/dist/object/index.mjs +2 -2
  360. package/dist/object/index.mjs.map +1 -1
  361. package/dist/object/object.mjs +355 -202
  362. package/dist/object/object.mjs.map +1 -1
  363. package/dist/others/cast-mutable.mjs +38 -11
  364. package/dist/others/cast-mutable.mjs.map +1 -1
  365. package/dist/others/cast-readonly.mjs +37 -11
  366. package/dist/others/cast-readonly.mjs.map +1 -1
  367. package/dist/others/debounce-function.mjs +22 -11
  368. package/dist/others/debounce-function.mjs.map +1 -1
  369. package/dist/others/fast-deep-equal.mjs +70 -51
  370. package/dist/others/fast-deep-equal.mjs.map +1 -1
  371. package/dist/others/if-then.mjs +32 -5
  372. package/dist/others/if-then.mjs.map +1 -1
  373. package/dist/others/index.mjs +10 -10
  374. package/dist/others/index.mjs.map +1 -1
  375. package/dist/others/map-nullable.mjs +11 -13
  376. package/dist/others/map-nullable.mjs.map +1 -1
  377. package/dist/others/memoize-function.mjs +14 -16
  378. package/dist/others/memoize-function.mjs.map +1 -1
  379. package/dist/others/tuple.mjs +52 -4
  380. package/dist/others/tuple.mjs.map +1 -1
  381. package/dist/others/unknown-to-string.mjs +91 -47
  382. package/dist/others/unknown-to-string.mjs.map +1 -1
  383. package/dist/promise/index.mjs +2 -2
  384. package/dist/promise/index.mjs.map +1 -1
  385. package/dist/promise/promise.mjs +51 -10
  386. package/dist/promise/promise.mjs.map +1 -1
  387. package/dist/string/index.mjs +2 -2
  388. package/dist/string/index.mjs.map +1 -1
  389. package/dist/string/str.mjs +250 -83
  390. package/dist/string/str.mjs.map +1 -1
  391. package/dist/types.mjs +3 -2
  392. package/dist/types.mjs.map +1 -1
  393. package/package.json +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"num.mjs","sources":["../../src/number/num.mts"],"sourcesContent":["import {\n type Decrement,\n type FiniteNumber,\n type Increment,\n type Index,\n type Int,\n type Min,\n type NaNType,\n type NegativeIndex,\n type NonNegativeNumber,\n type NonZeroNumber,\n type PositiveNumber,\n type PositiveSafeIntWithSmallInt,\n type RelaxedExclude,\n type SmallInt,\n type SmallUint,\n type UnknownBrand,\n} from 'ts-type-forge';\nimport { expectType } from '../expect-type.mjs';\nimport { Result } from '../functional/index.mjs';\nimport { type SmallPositiveInt } from '../types.mjs';\nimport {\n type AddResult,\n type DivIntResult,\n type DivResult,\n type MulResult,\n type SubResult,\n} from './num-arithmetic-types.mjs';\n\n/**\n * Namespace providing utility functions for number manipulation and validation.\n *\n * This namespace offers a comprehensive set of type-safe number utilities\n * including:\n *\n * - Type conversion and validation\n * - Type guards for numeric constraints (non-zero, non-negative, positive)\n * - Range checking and clamping operations\n * - Mathematical operations with type safety\n * - Rounding utilities\n *\n * Many functions in this namespace leverage TypeScript's type system to provide\n * compile-time guarantees about numeric constraints.\n */\nexport namespace Num {\n /**\n * Converts an unknown value to a number. Alias for the `Number` constructor.\n *\n * @example\n *\n * ```ts\n * const input = '123.45';\n *\n * const result = Num.from(input);\n *\n * assert.isTrue(result === 123.45);\n * ```\n *\n * @param n The value to convert.\n * @returns The numeric representation of `n`.\n */\n export const from: (n: unknown) => number = Number;\n\n /**\n * Safely parses a base-10 integer from a string, returning a {@link Result}\n * that is `Ok<Int>` for valid input and `Err<Error>` otherwise.\n *\n * This is a stricter alternative to both `parseInt` and `Number`:\n *\n * - Unlike `parseInt('12abc', 10)` (which returns `12`), trailing\n * non-numeric characters make the whole input invalid and yield `Err`.\n * - Unlike `Number('')` / `Number(' ')` (which return `0`), empty or\n * whitespace-only input yields `Err`.\n *\n * The empty-string case is rejected by delegating to `parseInt` (which\n * returns `NaN` there) rather than hard-coding a check, while the trailing-\n * garbage case is rejected via `Number`. Valid input is truncated toward\n * zero, so `'12.9'` becomes `12` and `'-3.5'` becomes `-3`.\n *\n * Only base 10 is supported. Use `Result.unwrapOk` (optionally with a\n * `?? Number.NaN` fallback) or `Result.unwrapOkOr` to get a plain number\n * back.\n *\n * @example\n *\n * ```ts\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseInt('123'), Number.NaN),\n * 123,\n * );\n *\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseInt('12.9'), Number.NaN),\n * 12,\n * );\n *\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseInt('-12.9'), Number.NaN),\n * -12,\n * );\n *\n * assert.strictEqual(Number.parseInt('-12.9', 10), -12);\n *\n * // Native `parseInt` ignores trailing non-numeric characters\n *\n * assert.strictEqual(Number.parseInt('123abc', 10), 123);\n *\n * assert.isTrue(Number.isNaN(Number('123abc')));\n *\n * assert.isTrue(Result.isErr(Num.safeParseInt('123abc')));\n *\n * // Whitespace is not a valid integer, so we return an error instead of coercing to 0.\n *\n * assert.isTrue(Number.isNaN(Number.parseInt(' ', 10)));\n *\n * assert.strictEqual(Number(' '), 0); // Native `Number` coerces whitespace to 0\n *\n * assert.isTrue(Result.isErr(Num.safeParseInt('')));\n *\n * assert.strictEqual(Result.unwrapOk(Num.safeParseInt(' ')), undefined);\n * ```\n *\n * @param s The string to parse.\n * @returns `Result.ok(parsedInt)` for valid input, otherwise `Result.err`\n * wrapping an `Error` describing the invalid input.\n */\n export const safeParseInt = (s: string): Result<Int, Error> => {\n const viaNumber = Number(s);\n\n // `Number('')` / `Number(' ')` は 0 を返すが、`parseInt` は NaN を返す。\n // 末尾不正文字 ('12abc' 等) は `Number` 側が NaN にするので、両者が共に\n // 有効な場合のみ採用することで空文字・空白のみ・末尾不正をまとめて弾く。\n return Number.isNaN(viaNumber) || Number.isNaN(Number.parseInt(s, 10))\n ? Result.err(\n new Error(`safeParseInt: \"${s}\" is not a valid base-10 integer`),\n )\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Result.ok(Math.trunc(viaNumber) as Int);\n };\n\n /**\n * Safely parses a finite floating-point number from a string, returning a\n * {@link Result} that is `Ok<FiniteNumber>` for valid input and `Err<Error>`\n * otherwise.\n *\n * This is a stricter alternative to both `parseFloat` and `Number`:\n *\n * - Unlike `parseFloat('12abc')` (which returns `12`), trailing non-numeric\n * characters make the whole input invalid and yield `Err`.\n * - Unlike `Number('')` / `Number(' ')` (which return `0`), empty or\n * whitespace-only input yields `Err`.\n * - Unlike `Number('Infinity')` (which returns `Infinity`), non-finite values\n * yield `Err`.\n *\n * The empty-string case is rejected by delegating to `parseFloat` (which\n * returns `NaN` there) rather than hard-coding a check, while the trailing-\n * garbage case is rejected via `Number`. Decimal values are preserved as-is,\n * so `'12.9'` stays `12.9`.\n *\n * Use `Result.unwrapOk` (optionally with a `?? Number.NaN` fallback) or\n * `Result.unwrapOkOr` to get a plain number back.\n *\n * @example\n *\n * ```ts\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseFloat('12.9'), Number.NaN),\n * 12.9,\n * );\n *\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseFloat('-3.5'), Number.NaN),\n * -3.5,\n * );\n *\n * assert.strictEqual(\n * Result.unwrapOkOr(Num.safeParseFloat('1e3'), Number.NaN),\n * 1000,\n * );\n *\n * // Native `parseFloat` ignores trailing non-numeric characters\n *\n * assert.strictEqual(Number.parseFloat('12px'), 12);\n *\n * assert.isTrue(Result.isErr(Num.safeParseFloat('12px')));\n *\n * // Whitespace is not a valid number, so we return an error instead of coercing to 0.\n *\n * assert.isTrue(Result.isErr(Num.safeParseFloat('')));\n *\n * assert.isTrue(Result.isErr(Num.safeParseFloat(' ')));\n *\n * // Infinity and NaN are not finite, so they are rejected.\n *\n * assert.isTrue(Result.isErr(Num.safeParseFloat('Infinity')));\n *\n * assert.isTrue(Result.isErr(Num.safeParseFloat('NaN')));\n * ```\n *\n * @param s The string to parse.\n * @returns `Result.ok(parsedFloat)` for valid finite input, otherwise\n * `Result.err` wrapping an `Error` describing the invalid input.\n */\n export const safeParseFloat = (s: string): Result<FiniteNumber, Error> => {\n const viaNumber = Number(s);\n\n // `Number('')` / `Number(' ')` は 0 を返すが、`parseFloat` は NaN を返す。\n // 末尾不正文字 ('12abc' 等) は `Number` 側が NaN にするので、両者が共に\n // 非 NaN かつ有限の場合のみ採用することで空文字・空白のみ・末尾不正・\n // Infinity をまとめて弾く。\n return Number.isNaN(viaNumber) ||\n !Number.isFinite(viaNumber) ||\n Number.isNaN(Number.parseFloat(s))\n ? Result.err(\n new Error(`safeParseFloat: \"${s}\" is not a valid finite number`),\n )\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Result.ok(viaNumber as FiniteNumber);\n };\n\n /**\n * Type guard that checks if a number is non-zero.\n *\n * When this function returns `true`, TypeScript narrows the type to exclude\n * zero, providing compile-time safety for division operations and other\n * calculations that require non-zero values.\n *\n * @example\n *\n * ```ts\n * const value: number = 5;\n *\n * if (Num.isNonZero(value)) {\n * // Safe to divide now that we know value is non-zero\n * // eslint-disable-next-line total-functions/no-partial-division\n * const inverted = 1 / value;\n *\n * assert.isTrue(inverted === 0.2);\n * }\n *\n * assert.isFalse(Num.isNonZero(0));\n * ```\n *\n * @template N - The numeric literal type or number type to check\n * @param num - The number to check\n * @returns `true` if the number is not zero, `false` otherwise\n */\n export const isNonZero = <N extends number>(\n num: N,\n ): num is NonZeroNumber & RelaxedExclude<N, 0> => num !== 0;\n\n expectType<NonZeroNumber & RelaxedExclude<123, 0>, UnknownBrand>('<=');\n\n /**\n * Type guard that checks if a number is non-negative (greater than or equal\n * to zero).\n *\n * When this function returns `true`, TypeScript narrows the type to exclude\n * negative values, which is useful for operations that require non-negative\n * inputs like array indices or measurements.\n *\n * @example\n *\n * ```ts\n * const candidate = 10;\n *\n * if (Num.isNonNegative(candidate)) {\n * const index: number = candidate;\n *\n * assert.isTrue(index === 10);\n * }\n *\n * assert.isFalse(Num.isNonNegative(-1));\n * ```\n *\n * @template N - The numeric literal type or number type to check\n * @param num - The number to check\n * @returns `true` if the number is >= 0, `false` otherwise\n */\n export const isNonNegative = <N extends number>(\n num: N,\n ): num is NonNegativeNumber & RelaxedExclude<N, NegativeIndex<1024>> =>\n num >= 0;\n\n /**\n * Type guard that checks if a number is positive (greater than zero).\n *\n * When this function returns `true`, TypeScript narrows the type to exclude\n * zero and negative values. This is particularly useful for validating inputs\n * that must be strictly positive, such as dimensions, counts, or rates.\n *\n * @example\n *\n * ```ts\n * const amount = 42;\n *\n * if (Num.isPositive(amount)) {\n * assert.isTrue(amount > 0);\n * }\n *\n * assert.isFalse(Num.isPositive(0));\n * ```\n *\n * @template N - The numeric literal type or number type to check\n * @param num - The number to check\n * @returns `true` if the number is > 0, `false` otherwise\n */\n export const isPositive = <N extends number>(\n num: N,\n ): num is PositiveNumber & RelaxedExclude<N, NegativeIndex<1024> | 0> =>\n num > 0;\n\n /**\n * Creates a function that checks if a number `x` is within the range\n * `lowerBound <= x < upperBound`.\n *\n * @example\n *\n * ```ts\n * const isGrade = Num.isInRange(0, 100);\n *\n * assert.isTrue(isGrade(50));\n *\n * assert.isFalse(isGrade(100));\n * ```\n *\n * @param lowerBound The lower bound (inclusive).\n * @param upperBound The upper bound (exclusive).\n * @returns A function that takes a number `x` and returns `true` if `x` is in\n * the range, `false` otherwise.\n */\n export const isInRange =\n (lowerBound: number, upperBound: number) =>\n (x: number): boolean =>\n lowerBound <= x && x < upperBound;\n\n /**\n * Creates a function that checks if a number `x` is within the range\n * `lowerBound <= x <= upperBound`.\n *\n * @example\n *\n * ```ts\n * const isPercentage = Num.isInRangeInclusive(0, 100);\n *\n * assert.isTrue(isPercentage(100));\n *\n * assert.isFalse(isPercentage(-1));\n * ```\n *\n * @param lowerBound The lower bound (inclusive).\n * @param upperBound The upper bound (inclusive).\n * @returns A function that takes a number `x` and returns `true` if `x` is in\n * the range, `false` otherwise.\n */\n export const isInRangeInclusive =\n (lowerBound: number, upperBound: number) =>\n (x: number): boolean =>\n lowerBound <= x && x <= upperBound;\n\n /**\n * @template N - A SmallUint representing the exclusive upper bound\n * @internal\n * Helper type mapping each SmallUint N to the union of integers from 0 to N-1.\n * Used internally for type-safe range operations.\n *\n * For example:\n * - LT[3] = 0 | 1 | 2\n * - LT[5] = 0 | 1 | 2 | 3 | 4\n */\n type LT = Readonly<{ [N in SmallUint]: Index<N> }>;\n\n /**\n * @template N - A SmallUint representing the inclusive upper bound\n * @internal\n * Helper type mapping each SmallUint N to the union of integers from 0 to N (inclusive).\n * Used internally for type-safe range operations with inclusive upper bounds.\n *\n * For example:\n * - LEQ[3] = 0 | 1 | 2 | 3\n * - LEQ[5] = 0 | 1 | 2 | 3 | 4 | 5\n */\n type LEQ = Readonly<{ [N in SmallUint]: Index<N> | N }>;\n\n /**\n * Creates a type guard that checks if a number is an unsigned integer within\n * a specified range.\n *\n * This function returns a predicate that validates whether a number is:\n *\n * - A safe integer (no floating point)\n * - Within the range [lowerBound, upperBound)\n *\n * The returned type guard provides precise type narrowing when the bounds are\n * SmallUint literals, making it ideal for array index validation.\n *\n * @example\n *\n * ```ts\n * const indexGuard = Num.isUintInRange(0, 5);\n *\n * assert.isTrue(indexGuard(3));\n *\n * assert.isFalse(indexGuard(5));\n *\n * assert.isFalse(indexGuard(-1));\n * ```\n *\n * @template L - The lower bound as a SmallUint literal type\n * @template U - The upper bound as a SmallUint literal type\n * @param lowerBound - The minimum value (inclusive)\n * @param upperBound - The maximum value (exclusive)\n * @returns A type guard function that validates and narrows number types\n */\n export const isUintInRange =\n <L extends SmallUint, U extends SmallUint>(lowerBound: L, upperBound: U) =>\n (x: number): x is RelaxedExclude<LT[U], LT[Min<L>]> =>\n Number.isSafeInteger(x) && lowerBound <= x && x < upperBound;\n\n /**\n * Creates a type guard that checks if a number is an unsigned integer within\n * a specified inclusive range.\n *\n * This function returns a predicate that validates whether a number is:\n *\n * - A safe integer (no floating point)\n * - Within the range [lowerBound, upperBound] (both bounds inclusive)\n *\n * The returned type guard provides precise type narrowing when the bounds are\n * SmallUint literals, useful for validating scores, percentages, or other\n * bounded values.\n *\n * @example\n *\n * ```ts\n * const inclusiveGuard = Num.isUintInRangeInclusive(0, 5);\n *\n * assert.isTrue(inclusiveGuard(5));\n *\n * assert.isFalse(inclusiveGuard(6));\n * ```\n *\n * @template L - The lower bound as a SmallUint literal type\n * @template U - The upper bound as a SmallUint literal type\n * @param lowerBound - The minimum value (inclusive)\n * @param upperBound - The maximum value (inclusive)\n * @returns A type guard function that validates and narrows number types\n */\n export const isUintInRangeInclusive =\n <L extends SmallUint, U extends SmallUint>(lowerBound: L, upperBound: U) =>\n (x: number): x is RelaxedExclude<LEQ[U], LT[Min<L>]> =>\n Number.isSafeInteger(x) && lowerBound <= x && x <= upperBound;\n\n /**\n * Clamps a value within the given range. If the target value is invalid (not\n * finite), returns the lower bound.\n *\n * Provides two usage patterns for maximum flexibility:\n *\n * - **Direct usage**: Pass all three arguments to get the clamped value\n * immediately\n * - **Curried usage**: Pass bounds to get a reusable clamping function\n *\n * @example\n *\n * ```ts\n * assert.isTrue(Num.clamp(150, 0, 100) === 100);\n *\n * assert.isTrue(Num.clamp(-50, 0, 100) === 0);\n *\n * const clampToPercentage = Num.clamp(0, 100);\n *\n * assert.isTrue(clampToPercentage(75) === 75);\n *\n * assert.isTrue(clampToPercentage(150) === 100);\n * ```\n */\n export function clamp(\n target: number,\n lowerBound: number,\n upperBound: number,\n ): number;\n\n // Curried version\n export function clamp(\n lowerBound: number,\n upperBound: number,\n ): (target: number) => number;\n\n export function clamp(\n ...args:\n | readonly [target: number, lowerBound: number, upperBound: number]\n | readonly [lowerBound: number, upperBound: number]\n ): number | ((target: number) => number) {\n switch (args.length) {\n case 3: {\n const [target, lowerBound, upperBound] = args;\n\n return !Number.isFinite(target)\n ? lowerBound\n : Math.max(lowerBound, Math.min(upperBound, target));\n }\n\n case 2: {\n const [lowerBound, upperBound] = args;\n\n return (target: number): number =>\n clamp(target, lowerBound, upperBound);\n }\n }\n }\n\n /**\n * Adds two numbers, returning the tightest sound branded result type.\n *\n * The sign of the result is computed exactly (e.g. a non-negative plus a\n * non-negative is non-negative); the integer/finite level is preserved, with\n * `SafeInt` operands widening to `Int` because the sum may exceed the safe\n * range. No clamping is performed — for a result that stays inside a bounded\n * type, use that type's branded `add` instead.\n *\n * @param a - The first addend.\n * @param b - The second addend.\n * @returns `a + b`, typed as the tightest branded type guaranteed to contain\n * it.\n */\n export const add = <A extends number, B extends number>(\n a: A,\n b: B,\n ): AddResult<A, B> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (a + b) as AddResult<A, B>;\n\n /**\n * Subtracts `b` from `a`, returning the tightest sound branded result type.\n *\n * The sign is computed exactly; the level is preserved (with `SafeInt`\n * widening to `Int`). No clamping — for saturating subtraction that stays in a\n * bounded type (e.g. `Uint.sub` clamping at `0`), use that type's branded\n * `sub`.\n *\n * @param a - The minuend.\n * @param b - The subtrahend.\n * @returns `a - b`, typed as the tightest branded type guaranteed to contain\n * it.\n */\n export const sub = <A extends number, B extends number>(\n a: A,\n b: B,\n ): SubResult<A, B> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (a - b) as SubResult<A, B>;\n\n /**\n * Multiplies two numbers, returning the tightest sound branded result type.\n *\n * The sign follows the usual product rule (e.g. negative times negative is\n * positive); the level is preserved (with `SafeInt` widening to `Int`). No\n * clamping.\n *\n * @param a - The first factor.\n * @param b - The second factor.\n * @returns `a * b`, typed as the tightest branded type guaranteed to contain\n * it.\n */\n export const mul = <A extends number, B extends number>(\n a: A,\n b: B,\n ): MulResult<A, B> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (a * b) as MulResult<A, B>;\n\n /**\n * Performs type-safe exact division with a compile-time zero-check.\n *\n * The divisor must be typed as `NonZeroNumber` or a non-zero numeric literal.\n * The result sign follows the quotient rule; because exact division can be\n * fractional, the level is `finite` (or `number`).\n *\n * @param a - The dividend.\n * @param b - The divisor (must be non-zero, enforced by types).\n * @returns `a / b`, typed as the tightest branded type guaranteed to contain\n * it.\n */\n export const div = <\n A extends number,\n B extends NonZeroNumber | SmallInt<'!=0'>,\n >(\n a: A,\n b: B,\n ): DivResult<A, B> =>\n // eslint-disable-next-line total-functions/no-partial-division, total-functions/no-unsafe-type-assertion\n (a / b) as DivResult<A, B>;\n\n /**\n * Performs integer division using floor division.\n *\n * Computes `⌊a / b⌋` by flooring both operands before division and then\n * flooring the result. This ensures integer arithmetic semantics.\n *\n * Note: Unlike `div`, this function does not enforce non-zero divisor at\n * compile time. Division by zero returns `NaN`.\n *\n * @param a - The dividend\n * @param b - The divisor\n * @returns The integer quotient, or `NaN` if b is zero\n */\n export const divInt = <\n A extends number,\n B extends NonZeroNumber | SmallInt<'!=0'>,\n >(\n a: A,\n b: B,\n ): DivIntResult<A, B> => {\n // eslint-disable-next-line total-functions/no-partial-division\n const quotient = Math.floor(Math.floor(a) / Math.floor(b));\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return quotient as DivIntResult<A, B>;\n };\n\n /**\n * Rounds a number to a specified number of decimal places.\n *\n * Uses the standard rounding algorithm (round half up) to round the number to\n * the given precision. The precision must be a positive safe integer.\n *\n * @param num - The number to round\n * @param precision - The number of decimal places (must be positive)\n * @returns The rounded number\n */\n export const roundAt = (\n num: number,\n precision: PositiveSafeIntWithSmallInt,\n ): number => {\n const digit = 10 ** precision;\n\n // eslint-disable-next-line total-functions/no-partial-division\n return Math.round(num * digit) / digit;\n };\n\n /**\n * Rounds a number to the nearest integer using bitwise operations.\n *\n * This function uses a bitwise OR trick for potentially faster rounding.\n * Note: This implementation rounds half up for positive numbers but may\n * behave differently for negative numbers compared to Math.round.\n *\n * @param num - The number to round\n * @returns The rounded integer as an Int branded type\n */\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n export const roundToInt = (num: number): Int => Math.trunc(num + 0.5) as Int;\n\n /**\n * Creates a reusable rounding function with a fixed precision.\n *\n * This is a curried version of roundAt that returns a function configured to\n * always round to the specified number of decimal places. Useful for creating\n * consistent rounding behavior across multiple values.\n *\n * @param digit - The number of decimal places for rounding\n * @returns A function that rounds numbers to the specified precision\n */\n export const round = (\n digit: PositiveSafeIntWithSmallInt,\n ): ((num: number) => number) => {\n const powAmount = 10 ** digit;\n\n return (target: number) =>\n // eslint-disable-next-line total-functions/no-partial-division\n roundToInt(powAmount * target) / powAmount;\n };\n\n /**\n * Converts NaN values to undefined while preserving all other numbers.\n *\n * This function is useful for handling potentially invalid numeric operations\n * in a type-safe way, converting NaN results to undefined for easier handling\n * with optional chaining or nullish coalescing.\n *\n * @template N - The numeric type (literal or number)\n * @param num - The number to check\n * @returns The original number if not NaN, otherwise undefined\n */\n export const mapNaN2Undefined = <N extends number>(\n num: N,\n ): RelaxedExclude<N, NaNType> | undefined =>\n Number.isNaN(num)\n ? undefined\n : // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (num as RelaxedExclude<N, NaNType>);\n\n /**\n * Type-safe increment operation for SmallUint values.\n *\n * Increments a SmallUint (0-40) by 1 with the result type computed at compile\n * time. This provides type-level arithmetic for small unsigned integers,\n * useful for type-safe counter operations.\n *\n * @template N - A SmallUint literal type (0-40)\n * @param n - The SmallUint value to increment\n * @returns The incremented value with type Increment<N>\n */\n export const increment = <N extends SmallUint>(n: N): Increment<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (n + 1) as Increment<N>;\n\n /**\n * Type-safe decrement operation for positive SmallInt values.\n *\n * Decrements a positive SmallInt (1-40) by 1 with the result type computed at\n * compile time. This provides type-level arithmetic for small positive\n * integers, useful for type-safe countdown operations.\n *\n * @template N - A positive SmallInt literal type (1-40)\n * @param n - The positive SmallInt value to decrement\n * @returns The decremented value with type Decrement<N>\n */\n export const decrement = <N extends SmallPositiveInt>(n: N): Decrement<N> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (n - 1) as Decrement<N>;\n}\n"],"names":["Num","Result.err","Result.ok"],"mappings":";;;;IA4CiB;AAAA,CAAV,CAAUA,IAAAA,KAAV;AAiBE,EAAMA,KAAA,IAAA,GAA+B,MAAA;AAiErC,EAAMA,IAAAA,CAAA,YAAA,GAAe,CAAC,CAAA,KAAkC;AAC7D,IAAA,MAAM,SAAA,GAAY,OAAO,CAAC,CAAA;AAK1B,IAAA,OAAO,MAAA,CAAO,KAAA,CAAM,SAAS,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,QAAA,CAAS,CAAA,EAAG,EAAE,CAAC,CAAA,GACjEC,GAAO;AAAA,MACL,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,CAAC,CAAA,gCAAA,CAAkC;AAAA,KACjE;AAAA;AAAA,MAEAC,EAAO,CAAG,IAAA,CAAK,KAAA,CAAM,SAAS,CAAQ;AAAA,KAAA;AAAA,EAAA,CAC5C;AAiEO,EAAMF,IAAAA,CAAA,cAAA,GAAiB,CAAC,CAAA,KAA2C;AACxE,IAAA,MAAM,SAAA,GAAY,OAAO,CAAC,CAAA;AAM1B,IAAA,OAAO,OAAO,KAAA,CAAM,SAAS,CAAA,IAC3B,CAAC,OAAO,QAAA,CAAS,SAAS,CAAA,IAC1B,MAAA,CAAO,MAAM,MAAA,CAAO,UAAA,CAAW,CAAC,CAAC,IAC/BC,GAAO;AAAA,MACL,IAAI,KAAA,CAAM,CAAA,iBAAA,EAAoB,CAAC,CAAA,8BAAA,CAAgC;AAAA,KACjE;AAAA;AAAA,MAEAC,GAAU,S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AAC,GAAG,KAAK,CAAC;IACzC,CAAC,CAAC;IAEF;;;;;;;;;OASG;IACH,oEAAoE;IACvD,cAAU,GAAG,CAAC,GAAW,EAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAQ,CAAC;IAE7E;;;;;;;;;OASG;IACU,SAAK,GAAG,CACnB,KAAkC,EACP,EAAE;QAC7B,MAAM,SAAS,GAAG,EAAE,IAAI,KAAK,CAAC;QAE9B,OAAO,CAAC,MAAc,EAAE,EAAE;QACxB,+DAA+D;QAC/D,cAAU,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC;IAC/C,CAAC,CAAC;IAEF;;;;;;;;;;OAUG;IACU,oBAAgB,GAAG,CAC9B,GAAM,EACkC,EAAE,CAC1C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACf,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,oEAAoE;YACnE,GAAkC,CAAC;IAE1C;;;;;;;;;;OAUG;IACU,aAAS,GAAG,CAAsB,CAAI,EAAgB,EAAE;IACnE,oEAAoE;IACpE,CAAC,CAAC,GAAG,CAAC,CAAiB,CAAC;IAE1B;;;;;;;;;;OAUG;IACU,aAAS,GAAG,CAA6B,CAAI,EAAgB,EAAE;IAC1E,oEAAoE;IACpE,CAAC,CAAC,GAAG,CAAC,CAAiB,CAAC;AAC5B,CAAC,EAtqBgB,GAAG,KAAH,GAAG,QAsqBnB"}
@@ -1,136 +1,297 @@
1
- import '@sindresorhus/is';
2
- import { pipe } from '../functional/pipe.mjs';
1
+
2
+ import { pipe } from '../functional/index.mjs';
3
3
  import { Num } from './num.mjs';
4
+ /** @internal */
5
+ export var TsDataForgeInternals;
6
+ (function (TsDataForgeInternals) {
7
+ /**
8
+ * Internal utilities for creating and managing refined (branded) number
9
+ * types.
10
+ *
11
+ * This namespace provides factory functions and type utilities for building
12
+ * type-safe numeric operations with compile-time constraints. It serves as
13
+ * the foundation for all branded number types in the library, including:
14
+ *
15
+ * - Integer types (Int, SafeInt, Int8, Int16, Int32)
16
+ * - Unsigned types (UInt, UInt8, UInt16, UInt32)
17
+ * - Constrained types (NonZero, NonNegative, Positive)
18
+ * - Range-bounded types
19
+ *
20
+ * The utilities handle:
21
+ *
22
+ * - Type validation and narrowing
23
+ * - Arithmetic operations that preserve type constraints
24
+ * - Automatic clamping for bounded types
25
+ * - Random number generation within type bounds
26
+ *
27
+ * @internal This namespace is not part of the public API
28
+ */
29
+ let RefinedNumberUtils;
30
+ (function (RefinedNumberUtils) {
31
+ const castTypeImpl = (is, typeNameInErrorMessage) => (a) => {
32
+ if (!is(a)) {
33
+ throw new TypeError(`Expected ${typeNameInErrorMessage}, got: ${a}`);
34
+ }
35
+ return a;
36
+ };
37
+ const isNonZero = (n) => n !== 0;
38
+
4
39
 
5
- var TsDataForgeInternals;
6
- ((TsDataForgeInternals2) => {
7
- ((RefinedNumberUtils2) => {
8
- const castTypeImpl = (is, typeNameInErrorMessage) => (a) => {
9
- if (!is(a)) {
10
- throw new TypeError(`Expected ${typeNameInErrorMessage}, got: ${a}`);
11
- }
12
- return a;
13
- };
14
- const isNonZero = (n) => n !== 0;
15
- const isFnOrUndefined = (min, max) => min === void 0 ? max === void 0 ? void 0 : (n) => n <= max : max === void 0 ? (n) => min <= n : Num.isInRangeInclusive(min, max);
16
- const clampFnOrUndefined = (min, max) => min === void 0 ? max === void 0 ? void 0 : (n) => Math.min(max, n) : max === void 0 ? (n) => Math.max(min, n) : Num.clamp(min, max);
17
- RefinedNumberUtils2.operatorsForInteger = ({
18
- integerOrSafeInteger,
19
- nonZero,
20
- MIN_VALUE,
21
- MAX_VALUE,
22
- typeNameInMessage
23
- }) => {
24
- const is = (a) => (integerOrSafeInteger === "Integer" ? Number.isInteger(a) : Number.isSafeInteger(a)) && (nonZero === true ? a !== 0 : true) && (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
25
- const castType = castTypeImpl(is, typeNameInMessage);
26
- const fromNumber = pipe(
27
- clampFnOrUndefined(MIN_VALUE, MAX_VALUE)
28
- ).mapNullable(
29
- (cl) => (x) => castType(Math.round(cl(x)))
30
- ).value;
31
- const clampOrCastFn = fromNumber ?? castType;
32
- const abs = (x) => (
33
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
34
- Math.abs(clampOrCastFn(x))
35
- );
36
- const min_ = (...values) => clampOrCastFn(Math.min(...values));
37
- const max_ = (...values) => clampOrCastFn(Math.max(...values));
38
- const pow = (x, y) => clampOrCastFn(x ** y);
39
- const add = (x, y) => clampOrCastFn(x + y);
40
- const sub = (x, y) => clampOrCastFn(x - y);
41
- const mul = (x, y) => clampOrCastFn(x * y);
42
- const div = (x, y) => clampOrCastFn(
43
- Math.floor(
44
- // eslint-disable-next-line total-functions/no-partial-division
45
- x / y
46
- )
47
- );
48
- const randomImpl = (min = MIN_VALUE, max = MAX_VALUE) => min + Math.floor((Math.max(max, min) - min + 1) * Math.random());
49
- const random = (min, max) => clampOrCastFn(randomImpl(min, max));
50
- const randomNonZero = (min, max) => {
51
- while (true) {
52
- const r = randomImpl(min, max);
53
- if (Num.isNonZero(r)) return clampOrCastFn(r);
54
- }
55
- };
56
- return {
57
- MIN_VALUE,
58
- MAX_VALUE,
59
- is,
60
- abs,
61
- min: min_,
62
- max: max_,
63
- pow,
64
- add,
65
- sub,
66
- mul,
67
- div,
68
- random,
69
- randomNonZero,
70
- castType,
71
- fromNumber: (
72
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
73
- fromNumber
74
- )
75
- };
76
- };
77
- RefinedNumberUtils2.operatorsForFloat = ({
78
- nonZero,
79
- MIN_VALUE,
80
- MAX_VALUE,
81
- typeNameInMessage
82
- }) => {
83
- const is = (a) => Number.isFinite(a) && (nonZero === true ? a !== 0 : true) && (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
84
- const castType = castTypeImpl(is, typeNameInMessage);
85
- const fromNumber = pipe(
86
- clampFnOrUndefined(MIN_VALUE, MAX_VALUE)
87
- ).mapNullable(
88
- (cl) => (x) => castType(cl(x))
89
- ).value;
90
- const clampOrCastFn = fromNumber ?? castType;
91
- const abs = (x) => (
92
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
93
- Math.abs(x)
94
- );
95
- const min_ = (...values) => clampOrCastFn(Math.min(...values));
96
- const max_ = (...values) => clampOrCastFn(Math.max(...values));
97
- const pow = (x, y) => clampOrCastFn(x ** y);
98
- const add = (x, y) => clampOrCastFn(x + y);
99
- const sub = (x, y) => clampOrCastFn(x - y);
100
- const mul = (x, y) => clampOrCastFn(x * y);
101
- const div = (x, y) => (
102
- // eslint-disable-next-line total-functions/no-partial-division
103
- clampOrCastFn(x / y)
104
- );
105
- const randomImpl = (min = MIN_VALUE, max = MAX_VALUE) => min + (Math.max(max, min) - min) * Math.random();
106
- const random = (min, max) => clampOrCastFn(randomImpl(min, max));
107
- const randomNonZero = (min, max) => {
108
- while (true) {
109
- const r = random(min, max);
110
- if (isNonZero(r)) return r;
111
- }
112
- };
113
- return {
114
- MIN_VALUE,
115
- MAX_VALUE,
116
- is,
117
- abs,
118
- min: min_,
119
- max: max_,
120
- pow,
121
- add,
122
- sub,
123
- mul,
124
- div,
125
- random,
126
- randomNonZero,
127
- castType,
128
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
129
- fromNumber
130
- };
131
- };
132
- })(TsDataForgeInternals2.RefinedNumberUtils || (TsDataForgeInternals2.RefinedNumberUtils = {}));
133
- })(TsDataForgeInternals || (TsDataForgeInternals = {}));
134
40
 
135
- export { TsDataForgeInternals };
136
- //# sourceMappingURL=refined-number-utils.mjs.map
41
+
42
+
43
+ const isFnOrUndefined = (min, max) => min === undefined
44
+ ? max === undefined
45
+ ? undefined
46
+ : (n) => n <= max
47
+ : max === undefined
48
+ ? (n) => min <= n
49
+ : Num.isInRangeInclusive(min, max);
50
+ const clampFnOrUndefined = (min, max) => min === undefined
51
+ ? max === undefined
52
+ ? undefined
53
+ : (n) => Math.min(max, n)
54
+ : max === undefined
55
+ ? (n) => Math.max(min, n)
56
+ : Num.clamp(min, max);
57
+ /**
58
+ * Factory function that creates a complete set of type-safe operations for
59
+ * integer types.
60
+ *
61
+ * This function generates:
62
+ *
63
+ * - Type guards and validators
64
+ * - Arithmetic operations that preserve type constraints
65
+ * - Utility functions (min, max, abs, random)
66
+ * - Automatic clamping for bounded types
67
+ *
68
+ * All operations ensure results remain within the type's constraints, using
69
+ * clamping when bounds are specified.
70
+ *
71
+ * @example
72
+ *
73
+ * ```ts
74
+ * const intOps = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<
75
+ * SafeInt,
76
+ * number,
77
+ * number
78
+ * >({
79
+ * integerOrSafeInteger: 'SafeInteger',
80
+ * MIN_VALUE: Number.MIN_SAFE_INTEGER,
81
+ * MAX_VALUE: Number.MAX_SAFE_INTEGER,
82
+ * typeNameInMessage: 'SafeInt',
83
+ * } as const);
84
+ *
85
+ * const six = intOps.castType(6);
86
+ *
87
+ * const four = intOps.castType(4);
88
+ *
89
+ * const sum = intOps.add(six, four);
90
+ *
91
+ * const difference = intOps.sub(six, four);
92
+ *
93
+ * const product = intOps.mul(six, four);
94
+ *
95
+ * const quotient = intOps.div(six, intOps.castType(2));
96
+ *
97
+ * const coerced = intOps.fromNumber(1.5);
98
+ *
99
+ * const randomValue = intOps.random();
100
+ *
101
+ * assert.isTrue(sum === 10);
102
+ *
103
+ * assert.isTrue(difference === 2);
104
+ *
105
+ * assert.isTrue(product === 24);
106
+ *
107
+ * assert.isTrue(quotient === 3);
108
+ *
109
+ * assert.isTrue(coerced === 2);
110
+ *
111
+ * assert.isTrue(Number.isSafeInteger(randomValue));
112
+ * ```
113
+ *
114
+ * @template ElementType - The integer branded type
115
+ * @template MIN_VALUE - Optional minimum value for bounded types
116
+ * @template MAX_VALUE - Optional maximum value for bounded types
117
+ * @param config - Configuration object
118
+ * @param config.integerOrSafeInteger - Whether to use Number.isInteger or
119
+ * Number.isSafeInteger
120
+ * @param config.nonZero - If true, excludes zero from valid values
121
+ * @param config.MIN_VALUE - Minimum valid value (inclusive)
122
+ * @param config.MAX_VALUE - Maximum valid value (inclusive)
123
+ * @param config.typeNameInMessage - Human-readable type name for error
124
+ * messages
125
+ * @returns Object containing all type-safe operations for the integer type
126
+ * @internal
127
+ */
128
+ RefinedNumberUtils.operatorsForInteger = ({ integerOrSafeInteger, nonZero, MIN_VALUE, MAX_VALUE, typeNameInMessage, }) => {
129
+ const is = (a) => (integerOrSafeInteger === 'Integer'
130
+ ? Number.isInteger(a)
131
+ : Number.isSafeInteger(a)) &&
132
+ (nonZero === true ? a !== 0 : true) &&
133
+ (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
134
+ const castType = castTypeImpl(is, typeNameInMessage);
135
+ const fromNumber = pipe(clampFnOrUndefined(MIN_VALUE, MAX_VALUE)).mapNullable((cl) => (x) => castType(Math.round(cl(x)))).value;
136
+ const clampOrCastFn = fromNumber ?? castType;
137
+ const abs = (x) =>
138
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
139
+ Math.abs(clampOrCastFn(x));
140
+ const min_ = (...values) => clampOrCastFn(Math.min(...values));
141
+ const max_ = (...values) => clampOrCastFn(Math.max(...values));
142
+ const pow = (x, y) => clampOrCastFn(x ** y);
143
+ const add = (x, y) => clampOrCastFn(x + y);
144
+ const sub = (x, y) => clampOrCastFn(x - y);
145
+ const mul = (x, y) => clampOrCastFn(x * y);
146
+ const div = (x, y) => clampOrCastFn(Math.floor(
147
+ // eslint-disable-next-line total-functions/no-partial-division
148
+ x / y));
149
+ const randomImpl = (min = MIN_VALUE, max = MAX_VALUE) => min + Math.floor((Math.max(max, min) - min + 1) * Math.random());
150
+ // [-5, 5] -> floor(11 * Math.random()) + (-5)
151
+ const random = (min, max) => clampOrCastFn(randomImpl(min, max));
152
+ const randomNonZero = (min, max) => {
153
+ while (true) {
154
+ const r = randomImpl(min, max);
155
+ if (Num.isNonZero(r))
156
+ return clampOrCastFn(r);
157
+ }
158
+ };
159
+ return {
160
+ MIN_VALUE,
161
+ MAX_VALUE,
162
+ is,
163
+ abs,
164
+ min: min_,
165
+ max: max_,
166
+ pow,
167
+ add,
168
+ sub,
169
+ mul,
170
+ div,
171
+ random,
172
+ randomNonZero,
173
+ castType,
174
+ fromNumber:
175
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
176
+ fromNumber,
177
+ };
178
+ };
179
+ /**
180
+ * Factory function that creates a complete set of type-safe operations for
181
+ * floating-point types.
182
+ *
183
+ * This function generates:
184
+ *
185
+ * - Type guards and validators (checking for finite values)
186
+ * - Arithmetic operations that preserve type constraints
187
+ * - Utility functions (min, max, abs, random)
188
+ * - Automatic clamping for bounded types
189
+ *
190
+ * All operations ensure results remain finite and within any specified
191
+ * bounds. Division by zero is prevented through type constraints.
192
+ *
193
+ * @example
194
+ *
195
+ * ```ts
196
+ * const floatOps = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<
197
+ * PositiveFiniteNumber,
198
+ * number,
199
+ * number
200
+ * >({
201
+ * nonZero: true,
202
+ * MIN_VALUE: Number.MIN_VALUE,
203
+ * MAX_VALUE: Number.MAX_VALUE,
204
+ * typeNameInMessage: 'PositiveFiniteNumber',
205
+ * } as const);
206
+ *
207
+ * const fortyTwo = floatOps.castType(42.5);
208
+ *
209
+ * const seven = floatOps.castType(7.5);
210
+ *
211
+ * const sum = floatOps.add(fortyTwo, seven);
212
+ *
213
+ * const ratio = floatOps.div(sum, floatOps.castType(10));
214
+ *
215
+ * const coerced = floatOps.fromNumber(0);
216
+ *
217
+ * const boundedRandom = floatOps.random(
218
+ * floatOps.castType(10),
219
+ * floatOps.castType(20),
220
+ * );
221
+ *
222
+ * const nonZeroRandom = floatOps.randomNonZero();
223
+ *
224
+ * assert.isTrue(sum === 50);
225
+ *
226
+ * assert.isTrue(ratio === 5);
227
+ *
228
+ * assert.isTrue(coerced >= Number.MIN_VALUE);
229
+ *
230
+ * assert.isTrue(boundedRandom >= 10 && boundedRandom <= 20);
231
+ *
232
+ * assert.isTrue(nonZeroRandom > 0);
233
+ * ```
234
+ *
235
+ * @template ElementType - The floating-point branded type
236
+ * @template MIN_VALUE - Optional minimum value for bounded types
237
+ * @template MAX_VALUE - Optional maximum value for bounded types
238
+ * @param config - Configuration object
239
+ * @param config.nonZero - If true, excludes zero from valid values
240
+ * @param config.MIN_VALUE - Minimum valid value (inclusive)
241
+ * @param config.MAX_VALUE - Maximum valid value (inclusive)
242
+ * @param config.typeNameInMessage - Human-readable type name for error
243
+ * messages
244
+ * @returns Object containing all type-safe operations for the
245
+ * floating-point type
246
+ * @internal
247
+ */
248
+ RefinedNumberUtils.operatorsForFloat = ({ nonZero, MIN_VALUE, MAX_VALUE, typeNameInMessage, }) => {
249
+ const is = (a) => Number.isFinite(a) &&
250
+ (nonZero === true ? a !== 0 : true) &&
251
+ (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);
252
+ const castType = castTypeImpl(is, typeNameInMessage);
253
+ const fromNumber = pipe(clampFnOrUndefined(MIN_VALUE, MAX_VALUE)).mapNullable((cl) => (x) => castType(cl(x))).value;
254
+ const clampOrCastFn = fromNumber ?? castType;
255
+ const abs = (x) =>
256
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
257
+ Math.abs(x);
258
+ const min_ = (...values) => clampOrCastFn(Math.min(...values));
259
+ const max_ = (...values) => clampOrCastFn(Math.max(...values));
260
+ const pow = (x, y) => clampOrCastFn(x ** y);
261
+ const add = (x, y) => clampOrCastFn(x + y);
262
+ const sub = (x, y) => clampOrCastFn(x - y);
263
+ const mul = (x, y) => clampOrCastFn(x * y);
264
+ const div = (x, y) =>
265
+ // eslint-disable-next-line total-functions/no-partial-division
266
+ clampOrCastFn(x / y);
267
+ const randomImpl = (min = MIN_VALUE, max = MAX_VALUE) => min + (Math.max(max, min) - min) * Math.random();
268
+ const random = (min, max) => clampOrCastFn(randomImpl(min, max));
269
+ const randomNonZero = (min, max) => {
270
+ while (true) {
271
+ const r = random(min, max);
272
+ if (isNonZero(r))
273
+ return r;
274
+ }
275
+ };
276
+ return {
277
+ MIN_VALUE,
278
+ MAX_VALUE,
279
+ is,
280
+ abs,
281
+ min: min_,
282
+ max: max_,
283
+ pow,
284
+ add,
285
+ sub,
286
+ mul,
287
+ div,
288
+ random,
289
+ randomNonZero,
290
+ castType,
291
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
292
+ fromNumber: fromNumber,
293
+ };
294
+ };
295
+ })(RefinedNumberUtils = TsDataForgeInternals.RefinedNumberUtils || (TsDataForgeInternals.RefinedNumberUtils = {}));
296
+ })(TsDataForgeInternals || (TsDataForgeInternals = {}));
297
+ //# sourceMappingURL=refined-number-utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"refined-number-utils.mjs","sources":["../../src/number/refined-number-utils.mts"],"sourcesContent":["import {\n type Brand,\n type ChangeBaseBrand,\n type GetBrandValuePart,\n type Int,\n type IntersectBrand,\n type NonNegativeNumber,\n type NonZeroNumber,\n type PositiveNumber,\n type RelaxedExclude,\n type StrictPick,\n type TypeEq,\n type UnknownBrand,\n type UnwrapBrandFalseKeys,\n type UnwrapBrandTrueKeys,\n type WithSmallInt,\n} from 'ts-type-forge';\nimport { expectType } from '../expect-type.mjs';\nimport { pipe } from '../functional/index.mjs';\nimport { Num } from './num.mjs';\n\n/** @internal */\nexport namespace TsDataForgeInternals {\n /**\n * Internal utilities for creating and managing refined (branded) number\n * types.\n *\n * This namespace provides factory functions and type utilities for building\n * type-safe numeric operations with compile-time constraints. It serves as\n * the foundation for all branded number types in the library, including:\n *\n * - Integer types (Int, SafeInt, Int8, Int16, Int32)\n * - Unsigned types (UInt, UInt8, UInt16, UInt32)\n * - Constrained types (NonZero, NonNegative, Positive)\n * - Range-bounded types\n *\n * The utilities handle:\n *\n * - Type validation and narrowing\n * - Arithmetic operations that preserve type constraints\n * - Automatic clamping for bounded types\n * - Random number generation within type bounds\n *\n * @internal This namespace is not part of the public API\n */\n export namespace RefinedNumberUtils {\n const castTypeImpl =\n <BrandedType extends number>(\n is: (n: number) => n is BrandedType,\n typeNameInErrorMessage: string,\n ) =>\n <N extends number>(a: N): BrandedType & N => {\n if (!is(a)) {\n throw new TypeError(`Expected ${typeNameInErrorMessage}, got: ${a}`);\n }\n\n return a;\n };\n\n type UnknownNumberBrand = ChangeBaseBrand<UnknownBrand, number>;\n\n /**\n * Converts a branded number type to include the Int brand.\n *\n * @template N - A branded number type\n * @internal\n */\n export type ToInt<N extends UnknownNumberBrand> = IntersectBrand<N, Int>;\n\n type ToNonZero<N extends UnknownNumberBrand> = IntersectBrand<\n N,\n NonZeroNumber\n >;\n\n const isNonZero = <N extends UnknownNumberBrand>(\n n: N,\n ): n is N & ToNonZero<N> => n !== 0;\n\n type ToNonZeroIntWithSmallInt<N extends Int> = WithSmallInt<\n CastToInt<ToNonZero<N>>\n >;\n\n /**\n * Converts a branded number type to include the NonNegativeNumber brand.\n *\n * @template N - A branded number type\n * @internal\n */\n export type ToNonNegative<N extends UnknownNumberBrand> =\n '!=0' extends UnwrapBrandTrueKeys<N>\n ? IntersectBrand<N, PositiveNumber>\n : IntersectBrand<N, NonNegativeNumber>;\n\n /**\n * Removes the non-zero brand constraint from a branded number type. Used\n * when operations may produce zero values.\n *\n * @template N - A branded number type\n * @internal\n */\n export type RemoveNonZeroBrandKey<N extends UnknownNumberBrand> = Brand<\n GetBrandValuePart<N>,\n RelaxedExclude<UnwrapBrandTrueKeys<N>, '!=0'> & string,\n RelaxedExclude<UnwrapBrandFalseKeys<N>, '<=0' | '>=0'> & string\n >;\n\n type CastToInt<N> = N extends Int ? N : never;\n\n /**\n * Generates a type-safe API for a branded number type based on its\n * characteristics.\n *\n * This type dynamically constructs an object type with appropriate methods\n * based on the number class. For example:\n *\n * - Integer types don't get floor/ceil/round methods\n * - Non-negative types don't get abs method\n * - Range-bounded types get MIN_VALUE/MAX_VALUE constants\n *\n * @template N - The branded number type\n * @template classes - Union of characteristics: 'int' | 'non-negative' |\n * 'positive' | 'range'\n * @internal\n */\n /** The closed binary arithmetic operations a branded namespace may expose. */\n export type NumberClassBinOp = 'add' | 'div' | 'mul' | 'sub';\n\n export type NumberClass<\n N extends UnknownNumberBrand,\n classes extends 'int' | 'non-negative' | 'positive' | 'range',\n binOps extends NumberClassBinOp = NumberClassBinOp,\n > = ('int' extends classes\n ? unknown\n : 'positive' extends classes\n ? Readonly<{\n floor: (x: N, y: N) => RemoveNonZeroBrandKey<ToInt<N>>;\n ceil: (x: N, y: N) => ToInt<N>;\n round: (x: N, y: N) => RemoveNonZeroBrandKey<ToInt<N>>;\n }>\n : Readonly<{\n floor: (x: N, y: N) => ToInt<N>;\n ceil: (x: N, y: N) => ToInt<N>;\n round: (x: N, y: N) => ToInt<N>;\n }>) &\n ('non-negative' extends classes\n ? Readonly<{\n MIN_VALUE: number;\n fromNumber: (a: number) => N;\n }>\n : unknown) &\n ('non-negative' extends classes\n ? unknown\n : 'positive' extends classes\n ? unknown\n : Readonly<{\n abs: (x: N) => ToNonNegative<N>;\n }>) &\n ('positive' extends classes\n ? Readonly<{\n MIN_VALUE: number;\n fromNumber: (a: number) => N;\n }>\n : unknown) &\n ('range' extends classes\n ? Readonly<{\n MIN_VALUE: number;\n MAX_VALUE: number;\n fromNumber: (a: number) => N;\n }>\n : unknown) &\n StrictPick<\n Readonly<{\n add: (x: N, y: N) => N;\n sub: (x: N, y: N) => N;\n mul: (x: N, y: N) => N;\n div: (x: N, y: ToNonZero<N>) => N;\n }>,\n binOps\n > &\n Readonly<{\n is: (a: number) => a is N;\n min: (...values: readonly N[]) => N;\n max: (...values: readonly N[]) => N;\n random: (min: N, max: N) => N;\n pow: (x: N, y: N) => N;\n }>;\n\n type BaseKeys =\n 'add' | 'div' | 'is' | 'max' | 'min' | 'mul' | 'pow' | 'random' | 'sub';\n\n type FloatMethods = 'ceil' | 'floor' | 'round';\n\n expectType<keyof NumberClass<UnknownNumberBrand, 'int'>, BaseKeys | 'abs'>(\n '=',\n );\n\n expectType<\n keyof NumberClass<UnknownNumberBrand, never>,\n BaseKeys | FloatMethods | 'abs'\n >('=');\n\n expectType<\n keyof NumberClass<UnknownNumberBrand, 'non-negative'>,\n BaseKeys | FloatMethods | 'fromNumber' | 'MIN_VALUE'\n >('=');\n\n expectType<\n keyof NumberClass<UnknownNumberBrand, 'positive'>,\n BaseKeys | FloatMethods | 'fromNumber' | 'MIN_VALUE'\n >('=');\n\n expectType<\n keyof NumberClass<UnknownNumberBrand, 'int' | 'range'>,\n BaseKeys | 'abs' | 'fromNumber' | 'MAX_VALUE' | 'MIN_VALUE'\n >('=');\n\n const isFnOrUndefined = (\n min: number | undefined,\n max: number | undefined,\n ): ((n: number) => boolean) | undefined =>\n min === undefined\n ? max === undefined\n ? undefined\n : (n) => n <= max\n : max === undefined\n ? (n) => min <= n\n : Num.isInRangeInclusive(min, max);\n\n const clampFnOrUndefined = (\n min: number | undefined,\n max: number | undefined,\n ): ((n: number) => number) | undefined =>\n min === undefined\n ? max === undefined\n ? undefined\n : (n) => Math.min(max, n)\n : max === undefined\n ? (n) => Math.max(min, n)\n : Num.clamp(min, max);\n\n type OperatorsForInteger<\n ElementType extends Int,\n MIN_VALUE extends number,\n MAX_VALUE extends number,\n ElementTypeWithSmallInt extends WithSmallInt<ElementType> =\n WithSmallInt<ElementType>,\n > = Readonly<{\n MIN_VALUE: MIN_VALUE;\n MAX_VALUE: MAX_VALUE;\n\n is: (a: number) => a is ElementType;\n\n abs: (x: ElementTypeWithSmallInt) => ToNonNegative<ElementType>;\n\n min: (...values: readonly ElementTypeWithSmallInt[]) => ElementType;\n\n max: (...values: readonly ElementTypeWithSmallInt[]) => ElementType;\n\n pow: (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ) => ElementType;\n\n add: (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ) => ElementType;\n\n sub: (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ) => ElementType;\n\n mul: (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ) => ElementType;\n\n div: (\n x: ElementTypeWithSmallInt,\n y: ToNonZeroIntWithSmallInt<ElementType>,\n ) => ElementType;\n\n random: (\n min?: ElementTypeWithSmallInt,\n max?: ElementTypeWithSmallInt,\n ) => ElementType;\n\n randomNonZero: (\n min?: ElementTypeWithSmallInt,\n max?: ElementTypeWithSmallInt,\n ) => ElementType;\n\n castType: <N extends number>(x: N) => ElementType & N;\n\n fromNumber: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true\n ? undefined\n : (x: number) => ElementType;\n }>;\n\n /**\n * Factory function that creates a complete set of type-safe operations for\n * integer types.\n *\n * This function generates:\n *\n * - Type guards and validators\n * - Arithmetic operations that preserve type constraints\n * - Utility functions (min, max, abs, random)\n * - Automatic clamping for bounded types\n *\n * All operations ensure results remain within the type's constraints, using\n * clamping when bounds are specified.\n *\n * @example\n *\n * ```ts\n * const intOps = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n * SafeInt,\n * number,\n * number\n * >({\n * integerOrSafeInteger: 'SafeInteger',\n * MIN_VALUE: Number.MIN_SAFE_INTEGER,\n * MAX_VALUE: Number.MAX_SAFE_INTEGER,\n * typeNameInMessage: 'SafeInt',\n * } as const);\n *\n * const six = intOps.castType(6);\n *\n * const four = intOps.castType(4);\n *\n * const sum = intOps.add(six, four);\n *\n * const difference = intOps.sub(six, four);\n *\n * const product = intOps.mul(six, four);\n *\n * const quotient = intOps.div(six, intOps.castType(2));\n *\n * const coerced = intOps.fromNumber(1.5);\n *\n * const randomValue = intOps.random();\n *\n * assert.isTrue(sum === 10);\n *\n * assert.isTrue(difference === 2);\n *\n * assert.isTrue(product === 24);\n *\n * assert.isTrue(quotient === 3);\n *\n * assert.isTrue(coerced === 2);\n *\n * assert.isTrue(Number.isSafeInteger(randomValue));\n * ```\n *\n * @template ElementType - The integer branded type\n * @template MIN_VALUE - Optional minimum value for bounded types\n * @template MAX_VALUE - Optional maximum value for bounded types\n * @param config - Configuration object\n * @param config.integerOrSafeInteger - Whether to use Number.isInteger or\n * Number.isSafeInteger\n * @param config.nonZero - If true, excludes zero from valid values\n * @param config.MIN_VALUE - Minimum valid value (inclusive)\n * @param config.MAX_VALUE - Maximum valid value (inclusive)\n * @param config.typeNameInMessage - Human-readable type name for error\n * messages\n * @returns Object containing all type-safe operations for the integer type\n * @internal\n */\n export const operatorsForInteger = <\n ElementType extends Int,\n MIN_VALUE extends number,\n MAX_VALUE extends number,\n >({\n integerOrSafeInteger,\n nonZero,\n MIN_VALUE,\n MAX_VALUE,\n typeNameInMessage,\n }: Readonly<{\n integerOrSafeInteger: 'Integer' | 'SafeInteger';\n nonZero?: boolean;\n MIN_VALUE: MIN_VALUE;\n MAX_VALUE: MAX_VALUE;\n typeNameInMessage: string;\n }>): OperatorsForInteger<ElementType, MIN_VALUE, MAX_VALUE> => {\n type ElementTypeWithSmallInt = WithSmallInt<ElementType>;\n\n const is = (a: number): a is ElementType =>\n (integerOrSafeInteger === 'Integer'\n ? Number.isInteger(a)\n : Number.isSafeInteger(a)) &&\n (nonZero === true ? a !== 0 : true) &&\n (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);\n\n const castType = castTypeImpl<ElementType>(is, typeNameInMessage);\n\n const fromNumber: ((a: number) => ElementType) | undefined = pipe(\n clampFnOrUndefined(MIN_VALUE, MAX_VALUE),\n ).mapNullable(\n (cl) =>\n (x: number): ElementType =>\n castType(Math.round(cl(x))),\n ).value;\n\n const clampOrCastFn: (a: number) => ElementType = fromNumber ?? castType;\n\n const abs = (x: ElementTypeWithSmallInt): ToNonNegative<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(clampOrCastFn(x)) as ToNonNegative<ElementType>;\n\n const min_ = (\n ...values: readonly ElementTypeWithSmallInt[]\n ): ElementType => clampOrCastFn(Math.min(...values));\n\n const max_ = (\n ...values: readonly ElementTypeWithSmallInt[]\n ): ElementType => clampOrCastFn(Math.max(...values));\n\n const pow = (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ): ElementType => clampOrCastFn(x ** y);\n\n const add = (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ): ElementType => clampOrCastFn(x + y);\n\n const sub = (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ): ElementType => clampOrCastFn(x - y);\n\n const mul = (\n x: ElementTypeWithSmallInt,\n y: ElementTypeWithSmallInt,\n ): ElementType => clampOrCastFn(x * y);\n\n const div = (\n x: ElementTypeWithSmallInt,\n y: ToNonZeroIntWithSmallInt<ElementType>,\n ): ElementType =>\n clampOrCastFn(\n Math.floor(\n // eslint-disable-next-line total-functions/no-partial-division\n x / y,\n ),\n );\n\n const randomImpl = (\n min: number = MIN_VALUE,\n max: number = MAX_VALUE,\n ): number =>\n min + Math.floor((Math.max(max, min) - min + 1) * Math.random());\n\n // [-5, 5] -> floor(11 * Math.random()) + (-5)\n const random = (\n min?: ElementTypeWithSmallInt,\n max?: ElementTypeWithSmallInt,\n ): ElementType => clampOrCastFn(randomImpl(min, max));\n\n const randomNonZero = (\n min?: ElementTypeWithSmallInt,\n max?: ElementTypeWithSmallInt,\n ): ElementType => {\n while (true) {\n const r = randomImpl(min, max);\n\n if (Num.isNonZero(r)) return clampOrCastFn(r);\n }\n };\n\n return {\n MIN_VALUE,\n MAX_VALUE,\n is,\n abs,\n min: min_,\n max: max_,\n pow,\n add,\n sub,\n mul,\n div,\n random,\n randomNonZero,\n castType,\n\n fromNumber:\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n fromNumber as TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true\n ? undefined\n : (x: number) => ElementType,\n } as const;\n };\n\n type OperatorsForFloat<\n ElementType extends UnknownNumberBrand,\n MIN_VALUE extends number | undefined,\n MAX_VALUE extends number | undefined,\n > = Readonly<{\n MIN_VALUE: MIN_VALUE;\n MAX_VALUE: MAX_VALUE;\n\n is: (a: number) => a is ElementType;\n\n abs: (x: ElementType) => ToNonNegative<ElementType>;\n min: (...values: readonly ElementType[]) => ElementType;\n max: (...values: readonly ElementType[]) => ElementType;\n pow: (x: ElementType, y: ElementType) => ElementType;\n add: (x: ElementType, y: ElementType) => ElementType;\n sub: (x: ElementType, y: ElementType) => ElementType;\n mul: (x: ElementType, y: ElementType) => ElementType;\n div: (x: ElementType, y: ToNonZero<ElementType>) => ElementType;\n random: (min?: ElementType, max?: ElementType) => ElementType;\n randomNonZero: (min?: ElementType, max?: ElementType) => ElementType;\n\n castType: <N extends number>(x: N) => ElementType & N;\n\n fromNumber: TypeEq<MAX_VALUE | MIN_VALUE, undefined> extends true\n ? undefined\n : (x: number) => ElementType;\n }>;\n\n /**\n * Factory function that creates a complete set of type-safe operations for\n * floating-point types.\n *\n * This function generates:\n *\n * - Type guards and validators (checking for finite values)\n * - Arithmetic operations that preserve type constraints\n * - Utility functions (min, max, abs, random)\n * - Automatic clamping for bounded types\n *\n * All operations ensure results remain finite and within any specified\n * bounds. Division by zero is prevented through type constraints.\n *\n * @example\n *\n * ```ts\n * const floatOps = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n * PositiveFiniteNumber,\n * number,\n * number\n * >({\n * nonZero: true,\n * MIN_VALUE: Number.MIN_VALUE,\n * MAX_VALUE: Number.MAX_VALUE,\n * typeNameInMessage: 'PositiveFiniteNumber',\n * } as const);\n *\n * const fortyTwo = floatOps.castType(42.5);\n *\n * const seven = floatOps.castType(7.5);\n *\n * const sum = floatOps.add(fortyTwo, seven);\n *\n * const ratio = floatOps.div(sum, floatOps.castType(10));\n *\n * const coerced = floatOps.fromNumber(0);\n *\n * const boundedRandom = floatOps.random(\n * floatOps.castType(10),\n * floatOps.castType(20),\n * );\n *\n * const nonZeroRandom = floatOps.randomNonZero();\n *\n * assert.isTrue(sum === 50);\n *\n * assert.isTrue(ratio === 5);\n *\n * assert.isTrue(coerced >= Number.MIN_VALUE);\n *\n * assert.isTrue(boundedRandom >= 10 && boundedRandom <= 20);\n *\n * assert.isTrue(nonZeroRandom > 0);\n * ```\n *\n * @template ElementType - The floating-point branded type\n * @template MIN_VALUE - Optional minimum value for bounded types\n * @template MAX_VALUE - Optional maximum value for bounded types\n * @param config - Configuration object\n * @param config.nonZero - If true, excludes zero from valid values\n * @param config.MIN_VALUE - Minimum valid value (inclusive)\n * @param config.MAX_VALUE - Maximum valid value (inclusive)\n * @param config.typeNameInMessage - Human-readable type name for error\n * messages\n * @returns Object containing all type-safe operations for the\n * floating-point type\n * @internal\n */\n export const operatorsForFloat = <\n ElementType extends UnknownNumberBrand,\n MIN_VALUE extends number,\n MAX_VALUE extends number,\n >({\n nonZero,\n MIN_VALUE,\n MAX_VALUE,\n typeNameInMessage,\n }: Readonly<{\n nonZero?: boolean;\n MIN_VALUE: MIN_VALUE;\n MAX_VALUE: MAX_VALUE;\n typeNameInMessage: string;\n }>): OperatorsForFloat<ElementType, MIN_VALUE, MAX_VALUE> => {\n const is = (a: number): a is ElementType =>\n Number.isFinite(a) &&\n (nonZero === true ? a !== 0 : true) &&\n (isFnOrUndefined(MIN_VALUE, MAX_VALUE)?.(a) ?? true);\n\n const castType = castTypeImpl<ElementType>(is, typeNameInMessage);\n\n const fromNumber: ((a: number) => ElementType) | undefined = pipe(\n clampFnOrUndefined(MIN_VALUE, MAX_VALUE),\n ).mapNullable(\n (cl) =>\n (x: number): ElementType =>\n castType(cl(x)),\n ).value;\n\n const clampOrCastFn: (a: number) => ElementType = fromNumber ?? castType;\n\n const abs = (x: ElementType): ToNonNegative<ElementType> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.abs(x) as ToNonNegative<ElementType>;\n\n const min_ = (...values: readonly ElementType[]): ElementType =>\n clampOrCastFn(Math.min(...values));\n\n const max_ = (...values: readonly ElementType[]): ElementType =>\n clampOrCastFn(Math.max(...values));\n\n const pow = (x: ElementType, y: ElementType): ElementType =>\n clampOrCastFn(x ** y);\n\n const add = (x: ElementType, y: ElementType): ElementType =>\n clampOrCastFn(x + y);\n\n const sub = (x: ElementType, y: ElementType): ElementType =>\n clampOrCastFn(x - y);\n\n const mul = (x: ElementType, y: ElementType): ElementType =>\n clampOrCastFn(x * y);\n\n const div = (x: ElementType, y: ToNonZero<ElementType>): ElementType =>\n // eslint-disable-next-line total-functions/no-partial-division\n clampOrCastFn(x / y);\n\n const randomImpl = (\n min: number = MIN_VALUE,\n max: number = MAX_VALUE,\n ): number => min + (Math.max(max, min) - min) * Math.random();\n\n const random = (min?: ElementType, max?: ElementType): ElementType =>\n clampOrCastFn(randomImpl(min, max));\n\n const randomNonZero = (\n min?: ElementType,\n max?: ElementType,\n ): ElementType => {\n while (true) {\n const r = random(min, max);\n\n if (isNonZero(r)) return r;\n }\n };\n\n return {\n MIN_VALUE,\n MAX_VALUE,\n is,\n abs,\n min: min_,\n max: max_,\n pow,\n add,\n sub,\n mul,\n div,\n random,\n randomNonZero,\n castType,\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n fromNumber: fromNumber as TypeEq<\n MAX_VALUE | MIN_VALUE,\n undefined\n > extends true\n ? undefined\n : (x: number) => ElementType,\n } as const;\n };\n }\n}\n"],"names":["TsDataForgeInternals","RefinedNumberUtils"],"mappings":";;;;IAsBiB;AAAA,CAAV,CAAUA,qBAAAA,KAAV;AAuBE,EAAA,CAAA,CAAUC,mBAAAA,KAAV;AACL,IAAA,MAAM,YAAA,GACJ,CACE,EAAA,EACA,sBAAA,KAEF,CAAmB,CAAA,KAA0B;AAC3C,MAAA,IAAI,CAAC,EAAA,CAAG,CAAC,CAAA,EAAG;AACV,QAAA,MAAM,IAAI,SAAA,CAAU,CAAA,SAAA,EAAY,sBAAsB,CAAA,OAAA,EAAU,CAAC,CAAA,CAAE,CAAA;AAAA,MAAA;AAGrE,MAAA,OAAO,CAAA;AAAA,IAAA,CACT;AAiBF,IAAA,MAAM,SAAA,GAAY,CAChB,CAAA,KAC0B,CAAA,KAAM,CAAA;AA4IlC,IAAA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EzB,UAAA,IAAI,SAAA,CAAU,CAAC,CAAA,EAAG,OAAO,CAAA;AAAA,QAAA;AAC3B,MAAA,CACF;AAEA,MAAA,OAAO;AAAA,QACL,SAAA;AAAA,QACA,SAAA;AAAA,QACA,EAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA,EAAK,IAAA;AAAA,QACL,GAAA,EAAK,IAAA;AAAA,QACL,GAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAA;AAAA,QACA,QAAA;AAAA;AAAA,QAGA;AAAA,OAMF;AAAA,IAAA,CACF;AAAA,EAAA,CAAA,EA5oBeD,qBAAAA,CAAA,kBAAA,KAAAA,qBAAAA,CAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EAvBF,oBAAA,KAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"refined-number-utils.mjs","sourceRoot":"","sources":["../../src/number/refined-number-utils.mts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,gBAAgB;AAChB,MAAM,KAAW,oBAAoB,CAqqBpC;AArqBD,WAAiB,oBAAoB;IACnC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,IAAiB,kBAAkB,CA6oBlC;IA7oBD,WAAiB,kBAAkB;QACjC,MAAM,YAAY,GAChB,CACE,EAAmC,EACnC,sBAA8B,EAC9B,EAAE,CACJ,CAAmB,CAAI,EAAmB,EAAE;YAC1C,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,SAAS,CAAC,YAAY,sBAAsB,UAAU,CAAC,EAAE,CAAC,CAAC;YACvE,CAAC;YAED,OA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YAEtC,MAAM,aAAa,GAAG,CACpB,GAAiB,EACjB,GAAiB,EACJ,EAAE;gBACf,OAAO,IAAI,EAAE,CAAC;oBACZ,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;oBAE3B,IAAI,SAAS,CAAC,CAAC,CAAC;wBAAE,OAAO,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC,CAAC;YAEF,OAAO;gBACL,SAAS;gBACT,SAAS;gBACT,EAAE;gBACF,GAAG;gBACH,GAAG,EAAE,IAAI;gBACT,GAAG,EAAE,IAAI;gBACT,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,MAAM;gBACN,aAAa;gBACb,QAAQ;gBAER,oEAAoE;gBACpE,UAAU,EAAE,UAKkB;aACtB,CAAC;QACb,CAAC,CAAC;IACJ,CAAC,EA7oBgB,kBAAkB,GAAlB,qBAAA,kBAAkB,KAAlB,qBAAA,kBAAkB,QA6oBlC;AACH,CAAC,EArqBgB,oBAAoB,KAApB,oBAAoB,QAqqBpC"}
@@ -1,2 +1,2 @@
1
- export { Obj } from './object.mjs';
2
- //# sourceMappingURL=index.mjs.map
1
+ export * from './object.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/object/index.mts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}