ts-data-forge 10.0.0 → 11.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 (249) hide show
  1. package/dist/array/impl/array-utils-creation.d.mts +3 -3
  2. package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-creation.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-element-access.d.mts +4 -4
  5. package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
  6. package/dist/{guard/as-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-cast.d.mts} +9 -9
  7. package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
  8. package/dist/{guard/as-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-cast.mjs} +2 -2
  9. package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
  10. package/dist/{guard/is-length-bounded-array.d.mts → array/impl/array-utils-length-bounded-array-guard.d.mts} +13 -13
  11. package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
  12. package/dist/{guard/is-length-bounded-array.mjs → array/impl/array-utils-length-bounded-array-guard.mjs} +1 -1
  13. package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
  14. package/dist/array/impl/array-utils-modification.d.mts +9 -9
  15. package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
  16. package/dist/array/impl/array-utils-modification.mjs.map +1 -1
  17. package/dist/array/impl/array-utils-reducing-value.d.mts +9 -9
  18. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  19. package/dist/array/impl/array-utils-size.d.mts +3 -3
  20. package/dist/array/impl/array-utils-size.mjs.map +1 -1
  21. package/dist/array/impl/array-utils-slicing.d.mts +9 -9
  22. package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
  23. package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
  24. package/dist/array/impl/array-utils-transformation.d.mts +16 -10
  25. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  26. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  27. package/dist/array/impl/index.d.mts +2 -0
  28. package/dist/array/impl/index.d.mts.map +1 -1
  29. package/dist/array/impl/index.mjs +2 -0
  30. package/dist/array/impl/index.mjs.map +1 -1
  31. package/dist/entry-point.mjs +1 -3
  32. package/dist/entry-point.mjs.map +1 -1
  33. package/dist/guard/index.d.mts +0 -3
  34. package/dist/guard/index.d.mts.map +1 -1
  35. package/dist/guard/index.mjs +0 -3
  36. package/dist/guard/index.mjs.map +1 -1
  37. package/dist/index.d.mts +1 -0
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +1 -3
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/number/branded-types/finite-number.d.mts +47 -61
  42. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/finite-number.mjs +37 -41
  44. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/int.d.mts +40 -46
  46. package/dist/number/branded-types/int.d.mts.map +1 -1
  47. package/dist/number/branded-types/int.mjs +29 -31
  48. package/dist/number/branded-types/int.mjs.map +1 -1
  49. package/dist/number/branded-types/int16.d.mts +65 -58
  50. package/dist/number/branded-types/int16.d.mts.map +1 -1
  51. package/dist/number/branded-types/int16.mjs +49 -45
  52. package/dist/number/branded-types/int16.mjs.map +1 -1
  53. package/dist/number/branded-types/int32.d.mts +65 -58
  54. package/dist/number/branded-types/int32.d.mts.map +1 -1
  55. package/dist/number/branded-types/int32.mjs +49 -45
  56. package/dist/number/branded-types/int32.mjs.map +1 -1
  57. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  58. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  59. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  60. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  61. package/dist/number/branded-types/negative-int.d.mts +60 -48
  62. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  63. package/dist/number/branded-types/negative-int.mjs +40 -36
  64. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  65. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  66. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  67. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  68. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  69. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  70. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  72. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  73. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  74. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  76. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  78. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  80. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  81. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  82. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  84. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  86. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  88. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  90. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  91. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  92. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  93. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  94. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  95. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  96. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  97. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  98. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  100. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  101. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  102. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  103. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  104. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  105. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  106. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  107. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  108. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  109. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  110. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  112. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  114. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  115. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  116. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  117. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  118. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  119. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  120. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  121. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  122. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  123. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  124. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  125. package/dist/number/branded-types/positive-int.d.mts +46 -68
  126. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  127. package/dist/number/branded-types/positive-int.mjs +34 -49
  128. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  129. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  130. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  131. package/dist/number/branded-types/positive-int16.mjs +44 -43
  132. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  133. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  134. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  135. package/dist/number/branded-types/positive-int32.mjs +44 -43
  136. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  137. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  138. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  139. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  140. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  141. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  142. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  143. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  144. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  145. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  146. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  147. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  148. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  149. package/dist/number/branded-types/safe-int.d.mts +43 -62
  150. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  151. package/dist/number/branded-types/safe-int.mjs +35 -42
  152. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  153. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  154. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  155. package/dist/number/branded-types/safe-uint.mjs +46 -44
  156. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  157. package/dist/number/branded-types/uint.d.mts +63 -50
  158. package/dist/number/branded-types/uint.d.mts.map +1 -1
  159. package/dist/number/branded-types/uint.mjs +42 -39
  160. package/dist/number/branded-types/uint.mjs.map +1 -1
  161. package/dist/number/branded-types/uint16.d.mts +60 -58
  162. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  163. package/dist/number/branded-types/uint16.mjs +44 -43
  164. package/dist/number/branded-types/uint16.mjs.map +1 -1
  165. package/dist/number/branded-types/uint32.d.mts +59 -55
  166. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  167. package/dist/number/branded-types/uint32.mjs +42 -42
  168. package/dist/number/branded-types/uint32.mjs.map +1 -1
  169. package/dist/number/enum/int8.d.mts +56 -65
  170. package/dist/number/enum/int8.d.mts.map +1 -1
  171. package/dist/number/enum/int8.mjs +44 -43
  172. package/dist/number/enum/int8.mjs.map +1 -1
  173. package/dist/number/enum/uint8.d.mts +60 -58
  174. package/dist/number/enum/uint8.d.mts.map +1 -1
  175. package/dist/number/enum/uint8.mjs +44 -43
  176. package/dist/number/enum/uint8.mjs.map +1 -1
  177. package/dist/string/index.d.mts +2 -0
  178. package/dist/string/index.d.mts.map +1 -0
  179. package/dist/string/index.mjs +2 -0
  180. package/dist/string/index.mjs.map +1 -0
  181. package/dist/string/str.d.mts +273 -0
  182. package/dist/string/str.d.mts.map +1 -0
  183. package/dist/string/str.mjs +42 -0
  184. package/dist/string/str.mjs.map +1 -0
  185. package/package.json +31 -92
  186. package/src/array/impl/array-utils-creation.mts +2 -1
  187. package/src/array/impl/array-utils-element-access.mts +3 -3
  188. package/src/array/impl/array-utils-element-access.test.mts +3 -3
  189. package/src/{guard/as-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-cast.mts} +9 -9
  190. package/src/{guard/as-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-cast.test.mts} +2 -2
  191. package/src/{guard/is-length-bounded-array.mts → array/impl/array-utils-length-bounded-array-guard.mts} +12 -12
  192. package/src/{guard/is-length-bounded-array.test.mts → array/impl/array-utils-length-bounded-array-guard.test.mts} +2 -2
  193. package/src/array/impl/array-utils-modification.mts +9 -8
  194. package/src/array/impl/array-utils-modification.test.mts +6 -1
  195. package/src/array/impl/array-utils-reducing-value.mts +9 -9
  196. package/src/array/impl/array-utils-size.mts +2 -2
  197. package/src/array/impl/array-utils-slicing.mts +24 -13
  198. package/src/array/impl/array-utils-transformation.mts +18 -12
  199. package/src/array/impl/array-utils-transformation.test.mts +12 -12
  200. package/src/array/impl/index.mts +2 -0
  201. package/src/guard/index.mts +0 -3
  202. package/src/index.mts +1 -0
  203. package/src/number/branded-types/finite-number.mts +47 -61
  204. package/src/number/branded-types/int.mts +40 -46
  205. package/src/number/branded-types/int16.mts +65 -58
  206. package/src/number/branded-types/int32.mts +65 -58
  207. package/src/number/branded-types/negative-finite-number.mts +68 -68
  208. package/src/number/branded-types/negative-int.mts +60 -57
  209. package/src/number/branded-types/negative-safe-int.mts +57 -65
  210. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  211. package/src/number/branded-types/non-negative-int16.mts +64 -57
  212. package/src/number/branded-types/non-negative-int32.mts +64 -58
  213. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  214. package/src/number/branded-types/non-positive-int.mts +41 -146
  215. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  216. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  217. package/src/number/branded-types/non-zero-int.mts +51 -38
  218. package/src/number/branded-types/non-zero-int16.mts +52 -53
  219. package/src/number/branded-types/non-zero-int32.mts +52 -54
  220. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  221. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  222. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  223. package/src/number/branded-types/positive-finite-number.mts +74 -63
  224. package/src/number/branded-types/positive-int.mts +46 -68
  225. package/src/number/branded-types/positive-int16.mts +61 -57
  226. package/src/number/branded-types/positive-int32.mts +61 -57
  227. package/src/number/branded-types/positive-safe-int.mts +62 -57
  228. package/src/number/branded-types/positive-uint16.mts +61 -57
  229. package/src/number/branded-types/positive-uint32.mts +61 -58
  230. package/src/number/branded-types/safe-int.mts +43 -62
  231. package/src/number/branded-types/safe-uint.mts +62 -57
  232. package/src/number/branded-types/uint.mts +63 -50
  233. package/src/number/branded-types/uint16.mts +60 -58
  234. package/src/number/branded-types/uint32.mts +59 -55
  235. package/src/number/enum/int8.mts +56 -65
  236. package/src/number/enum/uint8.mts +60 -58
  237. package/src/string/index.mts +1 -0
  238. package/src/string/str.mts +371 -0
  239. package/src/string/str.test.mts +215 -0
  240. package/dist/guard/as-length-bounded-array.d.mts.map +0 -1
  241. package/dist/guard/as-length-bounded-array.mjs.map +0 -1
  242. package/dist/guard/is-length-bounded-array.d.mts.map +0 -1
  243. package/dist/guard/is-length-bounded-array.mjs.map +0 -1
  244. package/dist/guard/is-length-bounded-string.d.mts +0 -163
  245. package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
  246. package/dist/guard/is-length-bounded-string.mjs +0 -7
  247. package/dist/guard/is-length-bounded-string.mjs.map +0 -1
  248. package/src/guard/is-length-bounded-string.mts +0 -199
  249. package/src/guard/is-length-bounded-string.test.mts +0 -170
@@ -31,117 +31,118 @@ const {
31
31
  } as const);
32
32
 
33
33
  /**
34
- * Checks if a number is a NonPositiveSafeInt (non-positive safe integer in the
35
- * range [Number.MIN_SAFE_INTEGER, 0]).
34
+ * Type guard that checks if a value is a non-positive safe integer.
36
35
  *
37
- * @param value The value to check.
38
- * @returns `true` if the value is a NonPositiveSafeInt, `false` otherwise.
36
+ * Returns `true` for a non-positive safe integer — a value with no fractional
37
+ * component.
38
+ *
39
+ * @param value - The value to check
40
+ * @returns `true` if the value is a non-positive safe integer, `false` otherwise
39
41
  */
40
42
  export const isNonPositiveSafeInt = is;
41
43
 
42
44
  /**
43
- * Casts a number to a NonPositiveSafeInt type.
45
+ * Casts a `number` to the `NonPositiveSafeInt` branded type.
46
+ *
47
+ * Validates that the value is a non-positive safe integer and returns it with
48
+ * the `NonPositiveSafeInt` brand. Throws a `TypeError` otherwise.
44
49
  *
45
- * @param value The value to cast.
46
- * @returns The value as a NonPositiveSafeInt type.
47
- * @throws {TypeError} If the value is not a non-positive safe integer.
50
+ * @param value - The value to cast
51
+ * @returns The value as a `NonPositiveSafeInt`
52
+ * @throws {TypeError} If the value is not a non-positive safe integer
48
53
  */
49
54
  export const asNonPositiveSafeInt = castType;
50
55
 
51
56
  /**
52
- * Namespace providing type-safe arithmetic operations for non-positive
53
- * safe integers.
57
+ * Namespace providing type-safe operations for the `NonPositiveSafeInt` branded
58
+ * type.
54
59
  *
55
- * All operations automatically clamp results to the valid NonPositiveSafeInt
56
- * range [Number.MIN_SAFE_INTEGER, 0]. This ensures that all arithmetic
57
- * maintains the non-positive safe integer constraint, with positive results
58
- * clamped to 0 and underflow results clamped to MIN_VALUE.
60
+ * The `NonPositiveSafeInt` type represents a non-positive safe integer.
61
+ * Division (`div`) uses floor division.
59
62
  */
60
63
  export const NonPositiveSafeInt = {
61
64
  /**
62
- * Type guard to check if a value is a NonPositiveSafeInt.
65
+ * Type guard that checks if a value is a non-positive safe integer.
63
66
  *
64
- * @param value The value to check.
65
- * @returns `true` if the value is a non-positive safe integer, `false`
66
- * otherwise.
67
+ * @param value - The value to check
68
+ * @returns `true` if the value is a non-positive safe integer, `false` otherwise
69
+ * @see {@link isNonPositiveSafeInt} for usage examples
67
70
  */
68
71
  is,
69
72
 
70
73
  /**
71
- * The minimum value for a non-positive safe integer.
72
- *
73
- * @readonly
74
+ * The smallest value representable as `NonPositiveSafeInt`.
74
75
  */
75
76
  MIN_VALUE,
76
77
 
77
78
  /**
78
- * The maximum value for a non-positive safe integer.
79
- *
80
- * @readonly
79
+ * The largest value representable as `NonPositiveSafeInt`.
81
80
  */
82
81
  MAX_VALUE,
83
82
 
84
83
  /**
85
- * Returns the smaller of two NonPositiveSafeInt values.
84
+ * Returns the smallest of the given non-positive safe integers.
86
85
  *
87
- * @param a The first NonPositiveSafeInt.
88
- * @param b The second NonPositiveSafeInt.
89
- * @returns The minimum value as a NonPositiveSafeInt.
86
+ * @param values - The non-positive safe integers to compare (at least one required)
87
+ * @returns The smallest value as a `NonPositiveSafeInt`
90
88
  */
91
89
  min: min_,
92
90
 
93
91
  /**
94
- * Returns the larger of two NonPositiveSafeInt values.
92
+ * Returns the largest of the given non-positive safe integers.
95
93
  *
96
- * @param a The first NonPositiveSafeInt.
97
- * @param b The second NonPositiveSafeInt.
98
- * @returns The maximum value as a NonPositiveSafeInt.
94
+ * @param values - The non-positive safe integers to compare (at least one required)
95
+ * @returns The largest value as a `NonPositiveSafeInt`
99
96
  */
100
97
  max: max_,
101
98
 
102
99
  /**
103
- * Clamps a number to the NonPositiveSafeInt range.
100
+ * Clamps a `number` into the `NonPositiveSafeInt` range, rounding to the
101
+ * nearest integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
104
102
  *
105
- * @param value The number to clamp.
106
- * @returns The value clamped to [Number.MIN_SAFE_INTEGER, 0] as a
107
- * NonPositiveSafeInt.
103
+ * @param value - The value to clamp
104
+ * @returns The clamped value as a `NonPositiveSafeInt`
108
105
  */
109
106
  clamp,
110
107
 
111
108
  /**
112
- * Generates a random NonPositiveSafeInt value within the valid range.
109
+ * Generates a random `NonPositiveSafeInt` within the given range.
110
+ *
111
+ * The range is inclusive on both ends.
113
112
  *
114
- * @returns A random NonPositiveSafeInt between Number.MIN_SAFE_INTEGER and 0.
113
+ * @param min - The minimum value (inclusive)
114
+ * @param max - The maximum value (inclusive)
115
+ * @returns A random `NonPositiveSafeInt` in `[min, max]`
115
116
  */
116
117
  random,
117
118
 
118
119
  /**
119
- * Raises a NonPositiveSafeInt to the power of another NonPositiveSafeInt.
120
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveSafeInt`
121
+ * (floored to an integer).
120
122
  *
121
- * @param a The base NonPositiveSafeInt.
122
- * @param b The exponent NonPositiveSafeInt.
123
- * @returns `a ** b` clamped to [Number.MIN_SAFE_INTEGER, 0] as a
124
- * NonPositiveSafeInt.
123
+ * @param a - The base non-positive safe integer
124
+ * @param b - The exponent non-positive safe integer
125
+ * @returns `a ** b` as a `NonPositiveSafeInt`
125
126
  */
126
127
  pow,
127
128
 
128
129
  /**
129
- * Adds two NonPositiveSafeInt values.
130
+ * Adds two non-positive safe integers, returning `a + b` as a
131
+ * `NonPositiveSafeInt`.
130
132
  *
131
- * @param a The first NonPositiveSafeInt.
132
- * @param b The second NonPositiveSafeInt.
133
- * @returns `a + b` clamped to [Number.MIN_SAFE_INTEGER, 0] as a
134
- * NonPositiveSafeInt.
133
+ * @param a - The first non-positive safe integer
134
+ * @param b - The second non-positive safe integer
135
+ * @returns The sum of `a` and `b` as a `NonPositiveSafeInt`
135
136
  */
136
137
  add,
137
138
 
138
139
  /**
139
- * Subtracts one NonPositiveSafeInt from another.
140
+ * Subtracts two non-positive safe integers, returning `a - b` as a
141
+ * `NonPositiveSafeInt`.
140
142
  *
141
- * @param a The minuend NonPositiveSafeInt.
142
- * @param b The subtrahend NonPositiveSafeInt.
143
- * @returns `a - b` clamped to [Number.MIN_SAFE_INTEGER, 0] as a
144
- * NonPositiveSafeInt (maximum 0).
143
+ * @param a - The first non-positive safe integer
144
+ * @param b - The second non-positive safe integer
145
+ * @returns The difference of `a` and `b` as a `NonPositiveSafeInt`
145
146
  */
146
147
  sub,
147
148
  } as const;
@@ -34,8 +34,6 @@ const {
34
34
  typeNameInMessage,
35
35
  } as const);
36
36
 
37
- // Not provided because reasonable rounding operations that avoid becoming 0 cannot be defined
38
-
39
37
  const floor = (
40
38
  x: ElementType,
41
39
  ): TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType> =>
@@ -67,125 +65,138 @@ expectType<
67
65
  >('=');
68
66
 
69
67
  /**
70
- * Checks if a number is a NonZeroFiniteNumber (a finite number that is not 0).
68
+ * Type guard that checks if a value is a non-zero finite number.
69
+ *
70
+ * Returns `true` only for a finite value — never `NaN`, `Infinity`, or
71
+ * `-Infinity`.
71
72
  *
72
- * @param value The value to check.
73
- * @returns `true` if the value is a NonZeroFiniteNumber, `false` otherwise.
73
+ * @param value - The value to check
74
+ * @returns `true` if the value is a non-zero finite number, `false` otherwise
74
75
  */
75
76
  export const isNonZeroFiniteNumber = is;
76
77
 
77
78
  /**
78
- * Casts a number to a NonZeroFiniteNumber type.
79
+ * Casts a `number` to the `NonZeroFiniteNumber` branded type.
80
+ *
81
+ * Validates that the value is a non-zero finite number and returns it with the
82
+ * `NonZeroFiniteNumber` brand. Throws a `TypeError` otherwise.
79
83
  *
80
- * @param value The value to cast.
81
- * @returns The value as a NonZeroFiniteNumber type.
82
- * @throws {TypeError} If the value is not a non-zero finite number.
84
+ * @param value - The value to cast
85
+ * @returns The value as a `NonZeroFiniteNumber`
86
+ * @throws {TypeError} If the value is not a non-zero finite number
83
87
  */
84
88
  export const asNonZeroFiniteNumber = castType;
85
89
 
86
90
  /**
87
- * Namespace providing type-safe arithmetic operations for non-zero finite
88
- * numbers.
91
+ * Namespace providing type-safe operations for the `NonZeroFiniteNumber`
92
+ * branded type.
89
93
  *
90
- * All operations maintain the non-zero constraint while ensuring results remain
91
- * finite (excluding NaN and Infinity). This type is useful for values that must
92
- * never be zero, such as denominators, scaling factors, and ratios.
94
+ * The `NonZeroFiniteNumber` type represents a non-zero finite number.
93
95
  */
94
96
  export const NonZeroFiniteNumber = {
95
97
  /**
96
- * Type guard to check if a value is a NonZeroFiniteNumber.
98
+ * Type guard that checks if a value is a non-zero finite number.
97
99
  *
98
- * @param value The value to check.
99
- * @returns `true` if the value is a non-zero finite number, `false`
100
- * otherwise.
100
+ * @param value - The value to check
101
+ * @returns `true` if the value is a non-zero finite number, `false` otherwise
102
+ * @see {@link isNonZeroFiniteNumber} for usage examples
101
103
  */
102
104
  is,
103
105
 
104
106
  /**
105
107
  * Returns the absolute value of a non-zero finite number.
106
108
  *
107
- * @param a The NonZeroFiniteNumber.
108
- * @returns The absolute value as a NonZeroFiniteNumber.
109
+ * The result is non-negative and keeps the `NonZeroFiniteNumber` brand.
110
+ *
111
+ * @param a - The non-zero finite number value
112
+ * @returns The absolute value as a non-negative `NonZeroFiniteNumber`
109
113
  */
110
114
  abs,
111
115
 
112
116
  /**
113
- * Returns the smaller of two NonZeroFiniteNumber values.
117
+ * Returns the smallest of the given non-zero finite numbers.
114
118
  *
115
- * @param a The first NonZeroFiniteNumber.
116
- * @param b The second NonZeroFiniteNumber.
117
- * @returns The minimum value as a NonZeroFiniteNumber.
119
+ * @param values - The non-zero finite numbers to compare (at least one required)
120
+ * @returns The smallest value as a `NonZeroFiniteNumber`
118
121
  */
119
122
  min: min_,
120
123
 
121
124
  /**
122
- * Returns the larger of two NonZeroFiniteNumber values.
125
+ * Returns the largest of the given non-zero finite numbers.
123
126
  *
124
- * @param a The first NonZeroFiniteNumber.
125
- * @param b The second NonZeroFiniteNumber.
126
- * @returns The maximum value as a NonZeroFiniteNumber.
127
+ * @param values - The non-zero finite numbers to compare (at least one required)
128
+ * @returns The largest value as a `NonZeroFiniteNumber`
127
129
  */
128
130
  max: max_,
129
131
 
130
132
  /**
131
- * Rounds down a NonZeroFiniteNumber to the nearest integer.
133
+ * Returns the greatest integer less than or equal to a non-zero finite
134
+ * number.
132
135
  *
133
- * @param x The NonZeroFiniteNumber to round down.
134
- * @returns The floor value as a NonZeroInt.
136
+ * @param a - The non-zero finite number value
137
+ * @returns The floored value as an integer
135
138
  */
136
139
  floor,
137
140
 
138
141
  /**
139
- * Rounds up a NonZeroFiniteNumber to the nearest integer.
142
+ * Returns the smallest integer greater than or equal to a non-zero finite
143
+ * number.
140
144
  *
141
- * @param x The NonZeroFiniteNumber to round up.
142
- * @returns The ceiling value as a NonZeroInt.
145
+ * @param a - The non-zero finite number value
146
+ * @returns The ceiled value as an integer
143
147
  */
144
148
  ceil,
145
149
 
146
150
  /**
147
- * Rounds a NonZeroFiniteNumber to the nearest integer.
151
+ * Returns the value of a non-zero finite number rounded to the nearest
152
+ * integer.
148
153
  *
149
- * @param x The NonZeroFiniteNumber to round.
150
- * @returns The rounded value as a NonZeroInt.
154
+ * @param a - The non-zero finite number value
155
+ * @returns The rounded value as an integer
151
156
  */
152
157
  round,
153
158
 
154
159
  /**
155
- * Generates a random NonZeroFiniteNumber value.
160
+ * Generates a random `NonZeroFiniteNumber` within the given range.
161
+ *
162
+ * The range is inclusive on both ends.
156
163
  *
157
- * @returns A random non-zero finite number.
164
+ * @param min - The minimum value (inclusive)
165
+ * @param max - The maximum value (inclusive)
166
+ * @returns A random `NonZeroFiniteNumber` in `[min, max]`
158
167
  */
159
168
  random,
160
169
 
161
170
  /**
162
- * Raises a NonZeroFiniteNumber to the power of another NonZeroFiniteNumber.
171
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroFiniteNumber`.
163
172
  *
164
- * @param a The base NonZeroFiniteNumber.
165
- * @param b The exponent NonZeroFiniteNumber.
166
- * @returns `a ** b` as a NonZeroFiniteNumber.
173
+ * @param a - The base non-zero finite number
174
+ * @param b - The exponent non-zero finite number
175
+ * @returns `a ** b` as a `NonZeroFiniteNumber`
167
176
  */
168
177
  pow,
169
178
 
170
179
  /**
171
- * Multiplies two NonZeroFiniteNumber values.
180
+ * Multiplies two non-zero finite numbers, returning `a * b` as a
181
+ * `NonZeroFiniteNumber`.
172
182
  *
173
- * @param a The first NonZeroFiniteNumber.
174
- * @param b The second NonZeroFiniteNumber.
175
- * @returns `a * b` as a NonZeroFiniteNumber.
183
+ * @param a - The first non-zero finite number
184
+ * @param b - The second non-zero finite number
185
+ * @returns The product of `a` and `b` as a `NonZeroFiniteNumber`
176
186
  */
177
187
  mul,
178
188
 
179
189
  /**
180
- * Divides one NonZeroFiniteNumber by another.
190
+ * Divides two non-zero finite numbers, returning `a / b` as a
191
+ * `NonZeroFiniteNumber`.
181
192
  *
182
193
  * Exact (non-flooring) division of two non-zero finite numbers is always
183
194
  * non-zero, so this stays closed. For the non-closed operations (`add`/`sub`,
184
195
  * whose result may be `0`) use {@link Num.add}/{@link Num.sub}.
185
196
  *
186
- * @param a The dividend NonZeroFiniteNumber.
187
- * @param b The divisor NonZeroFiniteNumber.
188
- * @returns `a / b` as a NonZeroFiniteNumber.
197
+ * @param a - The dividend
198
+ * @param b - The divisor (must be non-zero)
199
+ * @returns `a / b` as a `NonZeroFiniteNumber`
189
200
  */
190
201
  div,
191
202
  } as const;
@@ -30,90 +30,103 @@ const {
30
30
  } as const);
31
31
 
32
32
  /**
33
- * Checks if a number is a NonZeroInt.
33
+ * Type guard that checks if a value is a non-zero integer.
34
34
  *
35
- * @param value The value to check.
36
- * @returns `true` if the value is a NonZeroInt, `false` otherwise.
35
+ * Returns `true` for a non-zero integer — a value with no fractional component,
36
+ * including values outside the safe integer range (unlike `SafeInt`).
37
+ *
38
+ * @param value - The value to check
39
+ * @returns `true` if the value is a non-zero integer, `false` otherwise
37
40
  */
38
41
  export const isNonZeroInt = is;
39
42
 
40
43
  /**
41
- * Casts a number to a NonZeroInt type.
44
+ * Casts a `number` to the `NonZeroInt` branded type.
45
+ *
46
+ * Validates that the value is a non-zero integer and returns it with the
47
+ * `NonZeroInt` brand. Throws a `TypeError` otherwise.
42
48
  *
43
- * @param value The value to cast.
44
- * @returns The value as a NonZeroInt type.
45
- * @throws {TypeError} If the value is not a non-zero integer.
49
+ * @param value - The value to cast
50
+ * @returns The value as a `NonZeroInt`
51
+ * @throws {TypeError} If the value is not a non-zero integer
46
52
  */
47
53
  export const asNonZeroInt = castType;
48
54
 
49
55
  /**
50
- * Namespace providing type-safe arithmetic operations for non-zero integers.
56
+ * Namespace providing type-safe operations for the `NonZeroInt` branded type.
57
+ *
58
+ * The `NonZeroInt` type represents a non-zero integer. Division (`div`) uses
59
+ * floor division.
51
60
  *
52
- * All operations maintain the non-zero constraint, ensuring that results are
53
- * always valid NonZeroInt values. Division operations return floor division
54
- * results, and all arithmetic maintains integer precision.
61
+ * Unlike `SafeInt`, `NonZeroInt` allows values outside the safe integer range
62
+ * (±2^53 − 1), so very large magnitudes may lose precision in JavaScript's
63
+ * `number` type.
55
64
  */
56
65
  export const NonZeroInt = {
57
66
  /**
58
- * Type guard to check if a value is a NonZeroInt.
67
+ * Type guard that checks if a value is a non-zero integer.
59
68
  *
60
- * @param value The value to check.
61
- * @returns `true` if the value is a non-zero integer, `false` otherwise.
69
+ * @param value - The value to check
70
+ * @returns `true` if the value is a non-zero integer, `false` otherwise
71
+ * @see {@link isNonZeroInt} for usage examples
62
72
  */
63
73
  is,
64
74
 
65
75
  /**
66
76
  * Returns the absolute value of a non-zero integer.
67
77
  *
68
- * @param a The non-zero integer.
69
- * @returns The absolute value as a NonZeroInt.
78
+ * The result is non-negative and keeps the `NonZeroInt` brand. Note that
79
+ * `Math.abs(Number.MIN_SAFE_INTEGER)` exceeds `Number.MAX_SAFE_INTEGER`, so
80
+ * use `SafeInt` for guaranteed precision.
81
+ *
82
+ * @param a - The non-zero integer value
83
+ * @returns The absolute value as a non-negative `NonZeroInt`
70
84
  */
71
85
  abs,
72
86
 
73
87
  /**
74
- * Returns the smaller of two non-zero integers.
88
+ * Returns the smallest of the given non-zero integers.
75
89
  *
76
- * @param a The first non-zero integer.
77
- * @param b The second non-zero integer.
78
- * @returns The minimum value as a NonZeroInt.
90
+ * @param values - The non-zero integers to compare (at least one required)
91
+ * @returns The smallest value as a `NonZeroInt`
79
92
  */
80
93
  min: min_,
81
94
 
82
95
  /**
83
- * Returns the larger of two non-zero integers.
96
+ * Returns the largest of the given non-zero integers.
84
97
  *
85
- * @param a The first non-zero integer.
86
- * @param b The second non-zero integer.
87
- * @returns The maximum value as a NonZeroInt.
98
+ * @param values - The non-zero integers to compare (at least one required)
99
+ * @returns The largest value as a `NonZeroInt`
88
100
  */
89
101
  max: max_,
90
102
 
91
103
  /**
92
- * Generates a random non-zero integer.
104
+ * Generates a random `NonZeroInt` within the given range.
105
+ *
106
+ * The range is inclusive on both ends.
93
107
  *
94
- * @returns A random NonZeroInt value.
108
+ * @param min - The minimum value (inclusive)
109
+ * @param max - The maximum value (inclusive)
110
+ * @returns A random `NonZeroInt` in `[min, max]`
95
111
  */
96
112
  random,
97
113
 
98
114
  /**
99
- * Raises a non-zero integer to the power of another non-zero integer.
115
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonZeroInt` (floored
116
+ * to an integer).
100
117
  *
101
- * @param a The base non-zero integer.
102
- * @param b The exponent non-zero integer.
103
- * @returns `a ** b` as a NonZeroInt.
118
+ * @param a - The base non-zero integer
119
+ * @param b - The exponent non-zero integer
120
+ * @returns `a ** b` as a `NonZeroInt`
104
121
  */
105
122
  pow,
106
123
 
107
124
  /**
108
- * Multiplies two non-zero integers.
109
- *
110
- * The product of two non-zero integers is always non-zero, so this stays
111
- * closed; for the non-closed operations (`add`/`sub`/`div`, whose result may
112
- * be `0`) use {@link Num.add}/{@link Num.sub}/{@link Num.divInt}.
125
+ * Multiplies two non-zero integers, returning `a * b` as a `NonZeroInt`.
113
126
  *
114
- * @param a The first non-zero integer.
115
- * @param b The second non-zero integer.
116
- * @returns `a * b` as a NonZeroInt.
127
+ * @param a - The first non-zero integer
128
+ * @param b - The second non-zero integer
129
+ * @returns The product of `a` and `b` as a `NonZeroInt`
117
130
  */
118
131
  mul,
119
132
  } as const;