ts-data-forge 8.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (429) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-creation.mjs +17 -112
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
  5. package/dist/array/impl/array-utils-element-access.mjs +22 -61
  6. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  7. package/dist/array/impl/array-utils-iterators.d.mts.map +1 -1
  8. package/dist/array/impl/array-utils-iterators.mjs +9 -63
  9. package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
  10. package/dist/array/impl/array-utils-modification.mjs +78 -78
  11. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  12. package/dist/array/impl/array-utils-reducing-value.mjs +95 -89
  13. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  14. package/dist/array/impl/array-utils-search.mjs +100 -92
  15. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  16. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  17. package/dist/array/impl/array-utils-set-op.mjs +31 -141
  18. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-size.mjs +4 -8
  21. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  22. package/dist/array/impl/array-utils-slice-clamped.mjs +11 -12
  23. package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  25. package/dist/array/impl/array-utils-slicing.mjs +44 -96
  26. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  27. package/dist/array/impl/array-utils-transformation.d.mts +1 -1
  28. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  29. package/dist/array/impl/array-utils-transformation.mjs +150 -292
  30. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  31. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  32. package/dist/array/impl/array-utils-validation.mjs +18 -169
  33. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  34. package/dist/collections/imap-mapped.d.mts.map +1 -1
  35. package/dist/collections/imap-mapped.mjs +243 -330
  36. package/dist/collections/imap-mapped.mjs.map +1 -1
  37. package/dist/collections/imap.d.mts.map +1 -1
  38. package/dist/collections/imap.mjs +190 -275
  39. package/dist/collections/imap.mjs.map +1 -1
  40. package/dist/collections/iset-mapped.d.mts +1 -1
  41. package/dist/collections/iset-mapped.d.mts.map +1 -1
  42. package/dist/collections/iset-mapped.mjs +222 -444
  43. package/dist/collections/iset-mapped.mjs.map +1 -1
  44. package/dist/collections/iset.d.mts +1 -1
  45. package/dist/collections/iset.d.mts.map +1 -1
  46. package/dist/collections/iset.mjs +158 -324
  47. package/dist/collections/iset.mjs.map +1 -1
  48. package/dist/collections/queue.d.mts.map +1 -1
  49. package/dist/collections/queue.mjs +106 -178
  50. package/dist/collections/queue.mjs.map +1 -1
  51. package/dist/collections/stack.d.mts.map +1 -1
  52. package/dist/collections/stack.mjs +95 -165
  53. package/dist/collections/stack.mjs.map +1 -1
  54. package/dist/entry-point.mjs +1 -0
  55. package/dist/entry-point.mjs.map +1 -1
  56. package/dist/expect-type.d.mts +1 -1
  57. package/dist/expect-type.d.mts.map +1 -1
  58. package/dist/expect-type.mjs +1 -69
  59. package/dist/expect-type.mjs.map +1 -1
  60. package/dist/functional/match.mjs +9 -9
  61. package/dist/functional/match.mjs.map +1 -1
  62. package/dist/functional/optional/impl/optional-expect-to-be.mjs +13 -14
  63. package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
  64. package/dist/functional/optional/impl/optional-filter.mjs +14 -15
  65. package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
  66. package/dist/functional/optional/impl/optional-flat-map.mjs +10 -11
  67. package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
  68. package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
  69. package/dist/functional/optional/impl/optional-from-nullable.mjs +1 -25
  70. package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
  71. package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -1
  72. package/dist/functional/optional/impl/optional-is-none.mjs +0 -19
  73. package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
  74. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  75. package/dist/functional/optional/impl/optional-is-optional.mjs +1 -23
  76. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  77. package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
  78. package/dist/functional/optional/impl/optional-is-some.mjs +0 -20
  79. package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
  80. package/dist/functional/optional/impl/optional-map.mjs +13 -14
  81. package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
  82. package/dist/functional/optional/impl/optional-none.mjs +0 -16
  83. package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
  84. package/dist/functional/optional/impl/optional-or-else.mjs +10 -11
  85. package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
  86. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  87. package/dist/functional/optional/impl/optional-some.mjs +2 -21
  88. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  89. package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
  90. package/dist/functional/optional/impl/optional-to-nullable.mjs +1 -27
  91. package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
  92. package/dist/functional/optional/impl/optional-unwrap-or.mjs +9 -10
  93. package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
  94. package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
  95. package/dist/functional/optional/impl/optional-unwrap-throw.mjs +4 -32
  96. package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
  97. package/dist/functional/optional/impl/optional-unwrap.mjs +4 -4
  98. package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
  99. package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
  100. package/dist/functional/optional/impl/optional-zip.mjs +1 -35
  101. package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
  102. package/dist/functional/optional/impl/tag.mjs +2 -3
  103. package/dist/functional/optional/impl/tag.mjs.map +1 -1
  104. package/dist/functional/pipe.d.mts.map +1 -1
  105. package/dist/functional/pipe.mjs +9 -34
  106. package/dist/functional/pipe.mjs.map +1 -1
  107. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  108. package/dist/functional/result/impl/result-err.mjs +2 -27
  109. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  110. package/dist/functional/result/impl/result-expect-to-be.mjs +13 -15
  111. package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
  112. package/dist/functional/result/impl/result-flat-map.mjs +16 -16
  113. package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
  114. package/dist/functional/result/impl/result-fold.mjs +16 -16
  115. package/dist/functional/result/impl/result-fold.mjs.map +1 -1
  116. package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
  117. package/dist/functional/result/impl/result-from-promise.mjs +4 -31
  118. package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
  119. package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
  120. package/dist/functional/result/impl/result-from-throwable.mjs +8 -38
  121. package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
  122. package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
  123. package/dist/functional/result/impl/result-is-err.mjs +0 -19
  124. package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
  125. package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
  126. package/dist/functional/result/impl/result-is-ok.mjs +0 -19
  127. package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
  128. package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
  129. package/dist/functional/result/impl/result-is-result.mjs +1 -23
  130. package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
  131. package/dist/functional/result/impl/result-map-err.mjs +16 -16
  132. package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
  133. package/dist/functional/result/impl/result-map.mjs +16 -16
  134. package/dist/functional/result/impl/result-map.mjs.map +1 -1
  135. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  136. package/dist/functional/result/impl/result-ok.mjs +2 -27
  137. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  138. package/dist/functional/result/impl/result-or-else.mjs +10 -12
  139. package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
  140. package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
  141. package/dist/functional/result/impl/result-swap.mjs +4 -22
  142. package/dist/functional/result/impl/result-swap.mjs.map +1 -1
  143. package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
  144. package/dist/functional/result/impl/result-to-optional.mjs +0 -27
  145. package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
  146. package/dist/functional/result/impl/result-unwrap-err-or.mjs +9 -11
  147. package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
  148. package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
  149. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +13 -40
  150. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  151. package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
  152. package/dist/functional/result/impl/result-unwrap-err.mjs +4 -32
  153. package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
  154. package/dist/functional/result/impl/result-unwrap-ok-or.mjs +9 -11
  155. package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
  156. package/dist/functional/result/impl/result-unwrap-ok.mjs +4 -4
  157. package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
  158. package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
  159. package/dist/functional/result/impl/result-unwrap-throw.mjs +4 -35
  160. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  161. package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
  162. package/dist/functional/result/impl/result-zip.mjs +1 -34
  163. package/dist/functional/result/impl/result-zip.mjs.map +1 -1
  164. package/dist/functional/result/impl/tag.mjs +2 -3
  165. package/dist/functional/result/impl/tag.mjs.map +1 -1
  166. package/dist/functional/ternary-result/impl/tag.mjs +3 -5
  167. package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
  168. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  169. package/dist/functional/ternary-result/impl/ternary-result-err.mjs +2 -15
  170. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  171. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +13 -13
  172. package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
  173. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +27 -26
  174. package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
  175. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +21 -22
  176. package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
  177. package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
  178. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +4 -20
  179. package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
  180. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
  181. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +7 -25
  182. package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
  183. package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -1
  184. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -17
  185. package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
  186. package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
  187. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -19
  188. package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
  189. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
  190. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -25
  191. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
  192. package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
  193. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -18
  194. package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
  195. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +13 -15
  196. package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
  197. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +18 -18
  198. package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
  199. package/dist/functional/ternary-result/impl/ternary-result-map.mjs +21 -22
  200. package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
  201. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  202. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +2 -16
  203. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  204. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +9 -9
  205. package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
  206. package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
  207. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +4 -22
  208. package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
  209. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +9 -9
  210. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
  211. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
  212. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +12 -27
  213. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  214. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
  215. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +4 -19
  216. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
  217. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +9 -9
  218. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
  219. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +4 -5
  220. package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
  221. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
  222. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +15 -27
  223. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  224. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +9 -9
  225. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
  226. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
  227. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +10 -24
  228. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  229. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
  230. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +4 -19
  231. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
  232. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  233. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +3 -19
  234. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  235. package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
  236. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +14 -45
  237. package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
  238. package/dist/functional/ternary-result/impl/variant-name.d.mts +1 -1
  239. package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -1
  240. package/dist/functional/ternary-result/impl/variant-name.mjs +8 -9
  241. package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
  242. package/dist/functional/ternary-result/ternary-result.d.mts.map +1 -1
  243. package/dist/guard/has-key.d.mts.map +1 -1
  244. package/dist/guard/has-key.mjs +0 -41
  245. package/dist/guard/has-key.mjs.map +1 -1
  246. package/dist/guard/index.d.mts +1 -0
  247. package/dist/guard/index.d.mts.map +1 -1
  248. package/dist/guard/index.mjs +1 -0
  249. package/dist/guard/index.mjs.map +1 -1
  250. package/dist/guard/is-length-bounded-string.d.mts +164 -0
  251. package/dist/guard/is-length-bounded-string.d.mts.map +1 -0
  252. package/dist/guard/is-length-bounded-string.mjs +7 -0
  253. package/dist/guard/is-length-bounded-string.mjs.map +1 -0
  254. package/dist/guard/is-non-empty-string.d.mts +1 -1
  255. package/dist/guard/is-non-empty-string.d.mts.map +1 -1
  256. package/dist/guard/is-non-empty-string.mjs +1 -38
  257. package/dist/guard/is-non-empty-string.mjs.map +1 -1
  258. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  259. package/dist/guard/is-non-null-object.mjs +1 -35
  260. package/dist/guard/is-non-null-object.mjs.map +1 -1
  261. package/dist/guard/is-primitive.d.mts.map +1 -1
  262. package/dist/guard/is-primitive.mjs +12 -43
  263. package/dist/guard/is-primitive.mjs.map +1 -1
  264. package/dist/guard/is-record.d.mts.map +1 -1
  265. package/dist/guard/is-record.mjs +0 -86
  266. package/dist/guard/is-record.mjs.map +1 -1
  267. package/dist/guard/is-type.d.mts.map +1 -1
  268. package/dist/guard/is-type.mjs +12 -399
  269. package/dist/guard/is-type.mjs.map +1 -1
  270. package/dist/guard/key-is-in.d.mts.map +1 -1
  271. package/dist/guard/key-is-in.mjs +0 -40
  272. package/dist/guard/key-is-in.mjs.map +1 -1
  273. package/dist/index.mjs +1 -0
  274. package/dist/index.mjs.map +1 -1
  275. package/dist/iterator/range.mjs +16 -16
  276. package/dist/iterator/range.mjs.map +1 -1
  277. package/dist/json/json.d.mts.map +1 -1
  278. package/dist/json/json.mjs +52 -340
  279. package/dist/json/json.mjs.map +1 -1
  280. package/dist/number/branded-types/finite-number.d.mts +3 -3
  281. package/dist/number/branded-types/finite-number.mjs +135 -154
  282. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  283. package/dist/number/branded-types/int.d.mts +4 -4
  284. package/dist/number/branded-types/int.mjs +205 -245
  285. package/dist/number/branded-types/int.mjs.map +1 -1
  286. package/dist/number/branded-types/int16.d.mts +15 -15
  287. package/dist/number/branded-types/int16.mjs +116 -123
  288. package/dist/number/branded-types/int16.mjs.map +1 -1
  289. package/dist/number/branded-types/int32.d.mts +11 -11
  290. package/dist/number/branded-types/int32.mjs +116 -123
  291. package/dist/number/branded-types/int32.mjs.map +1 -1
  292. package/dist/number/branded-types/negative-finite-number.d.mts +4 -4
  293. package/dist/number/branded-types/negative-finite-number.mjs +129 -144
  294. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  295. package/dist/number/branded-types/negative-int.d.mts +5 -5
  296. package/dist/number/branded-types/negative-int.mjs +94 -113
  297. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  298. package/dist/number/branded-types/negative-safe-int.d.mts +5 -5
  299. package/dist/number/branded-types/negative-safe-int.mjs +103 -124
  300. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  301. package/dist/number/branded-types/non-negative-finite-number.d.mts +5 -5
  302. package/dist/number/branded-types/non-negative-finite-number.mjs +136 -142
  303. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  304. package/dist/number/branded-types/non-negative-int16.d.mts +16 -16
  305. package/dist/number/branded-types/non-negative-int16.mjs +109 -118
  306. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  307. package/dist/number/branded-types/non-negative-int32.d.mts +12 -12
  308. package/dist/number/branded-types/non-negative-int32.mjs +110 -119
  309. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  310. package/dist/number/branded-types/non-positive-finite-number.d.mts +3 -3
  311. package/dist/number/branded-types/non-positive-finite-number.mjs +120 -124
  312. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  313. package/dist/number/branded-types/non-positive-int.d.mts +4 -4
  314. package/dist/number/branded-types/non-positive-int.mjs +167 -212
  315. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  316. package/dist/number/branded-types/non-positive-safe-int.d.mts +4 -4
  317. package/dist/number/branded-types/non-positive-safe-int.mjs +95 -106
  318. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  319. package/dist/number/branded-types/non-zero-finite-number.d.mts +4 -4
  320. package/dist/number/branded-types/non-zero-finite-number.mjs +114 -123
  321. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  322. package/dist/number/branded-types/non-zero-int.d.mts +2 -2
  323. package/dist/number/branded-types/non-zero-int.mjs +72 -83
  324. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  325. package/dist/number/branded-types/non-zero-int16.d.mts +7 -7
  326. package/dist/number/branded-types/non-zero-int16.mjs +96 -107
  327. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  328. package/dist/number/branded-types/non-zero-int32.d.mts +5 -5
  329. package/dist/number/branded-types/non-zero-int32.mjs +97 -108
  330. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  331. package/dist/number/branded-types/non-zero-safe-int.d.mts +2 -2
  332. package/dist/number/branded-types/non-zero-safe-int.mjs +100 -111
  333. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  334. package/dist/number/branded-types/non-zero-uint16.d.mts +8 -8
  335. package/dist/number/branded-types/non-zero-uint16.mjs +96 -107
  336. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  337. package/dist/number/branded-types/non-zero-uint32.d.mts +6 -6
  338. package/dist/number/branded-types/non-zero-uint32.mjs +96 -107
  339. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  340. package/dist/number/branded-types/positive-finite-number.d.mts +8 -8
  341. package/dist/number/branded-types/positive-finite-number.mjs +139 -141
  342. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  343. package/dist/number/branded-types/positive-int.d.mts +11 -11
  344. package/dist/number/branded-types/positive-int.mjs +228 -271
  345. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  346. package/dist/number/branded-types/positive-int16.d.mts +19 -19
  347. package/dist/number/branded-types/positive-int16.mjs +109 -118
  348. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  349. package/dist/number/branded-types/positive-int32.d.mts +15 -15
  350. package/dist/number/branded-types/positive-int32.mjs +109 -118
  351. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  352. package/dist/number/branded-types/positive-safe-int.d.mts +11 -11
  353. package/dist/number/branded-types/positive-safe-int.mjs +244 -275
  354. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  355. package/dist/number/branded-types/positive-uint16.d.mts +17 -17
  356. package/dist/number/branded-types/positive-uint16.mjs +109 -118
  357. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  358. package/dist/number/branded-types/positive-uint32.d.mts +13 -13
  359. package/dist/number/branded-types/positive-uint32.mjs +110 -119
  360. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  361. package/dist/number/branded-types/safe-int.d.mts +4 -4
  362. package/dist/number/branded-types/safe-int.mjs +251 -292
  363. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  364. package/dist/number/branded-types/safe-uint.d.mts +8 -8
  365. package/dist/number/branded-types/safe-uint.mjs +111 -119
  366. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  367. package/dist/number/branded-types/uint.d.mts +8 -8
  368. package/dist/number/branded-types/uint.mjs +198 -225
  369. package/dist/number/branded-types/uint.mjs.map +1 -1
  370. package/dist/number/branded-types/uint16.d.mts +14 -14
  371. package/dist/number/branded-types/uint16.mjs +109 -119
  372. package/dist/number/branded-types/uint16.mjs.map +1 -1
  373. package/dist/number/branded-types/uint32.d.mts +10 -10
  374. package/dist/number/branded-types/uint32.mjs +110 -117
  375. package/dist/number/branded-types/uint32.mjs.map +1 -1
  376. package/dist/number/enum/int8.mjs +119 -145
  377. package/dist/number/enum/int8.mjs.map +1 -1
  378. package/dist/number/enum/uint8.mjs +107 -121
  379. package/dist/number/enum/uint8.mjs.map +1 -1
  380. package/dist/number/num.d.mts +2 -2
  381. package/dist/number/num.d.mts.map +1 -1
  382. package/dist/number/num.mjs +76 -537
  383. package/dist/number/num.mjs.map +1 -1
  384. package/dist/number/refined-number-utils.d.mts +1 -1
  385. package/dist/number/refined-number-utils.d.mts.map +1 -1
  386. package/dist/number/refined-number-utils.mjs +127 -263
  387. package/dist/number/refined-number-utils.mjs.map +1 -1
  388. package/dist/object/object.d.mts.map +1 -1
  389. package/dist/object/object.mjs +107 -222
  390. package/dist/object/object.mjs.map +1 -1
  391. package/dist/others/cast-mutable.d.mts.map +1 -1
  392. package/dist/others/cast-mutable.mjs +8 -37
  393. package/dist/others/cast-mutable.mjs.map +1 -1
  394. package/dist/others/cast-readonly.d.mts.map +1 -1
  395. package/dist/others/cast-readonly.mjs +8 -36
  396. package/dist/others/cast-readonly.mjs.map +1 -1
  397. package/dist/others/debounce-function.d.mts.map +1 -1
  398. package/dist/others/debounce-function.mjs +7 -16
  399. package/dist/others/debounce-function.mjs.map +1 -1
  400. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  401. package/dist/others/fast-deep-equal.mjs +43 -59
  402. package/dist/others/fast-deep-equal.mjs.map +1 -1
  403. package/dist/others/if-then.d.mts.map +1 -1
  404. package/dist/others/if-then.mjs +0 -29
  405. package/dist/others/if-then.mjs.map +1 -1
  406. package/dist/others/map-nullable.mjs +9 -9
  407. package/dist/others/map-nullable.mjs.map +1 -1
  408. package/dist/others/memoize-function.mjs +12 -12
  409. package/dist/others/memoize-function.mjs.map +1 -1
  410. package/dist/others/tuple.d.mts.map +1 -1
  411. package/dist/others/tuple.mjs +0 -50
  412. package/dist/others/tuple.mjs.map +1 -1
  413. package/dist/others/unknown-to-string.d.mts.map +1 -1
  414. package/dist/others/unknown-to-string.mjs +41 -88
  415. package/dist/others/unknown-to-string.mjs.map +1 -1
  416. package/dist/promise/promise.d.mts.map +1 -1
  417. package/dist/promise/promise.mjs +4 -49
  418. package/dist/promise/promise.mjs.map +1 -1
  419. package/package.json +17 -16
  420. package/src/array/impl/array-utils-transformation.mts +1 -2
  421. package/src/array/impl/array-utils-transformation.test.mts +3 -36
  422. package/src/array/impl/array-utils-validation.test.mts +1 -3
  423. package/src/expect-type.mts +4 -5
  424. package/src/functional/ternary-result/ternary-result.mts +2 -6
  425. package/src/guard/index.mts +1 -0
  426. package/src/guard/is-length-bounded-string.mts +199 -0
  427. package/src/guard/is-length-bounded-string.test.mts +170 -0
  428. package/src/number/refined-number-utils.mts +1 -9
  429. package/src/object/object.mts +25 -23
@@ -1,284 +1,253 @@
1
1
  import { TsDataForgeInternals } from '../refined-number-utils.mjs';
2
2
 
3
- const typeNameInMessage = 'a positive safe integer';
4
- const { MAX_VALUE, MIN_VALUE, add, castType, clamp, div, is, max: max_, min: min_, mul, pow, random, sub, } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
5
- integerOrSafeInteger: 'SafeInteger',
6
- MIN_VALUE: 1,
7
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
8
- MAX_VALUE: Number.MAX_SAFE_INTEGER,
9
- typeNameInMessage,
3
+ const typeNameInMessage = "a positive safe integer";
4
+ const {
5
+ MAX_VALUE,
6
+ MIN_VALUE,
7
+ add,
8
+ castType,
9
+ clamp,
10
+ div,
11
+ is,
12
+ max: max_,
13
+ min: min_,
14
+ mul,
15
+ pow,
16
+ random,
17
+ sub
18
+ } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
19
+ integerOrSafeInteger: "SafeInteger",
20
+ MIN_VALUE: 1,
21
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer
22
+ MAX_VALUE: Number.MAX_SAFE_INTEGER,
23
+ typeNameInMessage
10
24
  });
11
- /**
12
- * Checks if a number is a PositiveSafeInt (a positive safe integer in the range
13
- * [1, MAX_SAFE_INTEGER]).
14
- *
15
- * @example
16
- *
17
- * ```ts
18
- * assert.isTrue(isPositiveSafeInt(1));
19
- *
20
- * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
21
- *
22
- * assert.isFalse(isPositiveSafeInt(0));
23
- *
24
- * assert.isTrue(PositiveSafeInt.is(42));
25
- * ```
26
- *
27
- * @param value The value to check.
28
- * @returns `true` if the value is a PositiveSafeInt, `false` otherwise.
29
- */
30
25
  const isPositiveSafeInt = is;
31
- /**
32
- * Casts a number to a PositiveSafeInt type.
33
- *
34
- * @example
35
- *
36
- * ```ts
37
- * const branded = asPositiveSafeInt(128);
38
- *
39
- * assert.isTrue(branded === 128);
40
- *
41
- * assert.isTrue(PositiveSafeInt.is(branded));
42
- * ```
43
- *
44
- * @param value The value to cast.
45
- * @returns The value as a PositiveSafeInt type.
46
- * @throws {TypeError} If the value is not a positive safe integer.
47
- */
48
26
  const asPositiveSafeInt = castType;
49
- /**
50
- * Namespace providing type-safe arithmetic operations for positive safe
51
- * integers.
52
- *
53
- * All operations automatically clamp results to the positive safe integer range
54
- * [1, MAX_SAFE_INTEGER]. This ensures that all arithmetic maintains both the
55
- * positive constraint and IEEE 754 precision guarantees, preventing precision
56
- * loss and ensuring results are always positive.
57
- */
58
27
  const PositiveSafeInt = {
59
- /**
60
- * Type guard to check if a value is a PositiveSafeInt.
61
- *
62
- * @example
63
- *
64
- * ```ts
65
- * assert.isTrue(isPositiveSafeInt(1));
66
- *
67
- * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
68
- *
69
- * assert.isFalse(isPositiveSafeInt(0));
70
- *
71
- * assert.isTrue(PositiveSafeInt.is(42));
72
- * ```
73
- *
74
- * @param value The value to check.
75
- * @returns `true` if the value is a positive safe integer, `false` otherwise.
76
- * @see {@link isPositiveSafeInt} for usage examples
77
- */
78
- is,
79
- /**
80
- * The minimum value for a positive safe integer.
81
- *
82
- * @readonly
83
- */
84
- MIN_VALUE,
85
- /**
86
- * The maximum safe integer value (2^53 - 1).
87
- *
88
- * @readonly
89
- */
90
- MAX_VALUE,
91
- /**
92
- * Returns the smaller of two PositiveSafeInt values.
93
- *
94
- * @example
95
- *
96
- * ```ts
97
- * const smallest = PositiveSafeInt.min(
98
- * asPositiveSafeInt(10),
99
- * asPositiveSafeInt(5),
100
- * );
101
- *
102
- * assert.isTrue(smallest === 5);
103
- * ```
104
- *
105
- * @param a The first PositiveSafeInt.
106
- * @param b The second PositiveSafeInt.
107
- * @returns The minimum value as a PositiveSafeInt.
108
- */
109
- min: min_,
110
- /**
111
- * Returns the larger of two PositiveSafeInt values.
112
- *
113
- * @example
114
- *
115
- * ```ts
116
- * const largest = PositiveSafeInt.max(
117
- * asPositiveSafeInt(10),
118
- * asPositiveSafeInt(5),
119
- * );
120
- *
121
- * assert.isTrue(largest === 10);
122
- * ```
123
- *
124
- * @param a The first PositiveSafeInt.
125
- * @param b The second PositiveSafeInt.
126
- * @returns The maximum value as a PositiveSafeInt.
127
- */
128
- max: max_,
129
- /**
130
- * Clamps a number to the positive safe integer range.
131
- *
132
- * @example
133
- *
134
- * ```ts
135
- * const belowRange = PositiveSafeInt.clamp(0);
136
- *
137
- * const withinRange = PositiveSafeInt.clamp(123);
138
- *
139
- * const aboveRange = PositiveSafeInt.clamp(Number.MAX_SAFE_INTEGER + 10);
140
- *
141
- * assert.isTrue(belowRange === 1);
142
- *
143
- * assert.isTrue(withinRange === 123);
144
- *
145
- * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
146
- * ```
147
- *
148
- * @param value The number to clamp.
149
- * @returns The value clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
150
- */
151
- clamp,
152
- /**
153
- * Generates a random PositiveSafeInt value within the valid range.
154
- *
155
- * @example
156
- *
157
- * ```ts
158
- * const min = asPositiveSafeInt(1);
159
- *
160
- * const max = asPositiveSafeInt(6);
161
- *
162
- * const randomValue = PositiveSafeInt.random(min, max);
163
- *
164
- * assert.isTrue(PositiveSafeInt.is(randomValue));
165
- *
166
- * assert.isTrue(randomValue >= 1 && randomValue <= 6);
167
- * ```
168
- *
169
- * @returns A random PositiveSafeInt between 1 and MAX_SAFE_INTEGER.
170
- */
171
- random,
172
- /**
173
- * Raises a PositiveSafeInt to the power of another PositiveSafeInt.
174
- *
175
- * @example
176
- *
177
- * ```ts
178
- * const base = asPositiveSafeInt(3);
179
- *
180
- * const exponent = asPositiveSafeInt(3);
181
- *
182
- * const power = PositiveSafeInt.pow(base, exponent);
183
- *
184
- * assert.isTrue(power === 27);
185
- * ```
186
- *
187
- * @param a The base PositiveSafeInt.
188
- * @param b The exponent PositiveSafeInt.
189
- * @returns `a ** b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
190
- */
191
- pow,
192
- /**
193
- * Adds two PositiveSafeInt values.
194
- *
195
- * @example
196
- *
197
- * ```ts
198
- * const sum = PositiveSafeInt.add(
199
- * asPositiveSafeInt(1000),
200
- * asPositiveSafeInt(2048),
201
- * );
202
- *
203
- * assert.isTrue(sum === 3048);
204
- *
205
- * assert.isTrue(PositiveSafeInt.is(sum));
206
- * ```
207
- *
208
- * @param a The first PositiveSafeInt.
209
- * @param b The second PositiveSafeInt.
210
- * @returns `a + b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
211
- */
212
- add,
213
- /**
214
- * Subtracts one PositiveSafeInt from another.
215
- *
216
- * @example
217
- *
218
- * ```ts
219
- * const difference = PositiveSafeInt.sub(
220
- * asPositiveSafeInt(10),
221
- * asPositiveSafeInt(20),
222
- * );
223
- *
224
- * assert.isTrue(difference === 1);
225
- *
226
- * assert.isTrue(PositiveSafeInt.is(difference));
227
- * ```
228
- *
229
- * @param a The minuend PositiveSafeInt.
230
- * @param b The subtrahend PositiveSafeInt.
231
- * @returns `a - b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt
232
- * (minimum 1).
233
- */
234
- sub,
235
- /**
236
- * Multiplies two PositiveSafeInt values.
237
- *
238
- * @example
239
- *
240
- * ```ts
241
- * const product = PositiveSafeInt.mul(
242
- * asPositiveSafeInt(50),
243
- * asPositiveSafeInt(20),
244
- * );
245
- *
246
- * assert.isTrue(product === 1000);
247
- *
248
- * assert.isTrue(PositiveSafeInt.is(product));
249
- * ```
250
- *
251
- * @param a The first PositiveSafeInt.
252
- * @param b The second PositiveSafeInt.
253
- * @returns `a * b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
254
- */
255
- mul,
256
- /**
257
- * Divides one PositiveSafeInt by another using floor division.
258
- *
259
- * @example
260
- *
261
- * ```ts
262
- * const quotient = PositiveSafeInt.div(
263
- * asPositiveSafeInt(25),
264
- * asPositiveSafeInt(4),
265
- * );
266
- *
267
- * const clamped = PositiveSafeInt.div(
268
- * asPositiveSafeInt(5),
269
- * asPositiveSafeInt(50),
270
- * );
271
- *
272
- * assert.isTrue(quotient === 6);
273
- *
274
- * assert.isTrue(clamped === 1);
275
- * ```
276
- *
277
- * @param a The dividend PositiveSafeInt.
278
- * @param b The divisor PositiveSafeInt.
279
- * @returns `⌊a / b⌋` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
280
- */
281
- div,
28
+ /**
29
+ * Type guard to check if a value is a PositiveSafeInt.
30
+ *
31
+ * @example
32
+ *
33
+ * ```ts
34
+ * assert.isTrue(isPositiveSafeInt(1));
35
+ *
36
+ * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));
37
+ *
38
+ * assert.isFalse(isPositiveSafeInt(0));
39
+ *
40
+ * assert.isTrue(PositiveSafeInt.is(42));
41
+ * ```
42
+ *
43
+ * @param value The value to check.
44
+ * @returns `true` if the value is a positive safe integer, `false` otherwise.
45
+ * @see {@link isPositiveSafeInt} for usage examples
46
+ */
47
+ is,
48
+ /**
49
+ * The minimum value for a positive safe integer.
50
+ *
51
+ * @readonly
52
+ */
53
+ MIN_VALUE,
54
+ /**
55
+ * The maximum safe integer value (2^53 - 1).
56
+ *
57
+ * @readonly
58
+ */
59
+ MAX_VALUE,
60
+ /**
61
+ * Returns the smaller of two PositiveSafeInt values.
62
+ *
63
+ * @example
64
+ *
65
+ * ```ts
66
+ * const smallest = PositiveSafeInt.min(
67
+ * asPositiveSafeInt(10),
68
+ * asPositiveSafeInt(5),
69
+ * );
70
+ *
71
+ * assert.isTrue(smallest === 5);
72
+ * ```
73
+ *
74
+ * @param a The first PositiveSafeInt.
75
+ * @param b The second PositiveSafeInt.
76
+ * @returns The minimum value as a PositiveSafeInt.
77
+ */
78
+ min: min_,
79
+ /**
80
+ * Returns the larger of two PositiveSafeInt values.
81
+ *
82
+ * @example
83
+ *
84
+ * ```ts
85
+ * const largest = PositiveSafeInt.max(
86
+ * asPositiveSafeInt(10),
87
+ * asPositiveSafeInt(5),
88
+ * );
89
+ *
90
+ * assert.isTrue(largest === 10);
91
+ * ```
92
+ *
93
+ * @param a The first PositiveSafeInt.
94
+ * @param b The second PositiveSafeInt.
95
+ * @returns The maximum value as a PositiveSafeInt.
96
+ */
97
+ max: max_,
98
+ /**
99
+ * Clamps a number to the positive safe integer range.
100
+ *
101
+ * @example
102
+ *
103
+ * ```ts
104
+ * const belowRange = PositiveSafeInt.clamp(0);
105
+ *
106
+ * const withinRange = PositiveSafeInt.clamp(123);
107
+ *
108
+ * const aboveRange = PositiveSafeInt.clamp(Number.MAX_SAFE_INTEGER + 10);
109
+ *
110
+ * assert.isTrue(belowRange === 1);
111
+ *
112
+ * assert.isTrue(withinRange === 123);
113
+ *
114
+ * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);
115
+ * ```
116
+ *
117
+ * @param value The number to clamp.
118
+ * @returns The value clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
119
+ */
120
+ clamp,
121
+ /**
122
+ * Generates a random PositiveSafeInt value within the valid range.
123
+ *
124
+ * @example
125
+ *
126
+ * ```ts
127
+ * const min = asPositiveSafeInt(1);
128
+ *
129
+ * const max = asPositiveSafeInt(6);
130
+ *
131
+ * const randomValue = PositiveSafeInt.random(min, max);
132
+ *
133
+ * assert.isTrue(PositiveSafeInt.is(randomValue));
134
+ *
135
+ * assert.isTrue(randomValue >= 1 && randomValue <= 6);
136
+ * ```
137
+ *
138
+ * @returns A random PositiveSafeInt between 1 and MAX_SAFE_INTEGER.
139
+ */
140
+ random,
141
+ /**
142
+ * Raises a PositiveSafeInt to the power of another PositiveSafeInt.
143
+ *
144
+ * @example
145
+ *
146
+ * ```ts
147
+ * const base = asPositiveSafeInt(3);
148
+ *
149
+ * const exponent = asPositiveSafeInt(3);
150
+ *
151
+ * const power = PositiveSafeInt.pow(base, exponent);
152
+ *
153
+ * assert.isTrue(power === 27);
154
+ * ```
155
+ *
156
+ * @param a The base PositiveSafeInt.
157
+ * @param b The exponent PositiveSafeInt.
158
+ * @returns `a ** b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
159
+ */
160
+ pow,
161
+ /**
162
+ * Adds two PositiveSafeInt values.
163
+ *
164
+ * @example
165
+ *
166
+ * ```ts
167
+ * const sum = PositiveSafeInt.add(
168
+ * asPositiveSafeInt(1000),
169
+ * asPositiveSafeInt(2048),
170
+ * );
171
+ *
172
+ * assert.isTrue(sum === 3048);
173
+ *
174
+ * assert.isTrue(PositiveSafeInt.is(sum));
175
+ * ```
176
+ *
177
+ * @param a The first PositiveSafeInt.
178
+ * @param b The second PositiveSafeInt.
179
+ * @returns `a + b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
180
+ */
181
+ add,
182
+ /**
183
+ * Subtracts one PositiveSafeInt from another.
184
+ *
185
+ * @example
186
+ *
187
+ * ```ts
188
+ * const difference = PositiveSafeInt.sub(
189
+ * asPositiveSafeInt(10),
190
+ * asPositiveSafeInt(20),
191
+ * );
192
+ *
193
+ * assert.isTrue(difference === 1);
194
+ *
195
+ * assert.isTrue(PositiveSafeInt.is(difference));
196
+ * ```
197
+ *
198
+ * @param a The minuend PositiveSafeInt.
199
+ * @param b The subtrahend PositiveSafeInt.
200
+ * @returns `a - b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt
201
+ * (minimum 1).
202
+ */
203
+ sub,
204
+ /**
205
+ * Multiplies two PositiveSafeInt values.
206
+ *
207
+ * @example
208
+ *
209
+ * ```ts
210
+ * const product = PositiveSafeInt.mul(
211
+ * asPositiveSafeInt(50),
212
+ * asPositiveSafeInt(20),
213
+ * );
214
+ *
215
+ * assert.isTrue(product === 1000);
216
+ *
217
+ * assert.isTrue(PositiveSafeInt.is(product));
218
+ * ```
219
+ *
220
+ * @param a The first PositiveSafeInt.
221
+ * @param b The second PositiveSafeInt.
222
+ * @returns `a * b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
223
+ */
224
+ mul,
225
+ /**
226
+ * Divides one PositiveSafeInt by another using floor division.
227
+ *
228
+ * @example
229
+ *
230
+ * ```ts
231
+ * const quotient = PositiveSafeInt.div(
232
+ * asPositiveSafeInt(25),
233
+ * asPositiveSafeInt(4),
234
+ * );
235
+ *
236
+ * const clamped = PositiveSafeInt.div(
237
+ * asPositiveSafeInt(5),
238
+ * asPositiveSafeInt(50),
239
+ * );
240
+ *
241
+ * assert.isTrue(quotient === 6);
242
+ *
243
+ * assert.isTrue(clamped === 1);
244
+ * ```
245
+ *
246
+ * @param a The dividend PositiveSafeInt.
247
+ * @param b The divisor PositiveSafeInt.
248
+ * @returns `⌊a / b⌋` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.
249
+ */
250
+ div
282
251
  };
283
252
 
284
253
  export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt };
@@ -1 +1 @@
1
- {"version":3,"file":"positive-safe-int.mjs","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAWA,MAAM,iBAAiB,GAAG,yBAAyB;AAEnD,MAAM,EACJ,SAAS,EACT,SAAS,EACT,GAAG,EACH,QAAQ,EACR,KAAK,EACL,GAAG,EACH,EAAE,EACF,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,GAAG,EACH,MAAM,EACN,GAAG,GACJ,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,mBAAmB,CAI7D;AACA,IAAA,oBAAoB,EAAE,aAAa;AACnC,IAAA,SAAS,EAAE,CAAC;;IAEZ,SAAS,EAAE,MAAM,CAAC,gBAA4B;IAC9C,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,iBAAiB,GAAG;AAEjC;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,iBAAiB,GAAG;AAEjC;;;;;;;;AAQG;AACI,MAAM,eAAe,GAAG;AAC7B;;;;;;;;;;;;;;;;;;AAkBG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;AAIG;IACH,SAAS;AAET;;;;;;;;;;;;;;;;;AAiBG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;AAiBG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;;;;;;;;;;;;;;;;AAqBG;IACH,KAAK;AAEL;;;;;;;;;;;;;;;;;;AAkBG;IACH,MAAM;AAEN;;;;;;;;;;;;;;;;;;AAkBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;AAmBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;;AAoBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;AAmBG;IACH,GAAG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;IACH,GAAG;;;;;"}
1
+ {"version":3,"file":"positive-safe-int.mjs","sources":["../../../src/number/branded-types/positive-safe-int.mts"],"sourcesContent":["import {\n type SafeUint,\n type PositiveSafeInt as TtfImported_PositiveSafeInt,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type PositiveSafeInt = TtfImported_PositiveSafeInt;\n\ntype ElementType = PositiveSafeInt;\n\nconst typeNameInMessage = 'a positive safe integer';\n\nconst {\n MAX_VALUE,\n MIN_VALUE,\n add,\n castType,\n clamp,\n div,\n is,\n max: max_,\n min: min_,\n mul,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger<\n ElementType,\n 1,\n SafeUint\n>({\n integerOrSafeInteger: 'SafeInteger',\n MIN_VALUE: 1,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion, math/prefer-number-max-safe-integer\n MAX_VALUE: Number.MAX_SAFE_INTEGER as SafeUint,\n typeNameInMessage,\n} as const);\n\n/**\n * Checks if a number is a PositiveSafeInt (a positive safe integer in the range\n * [1, MAX_SAFE_INTEGER]).\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value The value to check.\n * @returns `true` if the value is a PositiveSafeInt, `false` otherwise.\n */\nexport const isPositiveSafeInt = is;\n\n/**\n * Casts a number to a PositiveSafeInt type.\n *\n * @example\n *\n * ```ts\n * const branded = asPositiveSafeInt(128);\n *\n * assert.isTrue(branded === 128);\n *\n * assert.isTrue(PositiveSafeInt.is(branded));\n * ```\n *\n * @param value The value to cast.\n * @returns The value as a PositiveSafeInt type.\n * @throws {TypeError} If the value is not a positive safe integer.\n */\nexport const asPositiveSafeInt = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for positive safe\n * integers.\n *\n * All operations automatically clamp results to the positive safe integer range\n * [1, MAX_SAFE_INTEGER]. This ensures that all arithmetic maintains both the\n * positive constraint and IEEE 754 precision guarantees, preventing precision\n * loss and ensuring results are always positive.\n */\nexport const PositiveSafeInt = {\n /**\n * Type guard to check if a value is a PositiveSafeInt.\n *\n * @example\n *\n * ```ts\n * assert.isTrue(isPositiveSafeInt(1));\n *\n * assert.isTrue(isPositiveSafeInt(Number.MAX_SAFE_INTEGER));\n *\n * assert.isFalse(isPositiveSafeInt(0));\n *\n * assert.isTrue(PositiveSafeInt.is(42));\n * ```\n *\n * @param value The value to check.\n * @returns `true` if the value is a positive safe integer, `false` otherwise.\n * @see {@link isPositiveSafeInt} for usage examples\n */\n is,\n\n /**\n * The minimum value for a positive safe integer.\n *\n * @readonly\n */\n MIN_VALUE,\n\n /**\n * The maximum safe integer value (2^53 - 1).\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the smaller of two PositiveSafeInt values.\n *\n * @example\n *\n * ```ts\n * const smallest = PositiveSafeInt.min(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(smallest === 5);\n * ```\n *\n * @param a The first PositiveSafeInt.\n * @param b The second PositiveSafeInt.\n * @returns The minimum value as a PositiveSafeInt.\n */\n min: min_,\n\n /**\n * Returns the larger of two PositiveSafeInt values.\n *\n * @example\n *\n * ```ts\n * const largest = PositiveSafeInt.max(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(5),\n * );\n *\n * assert.isTrue(largest === 10);\n * ```\n *\n * @param a The first PositiveSafeInt.\n * @param b The second PositiveSafeInt.\n * @returns The maximum value as a PositiveSafeInt.\n */\n max: max_,\n\n /**\n * Clamps a number to the positive safe integer range.\n *\n * @example\n *\n * ```ts\n * const belowRange = PositiveSafeInt.clamp(0);\n *\n * const withinRange = PositiveSafeInt.clamp(123);\n *\n * const aboveRange = PositiveSafeInt.clamp(Number.MAX_SAFE_INTEGER + 10);\n *\n * assert.isTrue(belowRange === 1);\n *\n * assert.isTrue(withinRange === 123);\n *\n * assert.isTrue(aboveRange === Number.MAX_SAFE_INTEGER);\n * ```\n *\n * @param value The number to clamp.\n * @returns The value clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.\n */\n clamp,\n\n /**\n * Generates a random PositiveSafeInt value within the valid range.\n *\n * @example\n *\n * ```ts\n * const min = asPositiveSafeInt(1);\n *\n * const max = asPositiveSafeInt(6);\n *\n * const randomValue = PositiveSafeInt.random(min, max);\n *\n * assert.isTrue(PositiveSafeInt.is(randomValue));\n *\n * assert.isTrue(randomValue >= 1 && randomValue <= 6);\n * ```\n *\n * @returns A random PositiveSafeInt between 1 and MAX_SAFE_INTEGER.\n */\n random,\n\n /**\n * Raises a PositiveSafeInt to the power of another PositiveSafeInt.\n *\n * @example\n *\n * ```ts\n * const base = asPositiveSafeInt(3);\n *\n * const exponent = asPositiveSafeInt(3);\n *\n * const power = PositiveSafeInt.pow(base, exponent);\n *\n * assert.isTrue(power === 27);\n * ```\n *\n * @param a The base PositiveSafeInt.\n * @param b The exponent PositiveSafeInt.\n * @returns `a ** b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.\n */\n pow,\n\n /**\n * Adds two PositiveSafeInt values.\n *\n * @example\n *\n * ```ts\n * const sum = PositiveSafeInt.add(\n * asPositiveSafeInt(1000),\n * asPositiveSafeInt(2048),\n * );\n *\n * assert.isTrue(sum === 3048);\n *\n * assert.isTrue(PositiveSafeInt.is(sum));\n * ```\n *\n * @param a The first PositiveSafeInt.\n * @param b The second PositiveSafeInt.\n * @returns `a + b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.\n */\n add,\n\n /**\n * Subtracts one PositiveSafeInt from another.\n *\n * @example\n *\n * ```ts\n * const difference = PositiveSafeInt.sub(\n * asPositiveSafeInt(10),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(difference === 1);\n *\n * assert.isTrue(PositiveSafeInt.is(difference));\n * ```\n *\n * @param a The minuend PositiveSafeInt.\n * @param b The subtrahend PositiveSafeInt.\n * @returns `a - b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt\n * (minimum 1).\n */\n sub,\n\n /**\n * Multiplies two PositiveSafeInt values.\n *\n * @example\n *\n * ```ts\n * const product = PositiveSafeInt.mul(\n * asPositiveSafeInt(50),\n * asPositiveSafeInt(20),\n * );\n *\n * assert.isTrue(product === 1000);\n *\n * assert.isTrue(PositiveSafeInt.is(product));\n * ```\n *\n * @param a The first PositiveSafeInt.\n * @param b The second PositiveSafeInt.\n * @returns `a * b` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.\n */\n mul,\n\n /**\n * Divides one PositiveSafeInt by another using floor division.\n *\n * @example\n *\n * ```ts\n * const quotient = PositiveSafeInt.div(\n * asPositiveSafeInt(25),\n * asPositiveSafeInt(4),\n * );\n *\n * const clamped = PositiveSafeInt.div(\n * asPositiveSafeInt(5),\n * asPositiveSafeInt(50),\n * );\n *\n * assert.isTrue(quotient === 6);\n *\n * assert.isTrue(clamped === 1);\n * ```\n *\n * @param a The dividend PositiveSafeInt.\n * @param b The divisor PositiveSafeInt.\n * @returns `⌊a / b⌋` clamped to [1, MAX_SAFE_INTEGER] as a PositiveSafeInt.\n */\n div,\n} as const;\n\nexpectType<\n keyof typeof PositiveSafeInt,\n keyof TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('=');\n\nexpectType<\n typeof PositiveSafeInt,\n TsDataForgeInternals.RefinedNumberUtils.NumberClass<\n ElementType,\n 'int' | 'positive' | 'range'\n >\n>('<=');\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAA,GAAoB,yBAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,mBAAA,CAI1C;AAAA,EACA,oBAAA,EAAsB,aAAA;AAAA,EACtB,SAAA,EAAW,CAAA;AAAA;AAAA,EAEX,WAAW,MAAA,CAAO,gBAAA;AAAA,EAClB;AACF,CAAU,CAAA;AAqBH,MAAM,iBAAA,GAAoB;AAmB1B,MAAM,iBAAA,GAAoB;AAW1B,MAAM,eAAA,GAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB7B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BA;AACF;;;;"}
@@ -16,19 +16,19 @@ export declare const isPositiveUint16: (a: number) => a is TtfImported_PositiveU
16
16
  * @throws {TypeError} If the value is not a positive integer in [1, 2^16).
17
17
  */
18
18
  export declare const asPositiveUint16: <N extends number>(x: N) => number & {
19
- readonly NaNValue: false;
20
- readonly Finite: true;
21
- readonly Int: true;
19
+ readonly "!=0": true;
20
+ readonly "< 2^16": true;
21
+ readonly "< 2^31": true;
22
+ readonly "< 2^32": true;
23
+ readonly "<=0": false;
22
24
  readonly "> -2^16": true;
23
25
  readonly "> -2^32": true;
24
26
  readonly ">= -2^15": true;
25
27
  readonly ">= -2^31": true;
26
28
  readonly ">=0": true;
27
- readonly "!=0": true;
28
- readonly "<=0": false;
29
- readonly "< 2^16": true;
30
- readonly "< 2^31": true;
31
- readonly "< 2^32": true;
29
+ readonly Finite: true;
30
+ readonly Int: true;
31
+ readonly NaNValue: false;
32
32
  readonly SafeInt: true;
33
33
  } & Readonly<{
34
34
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
@@ -131,20 +131,20 @@ export declare const PositiveUint16: {
131
131
  * @param b The divisor PositiveUint16.
132
132
  * @returns `⌊a / b⌋` clamped to [1, 65535] as a PositiveUint16.
133
133
  */
134
- readonly div: (x: import("ts-type-forge").WithSmallInt<TtfImported_PositiveUint16>, y: 1 | 2 | 3 | 32 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 10 | 20 | 30 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | import("ts-type-forge").NormalizeBrandUnion<number & {
135
- readonly NaNValue: false;
136
- readonly Finite: true;
137
- readonly Int: true;
134
+ readonly div: (x: import("ts-type-forge").WithSmallInt<TtfImported_PositiveUint16>, y: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | import("ts-type-forge").NormalizeBrandUnion<number & {
135
+ readonly "!=0": true;
136
+ readonly "< 2^16": true;
137
+ readonly "< 2^31": true;
138
+ readonly "< 2^32": true;
139
+ readonly "<=0": false;
138
140
  readonly "> -2^16": true;
139
141
  readonly "> -2^32": true;
140
142
  readonly ">= -2^15": true;
141
143
  readonly ">= -2^31": true;
142
144
  readonly ">=0": true;
143
- readonly "!=0": true;
144
- readonly "<=0": false;
145
- readonly "< 2^16": true;
146
- readonly "< 2^31": true;
147
- readonly "< 2^32": true;
145
+ readonly Finite: true;
146
+ readonly Int: true;
147
+ readonly NaNValue: false;
148
148
  readonly SafeInt: true;
149
149
  } & Readonly<{
150
150
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;