ts-data-forge 11.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 (171) hide show
  1. package/dist/number/branded-types/finite-number.d.mts +47 -61
  2. package/dist/number/branded-types/finite-number.d.mts.map +1 -1
  3. package/dist/number/branded-types/finite-number.mjs +37 -41
  4. package/dist/number/branded-types/finite-number.mjs.map +1 -1
  5. package/dist/number/branded-types/int.d.mts +40 -46
  6. package/dist/number/branded-types/int.d.mts.map +1 -1
  7. package/dist/number/branded-types/int.mjs +29 -31
  8. package/dist/number/branded-types/int.mjs.map +1 -1
  9. package/dist/number/branded-types/int16.d.mts +65 -58
  10. package/dist/number/branded-types/int16.d.mts.map +1 -1
  11. package/dist/number/branded-types/int16.mjs +49 -45
  12. package/dist/number/branded-types/int16.mjs.map +1 -1
  13. package/dist/number/branded-types/int32.d.mts +65 -58
  14. package/dist/number/branded-types/int32.d.mts.map +1 -1
  15. package/dist/number/branded-types/int32.mjs +49 -45
  16. package/dist/number/branded-types/int32.mjs.map +1 -1
  17. package/dist/number/branded-types/negative-finite-number.d.mts +68 -59
  18. package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -1
  19. package/dist/number/branded-types/negative-finite-number.mjs +52 -46
  20. package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
  21. package/dist/number/branded-types/negative-int.d.mts +60 -48
  22. package/dist/number/branded-types/negative-int.d.mts.map +1 -1
  23. package/dist/number/branded-types/negative-int.mjs +40 -36
  24. package/dist/number/branded-types/negative-int.mjs.map +1 -1
  25. package/dist/number/branded-types/negative-safe-int.d.mts +57 -56
  26. package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -1
  27. package/dist/number/branded-types/negative-safe-int.mjs +40 -41
  28. package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
  29. package/dist/number/branded-types/non-negative-finite-number.d.mts +74 -64
  30. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
  31. package/dist/number/branded-types/non-negative-finite-number.mjs +58 -51
  32. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
  33. package/dist/number/branded-types/non-negative-int16.d.mts +64 -57
  34. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
  35. package/dist/number/branded-types/non-negative-int16.mjs +47 -43
  36. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
  37. package/dist/number/branded-types/non-negative-int32.d.mts +64 -58
  38. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
  39. package/dist/number/branded-types/non-negative-int32.mjs +47 -44
  40. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
  41. package/dist/number/branded-types/non-positive-finite-number.d.mts +64 -54
  42. package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -1
  43. package/dist/number/branded-types/non-positive-finite-number.mjs +48 -41
  44. package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
  45. package/dist/number/branded-types/non-positive-int.d.mts +41 -146
  46. package/dist/number/branded-types/non-positive-int.d.mts.map +1 -1
  47. package/dist/number/branded-types/non-positive-int.mjs +27 -107
  48. package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
  49. package/dist/number/branded-types/non-positive-safe-int.d.mts +54 -53
  50. package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -1
  51. package/dist/number/branded-types/non-positive-safe-int.mjs +37 -39
  52. package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
  53. package/dist/number/branded-types/non-zero-finite-number.d.mts +62 -49
  54. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
  55. package/dist/number/branded-types/non-zero-finite-number.mjs +46 -37
  56. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
  57. package/dist/number/branded-types/non-zero-int.d.mts +51 -38
  58. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
  59. package/dist/number/branded-types/non-zero-int.mjs +31 -27
  60. package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
  61. package/dist/number/branded-types/non-zero-int16.d.mts +52 -53
  62. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
  63. package/dist/number/branded-types/non-zero-int16.mjs +36 -39
  64. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
  65. package/dist/number/branded-types/non-zero-int32.d.mts +52 -54
  66. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
  67. package/dist/number/branded-types/non-zero-int32.mjs +36 -40
  68. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
  69. package/dist/number/branded-types/non-zero-safe-int.d.mts +53 -54
  70. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
  71. package/dist/number/branded-types/non-zero-safe-int.mjs +36 -40
  72. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
  73. package/dist/number/branded-types/non-zero-uint16.d.mts +52 -53
  74. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
  75. package/dist/number/branded-types/non-zero-uint16.mjs +35 -39
  76. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
  77. package/dist/number/branded-types/non-zero-uint32.d.mts +52 -53
  78. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
  79. package/dist/number/branded-types/non-zero-uint32.mjs +35 -39
  80. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
  81. package/dist/number/branded-types/positive-finite-number.d.mts +74 -63
  82. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
  83. package/dist/number/branded-types/positive-finite-number.mjs +58 -50
  84. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
  85. package/dist/number/branded-types/positive-int.d.mts +46 -68
  86. package/dist/number/branded-types/positive-int.d.mts.map +1 -1
  87. package/dist/number/branded-types/positive-int.mjs +34 -49
  88. package/dist/number/branded-types/positive-int.mjs.map +1 -1
  89. package/dist/number/branded-types/positive-int16.d.mts +61 -57
  90. package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
  91. package/dist/number/branded-types/positive-int16.mjs +44 -43
  92. package/dist/number/branded-types/positive-int16.mjs.map +1 -1
  93. package/dist/number/branded-types/positive-int32.d.mts +61 -57
  94. package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
  95. package/dist/number/branded-types/positive-int32.mjs +44 -43
  96. package/dist/number/branded-types/positive-int32.mjs.map +1 -1
  97. package/dist/number/branded-types/positive-safe-int.d.mts +62 -57
  98. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
  99. package/dist/number/branded-types/positive-safe-int.mjs +45 -43
  100. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
  101. package/dist/number/branded-types/positive-uint16.d.mts +61 -57
  102. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
  103. package/dist/number/branded-types/positive-uint16.mjs +44 -43
  104. package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
  105. package/dist/number/branded-types/positive-uint32.d.mts +61 -58
  106. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
  107. package/dist/number/branded-types/positive-uint32.mjs +44 -44
  108. package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
  109. package/dist/number/branded-types/safe-int.d.mts +43 -62
  110. package/dist/number/branded-types/safe-int.d.mts.map +1 -1
  111. package/dist/number/branded-types/safe-int.mjs +35 -42
  112. package/dist/number/branded-types/safe-int.mjs.map +1 -1
  113. package/dist/number/branded-types/safe-uint.d.mts +62 -57
  114. package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
  115. package/dist/number/branded-types/safe-uint.mjs +46 -44
  116. package/dist/number/branded-types/safe-uint.mjs.map +1 -1
  117. package/dist/number/branded-types/uint.d.mts +63 -50
  118. package/dist/number/branded-types/uint.d.mts.map +1 -1
  119. package/dist/number/branded-types/uint.mjs +42 -39
  120. package/dist/number/branded-types/uint.mjs.map +1 -1
  121. package/dist/number/branded-types/uint16.d.mts +60 -58
  122. package/dist/number/branded-types/uint16.d.mts.map +1 -1
  123. package/dist/number/branded-types/uint16.mjs +44 -43
  124. package/dist/number/branded-types/uint16.mjs.map +1 -1
  125. package/dist/number/branded-types/uint32.d.mts +59 -55
  126. package/dist/number/branded-types/uint32.d.mts.map +1 -1
  127. package/dist/number/branded-types/uint32.mjs +42 -42
  128. package/dist/number/branded-types/uint32.mjs.map +1 -1
  129. package/dist/number/enum/int8.d.mts +56 -65
  130. package/dist/number/enum/int8.d.mts.map +1 -1
  131. package/dist/number/enum/int8.mjs +44 -43
  132. package/dist/number/enum/int8.mjs.map +1 -1
  133. package/dist/number/enum/uint8.d.mts +60 -58
  134. package/dist/number/enum/uint8.d.mts.map +1 -1
  135. package/dist/number/enum/uint8.mjs +44 -43
  136. package/dist/number/enum/uint8.mjs.map +1 -1
  137. package/package.json +2 -1
  138. package/src/number/branded-types/finite-number.mts +47 -61
  139. package/src/number/branded-types/int.mts +40 -46
  140. package/src/number/branded-types/int16.mts +65 -58
  141. package/src/number/branded-types/int32.mts +65 -58
  142. package/src/number/branded-types/negative-finite-number.mts +68 -68
  143. package/src/number/branded-types/negative-int.mts +60 -57
  144. package/src/number/branded-types/negative-safe-int.mts +57 -65
  145. package/src/number/branded-types/non-negative-finite-number.mts +74 -64
  146. package/src/number/branded-types/non-negative-int16.mts +64 -57
  147. package/src/number/branded-types/non-negative-int32.mts +64 -58
  148. package/src/number/branded-types/non-positive-finite-number.mts +64 -54
  149. package/src/number/branded-types/non-positive-int.mts +41 -146
  150. package/src/number/branded-types/non-positive-safe-int.mts +54 -53
  151. package/src/number/branded-types/non-zero-finite-number.mts +62 -51
  152. package/src/number/branded-types/non-zero-int.mts +51 -38
  153. package/src/number/branded-types/non-zero-int16.mts +52 -53
  154. package/src/number/branded-types/non-zero-int32.mts +52 -54
  155. package/src/number/branded-types/non-zero-safe-int.mts +53 -54
  156. package/src/number/branded-types/non-zero-uint16.mts +52 -53
  157. package/src/number/branded-types/non-zero-uint32.mts +52 -53
  158. package/src/number/branded-types/positive-finite-number.mts +74 -63
  159. package/src/number/branded-types/positive-int.mts +46 -68
  160. package/src/number/branded-types/positive-int16.mts +61 -57
  161. package/src/number/branded-types/positive-int32.mts +61 -57
  162. package/src/number/branded-types/positive-safe-int.mts +62 -57
  163. package/src/number/branded-types/positive-uint16.mts +61 -57
  164. package/src/number/branded-types/positive-uint32.mts +61 -58
  165. package/src/number/branded-types/safe-int.mts +43 -62
  166. package/src/number/branded-types/safe-uint.mts +62 -57
  167. package/src/number/branded-types/uint.mts +63 -50
  168. package/src/number/branded-types/uint16.mts +60 -58
  169. package/src/number/branded-types/uint32.mts +59 -55
  170. package/src/number/enum/int8.mts +56 -65
  171. package/src/number/enum/uint8.mts +60 -58
@@ -37,91 +37,98 @@ const isNonPositiveFiniteNumber = is;
37
37
  const asNonPositiveFiniteNumber = castType;
38
38
  const NonPositiveFiniteNumber = {
39
39
  /**
40
- * Type guard to check if a value is a NonPositiveFiniteNumber.
40
+ * Type guard that checks if a value is a non-positive finite number.
41
41
  *
42
- * @param value The value to check.
43
- * @returns `true` if the value is a non-positive finite number, `false`
44
- * otherwise.
42
+ * @param value - The value to check
43
+ * @returns `true` if the value is a non-positive finite number, `false` otherwise
44
+ * @see {@link isNonPositiveFiniteNumber} for usage examples
45
45
  */
46
46
  is,
47
47
  /**
48
- * The maximum value for a non-positive finite number.
49
- *
50
- * @readonly
48
+ * The largest value representable as `NonPositiveFiniteNumber`.
51
49
  */
52
50
  MAX_VALUE,
53
51
  /**
54
- * Returns the smaller of two NonPositiveFiniteNumber values.
52
+ * Returns the smallest of the given non-positive finite numbers.
55
53
  *
56
- * @param a The first NonPositiveFiniteNumber.
57
- * @param b The second NonPositiveFiniteNumber.
58
- * @returns The minimum value as a NonPositiveFiniteNumber.
54
+ * @param values - The non-positive finite numbers to compare (at least one required)
55
+ * @returns The smallest value as a `NonPositiveFiniteNumber`
59
56
  */
60
57
  min: min_,
61
58
  /**
62
- * Returns the larger of two NonPositiveFiniteNumber values.
59
+ * Returns the largest of the given non-positive finite numbers.
63
60
  *
64
- * @param a The first NonPositiveFiniteNumber.
65
- * @param b The second NonPositiveFiniteNumber.
66
- * @returns The maximum value as a NonPositiveFiniteNumber.
61
+ * @param values - The non-positive finite numbers to compare (at least one required)
62
+ * @returns The largest value as a `NonPositiveFiniteNumber`
67
63
  */
68
64
  max: max_,
69
65
  /**
70
- * Clamps a number to the non-positive finite range.
66
+ * Clamps a `number` into the `NonPositiveFiniteNumber` range `[MIN_VALUE,
67
+ * MAX_VALUE]`.
71
68
  *
72
- * @param value The number to clamp.
73
- * @returns The value clamped to (-∞, 0] as a NonPositiveFiniteNumber.
69
+ * @param value - The value to clamp
70
+ * @returns The clamped value as a `NonPositiveFiniteNumber`
74
71
  */
75
72
  clamp,
76
73
  /**
77
- * Rounds down a NonPositiveFiniteNumber to the nearest integer.
74
+ * Returns the greatest integer less than or equal to a non-positive finite
75
+ * number.
78
76
  *
79
- * @param x The NonPositiveFiniteNumber to round down.
80
- * @returns The floor value as a NonPositiveInt (can be 0).
77
+ * @param a - The non-positive finite number value
78
+ * @returns The floored value as an integer
81
79
  */
82
80
  floor,
83
81
  /**
84
- * Rounds up a NonPositiveFiniteNumber to the nearest integer.
82
+ * Returns the smallest integer greater than or equal to a non-positive finite
83
+ * number.
85
84
  *
86
- * @param x The NonPositiveFiniteNumber to round up.
87
- * @returns The ceiling value as a NegativeInt (always <= -1) or 0.
85
+ * @param a - The non-positive finite number value
86
+ * @returns The ceiled value as an integer
88
87
  */
89
88
  ceil,
90
89
  /**
91
- * Rounds a NonPositiveFiniteNumber to the nearest integer.
90
+ * Returns the value of a non-positive finite number rounded to the nearest
91
+ * integer.
92
92
  *
93
- * @param x The NonPositiveFiniteNumber to round.
94
- * @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).
93
+ * @param a - The non-positive finite number value
94
+ * @returns The rounded value as an integer
95
95
  */
96
96
  round,
97
97
  /**
98
- * Generates a random NonPositiveFiniteNumber value.
98
+ * Generates a random `NonPositiveFiniteNumber` within the given range.
99
+ *
100
+ * The range is inclusive on both ends.
99
101
  *
100
- * @returns A random non-positive finite number.
102
+ * @param min - The minimum value (inclusive)
103
+ * @param max - The maximum value (inclusive)
104
+ * @returns A random `NonPositiveFiniteNumber` in `[min, max]`
101
105
  */
102
106
  random,
103
107
  /**
104
- * Raises a NonPositiveFiniteNumber to the power of another NonPositiveFiniteNumber.
108
+ * Raises `a` to the power `b`, returning `a ** b` as a
109
+ * `NonPositiveFiniteNumber`.
105
110
  *
106
- * @param a The base NonPositiveFiniteNumber.
107
- * @param b The exponent NonPositiveFiniteNumber.
108
- * @returns `a ** b` clamped to (-∞, 0] as a NonPositiveFiniteNumber.
111
+ * @param a - The base non-positive finite number
112
+ * @param b - The exponent non-positive finite number
113
+ * @returns `a ** b` as a `NonPositiveFiniteNumber`
109
114
  */
110
115
  pow,
111
116
  /**
112
- * Adds two NonPositiveFiniteNumber values.
117
+ * Adds two non-positive finite numbers, returning `a + b` as a
118
+ * `NonPositiveFiniteNumber`.
113
119
  *
114
- * @param a The first NonPositiveFiniteNumber.
115
- * @param b The second NonPositiveFiniteNumber.
116
- * @returns `a + b` clamped to (-∞, 0] as a NonPositiveFiniteNumber.
120
+ * @param a - The first non-positive finite number
121
+ * @param b - The second non-positive finite number
122
+ * @returns The sum of `a` and `b` as a `NonPositiveFiniteNumber`
117
123
  */
118
124
  add,
119
125
  /**
120
- * Subtracts one NonPositiveFiniteNumber from another.
126
+ * Subtracts two non-positive finite numbers, returning `a - b` as a
127
+ * `NonPositiveFiniteNumber`.
121
128
  *
122
- * @param a The minuend NonPositiveFiniteNumber.
123
- * @param b The subtrahend NonPositiveFiniteNumber.
124
- * @returns `a - b` clamped to (-∞, 0] as a NonPositiveFiniteNumber (maximum 0).
129
+ * @param a - The first non-positive finite number
130
+ * @param b - The second non-positive finite number
131
+ * @returns The difference of `a` and `b` as a `NonPositiveFiniteNumber`
125
132
  */
126
133
  sub
127
134
  };
@@ -1 +1 @@
1
- {"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n 0\n>({\n MIN_VALUE: Number.MAX_VALUE * -1,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n * Checks if a number is a NonPositiveFiniteNumber (a finite number <= 0).\n *\n * @param value The value to check.\n * @returns `true` if the value is a NonPositiveFiniteNumber, `false` otherwise.\n */\nexport const isNonPositiveFiniteNumber = is;\n\n/**\n * Casts a number to a NonPositiveFiniteNumber type.\n *\n * @param value The value to cast.\n * @returns The value as a NonPositiveFiniteNumber type.\n * @throws {TypeError} If the value is not a non-positive finite number.\n */\nexport const asNonPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe arithmetic operations for non-positive finite\n * numbers.\n *\n * All operations maintain the non-positive constraint by clamping positive\n * results to MAX_VALUE (0), while ensuring results remain finite (excluding NaN\n * and Infinity). This type is useful for representing quantities that must\n * always be non-positive, such as debts, penalties, and negative offsets.\n */\nexport const NonPositiveFiniteNumber = {\n /**\n * Type guard to check if a value is a NonPositiveFiniteNumber.\n *\n * @param value The value to check.\n * @returns `true` if the value is a non-positive finite number, `false`\n * otherwise.\n */\n is,\n\n /**\n * The maximum value for a non-positive finite number.\n *\n * @readonly\n */\n MAX_VALUE,\n\n /**\n * Returns the smaller of two NonPositiveFiniteNumber values.\n *\n * @param a The first NonPositiveFiniteNumber.\n * @param b The second NonPositiveFiniteNumber.\n * @returns The minimum value as a NonPositiveFiniteNumber.\n */\n min: min_,\n\n /**\n * Returns the larger of two NonPositiveFiniteNumber values.\n *\n * @param a The first NonPositiveFiniteNumber.\n * @param b The second NonPositiveFiniteNumber.\n * @returns The maximum value as a NonPositiveFiniteNumber.\n */\n max: max_,\n\n /**\n * Clamps a number to the non-positive finite range.\n *\n * @param value The number to clamp.\n * @returns The value clamped to (-∞, 0] as a NonPositiveFiniteNumber.\n */\n clamp,\n\n /**\n * Rounds down a NonPositiveFiniteNumber to the nearest integer.\n *\n * @param x The NonPositiveFiniteNumber to round down.\n * @returns The floor value as a NonPositiveInt (can be 0).\n */\n floor,\n\n /**\n * Rounds up a NonPositiveFiniteNumber to the nearest integer.\n *\n * @param x The NonPositiveFiniteNumber to round up.\n * @returns The ceiling value as a NegativeInt (always <= -1) or 0.\n */\n ceil,\n\n /**\n * Rounds a NonPositiveFiniteNumber to the nearest integer.\n *\n * @param x The NonPositiveFiniteNumber to round.\n * @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).\n */\n round,\n\n /**\n * Generates a random NonPositiveFiniteNumber value.\n *\n * @returns A random non-positive finite number.\n */\n random,\n\n /**\n * Raises a NonPositiveFiniteNumber to the power of another NonPositiveFiniteNumber.\n *\n * @param a The base NonPositiveFiniteNumber.\n * @param b The exponent NonPositiveFiniteNumber.\n * @returns `a ** b` clamped to (-∞, 0] as a NonPositiveFiniteNumber.\n */\n pow,\n\n /**\n * Adds two NonPositiveFiniteNumber values.\n *\n * @param a The first NonPositiveFiniteNumber.\n * @param b The second NonPositiveFiniteNumber.\n * @returns `a + b` clamped to (-∞, 0] as a NonPositiveFiniteNumber.\n */\n add,\n\n /**\n * Subtracts one NonPositiveFiniteNumber from another.\n *\n * @param a The minuend NonPositiveFiniteNumber.\n * @param b The subtrahend NonPositiveFiniteNumber.\n * @returns `a - b` clamped to (-∞, 0] as a NonPositiveFiniteNumber (maximum 0).\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,8BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,OAAO,SAAA,GAAY,EAAA;AAAA,EAC9B,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAIb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAUK,MAAM,yBAAA,GAA4B;AASlC,MAAM,yBAAA,GAA4B;AAWlC,MAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrC,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA;AACF;;;;"}
1
+ {"version":3,"file":"non-positive-finite-number.mjs","sources":["../../../src/number/branded-types/non-positive-finite-number.mts"],"sourcesContent":["import { type NonPositiveFiniteNumber as TtfImported_NonPositiveFiniteNumber } from 'ts-type-forge';\nimport { TsDataForgeInternals } from '../refined-number-utils.mjs';\n\nexport type NonPositiveFiniteNumber = TtfImported_NonPositiveFiniteNumber;\n\ntype ElementType = NonPositiveFiniteNumber;\n\nconst typeNameInMessage = 'a non-positive finite number';\n\nconst {\n MAX_VALUE,\n add,\n castType,\n clamp,\n is,\n max: max_,\n min: min_,\n pow,\n random,\n sub,\n} = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat<\n ElementType,\n number,\n 0\n>({\n MIN_VALUE: Number.MAX_VALUE * -1,\n MAX_VALUE: 0,\n typeNameInMessage,\n} as const);\n\nconst floor = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.floor(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst ceil = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.ceil(x) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\nconst round = (\n x: ElementType,\n): TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Math.round(\n x,\n ) as TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<\n TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>\n >;\n\n/**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * Returns `true` only for a finite value — never `NaN`, `Infinity`, or\n * `-Infinity`.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n */\nexport const isNonPositiveFiniteNumber = is;\n\n/**\n * Casts a `number` to the `NonPositiveFiniteNumber` branded type.\n *\n * Validates that the value is a non-positive finite number and returns it with\n * the `NonPositiveFiniteNumber` brand. Throws a `TypeError` otherwise.\n *\n * @param value - The value to cast\n * @returns The value as a `NonPositiveFiniteNumber`\n * @throws {TypeError} If the value is not a non-positive finite number\n */\nexport const asNonPositiveFiniteNumber = castType;\n\n/**\n * Namespace providing type-safe operations for the `NonPositiveFiniteNumber`\n * branded type.\n *\n * The `NonPositiveFiniteNumber` type represents a non-positive finite number.\n */\nexport const NonPositiveFiniteNumber = {\n /**\n * Type guard that checks if a value is a non-positive finite number.\n *\n * @param value - The value to check\n * @returns `true` if the value is a non-positive finite number, `false` otherwise\n * @see {@link isNonPositiveFiniteNumber} for usage examples\n */\n is,\n\n /**\n * The largest value representable as `NonPositiveFiniteNumber`.\n */\n MAX_VALUE,\n\n /**\n * Returns the smallest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The smallest value as a `NonPositiveFiniteNumber`\n */\n min: min_,\n\n /**\n * Returns the largest of the given non-positive finite numbers.\n *\n * @param values - The non-positive finite numbers to compare (at least one required)\n * @returns The largest value as a `NonPositiveFiniteNumber`\n */\n max: max_,\n\n /**\n * Clamps a `number` into the `NonPositiveFiniteNumber` range `[MIN_VALUE,\n * MAX_VALUE]`.\n *\n * @param value - The value to clamp\n * @returns The clamped value as a `NonPositiveFiniteNumber`\n */\n clamp,\n\n /**\n * Returns the greatest integer less than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The floored value as an integer\n */\n floor,\n\n /**\n * Returns the smallest integer greater than or equal to a non-positive finite\n * number.\n *\n * @param a - The non-positive finite number value\n * @returns The ceiled value as an integer\n */\n ceil,\n\n /**\n * Returns the value of a non-positive finite number rounded to the nearest\n * integer.\n *\n * @param a - The non-positive finite number value\n * @returns The rounded value as an integer\n */\n round,\n\n /**\n * Generates a random `NonPositiveFiniteNumber` within the given range.\n *\n * The range is inclusive on both ends.\n *\n * @param min - The minimum value (inclusive)\n * @param max - The maximum value (inclusive)\n * @returns A random `NonPositiveFiniteNumber` in `[min, max]`\n */\n random,\n\n /**\n * Raises `a` to the power `b`, returning `a ** b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The base non-positive finite number\n * @param b - The exponent non-positive finite number\n * @returns `a ** b` as a `NonPositiveFiniteNumber`\n */\n pow,\n\n /**\n * Adds two non-positive finite numbers, returning `a + b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The sum of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n add,\n\n /**\n * Subtracts two non-positive finite numbers, returning `a - b` as a\n * `NonPositiveFiniteNumber`.\n *\n * @param a - The first non-positive finite number\n * @param b - The second non-positive finite number\n * @returns The difference of `a` and `b` as a `NonPositiveFiniteNumber`\n */\n sub,\n} as const;\n"],"names":[],"mappings":";;AAOA,MAAM,iBAAA,GAAoB,8BAAA;AAE1B,MAAM;AAAA,EACJ,SAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,EAAA;AAAA,EACA,GAAA,EAAK,IAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,GAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,GAAI,oBAAA,CAAqB,mBAAmB,iBAAA,CAI1C;AAAA,EACA,SAAA,EAAW,OAAO,SAAA,GAAY,EAAA;AAAA,EAC9B,SAAA,EAAW,CAAA;AAAA,EACX;AACF,CAAU,CAAA;AAEV,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAIF,MAAM,OAAO,CACX,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAK,CAAC;AAAA,CAAA;AAIb,MAAM,QAAQ,CACZ,CAAA;AAAA;AAAA,EAKA,IAAA,CAAK,KAAA;AAAA,IACH;AAAA;AACF,CAAA;AAaK,MAAM,yBAAA,GAA4B;AAYlC,MAAM,yBAAA,GAA4B;AAQlC,MAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrC,EAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQL,GAAA,EAAK,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASL,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AACF;;;;"}
@@ -3,43 +3,22 @@ export type NonPositiveInt = TtfImported_NonPositiveInt;
3
3
  /**
4
4
  * Type guard that checks if a value is a non-positive integer.
5
5
  *
6
- * A non-positive integer is any integer less than or equal to zero (<= 0).
7
- * This includes zero and all negative integers, but excludes positive numbers
8
- * and non-integers.
9
- *
10
- * @example
11
- *
12
- * ```ts
13
- * assert.isTrue(isNonPositiveInt(0));
14
- *
15
- * assert.isTrue(isNonPositiveInt(-5));
16
- *
17
- * assert.isFalse(isNonPositiveInt(1));
18
- * ```
6
+ * Returns `true` for a non-positive integer — a value with no fractional
7
+ * component, including values outside the safe integer range (unlike
8
+ * `SafeInt`).
19
9
  *
20
10
  * @param value - The value to check
21
11
  * @returns `true` if the value is a non-positive integer, `false` otherwise
22
12
  */
23
13
  export declare const isNonPositiveInt: (a: number) => a is TtfImported_NonPositiveInt;
24
14
  /**
25
- * Casts a number to a NonPositiveInt branded type.
26
- *
27
- * This function validates that the input is a non-positive integer (<= 0) and
28
- * returns it with the NonPositiveInt brand. This ensures type safety for
29
- * operations that require non-positive integer values.
30
- *
31
- * @example
15
+ * Casts a `number` to the `NonPositiveInt` branded type.
32
16
  *
33
- * ```ts
34
- * const branded = asNonPositiveInt(-7);
35
- *
36
- * assert.isTrue(branded === -7);
37
- *
38
- * assert.isTrue(NonPositiveInt.is(branded));
39
- * ```
17
+ * Validates that the value is a non-positive integer and returns it with the
18
+ * `NonPositiveInt` brand. Throws a `TypeError` otherwise.
40
19
  *
41
20
  * @param value - The value to cast
42
- * @returns The value as a NonPositiveInt branded type
21
+ * @returns The value as a `NonPositiveInt`
43
22
  * @throws {TypeError} If the value is not a non-positive integer
44
23
  */
45
24
  export declare const asNonPositiveInt: <N extends number>(x: N) => number & {
@@ -55,169 +34,85 @@ export declare const asNonPositiveInt: <N extends number>(x: N) => number & {
55
34
  'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
56
35
  }> & N;
57
36
  /**
58
- * Namespace providing type-safe operations for NonPositiveInt branded types.
59
- *
60
- * NonPositiveInt represents integers that are less than or equal to zero (<= 0).
61
- * All operations automatically clamp results to maintain the non-positive
62
- * constraint, ensuring that arithmetic operations never produce positive values.
37
+ * Namespace providing type-safe operations for the `NonPositiveInt` branded
38
+ * type.
63
39
  *
64
- * This type is essential for:
40
+ * The `NonPositiveInt` type represents a non-positive integer. Division (`div`)
41
+ * uses floor division.
65
42
  *
66
- * - Debts and negative balances
67
- * - Penalties and reductions
68
- * - Offsets and adjustments (downward)
69
- * - Negative counts or differences
70
- * - Depth or altitude below a reference point
43
+ * Unlike `SafeInt`, `NonPositiveInt` allows values outside the safe integer
44
+ * range (±2^53 − 1), so very large magnitudes may lose precision in
45
+ * JavaScript's `number` type.
71
46
  */
72
47
  export declare const NonPositiveInt: {
73
48
  /**
74
49
  * Type guard that checks if a value is a non-positive integer.
75
50
  *
76
- * @example
77
- *
78
- * ```ts
79
- * const value: number = -42;
80
- *
81
- * if (NonPositiveInt.is(value)) {
82
- * // value is now typed as NonPositiveInt
83
- * const debt = value;
84
- * }
85
- * ```
86
- *
87
51
  * @param value - The value to check
88
52
  * @returns `true` if the value is a non-positive integer, `false` otherwise
53
+ * @see {@link isNonPositiveInt} for usage examples
89
54
  */
90
55
  readonly is: (a: number) => a is TtfImported_NonPositiveInt;
91
56
  /**
92
- * The maximum value for a non-positive integer.
93
- *
94
- * @readonly
57
+ * The largest value representable as `NonPositiveInt`.
95
58
  */
96
59
  readonly MAX_VALUE: 0;
97
60
  /**
98
- * Returns the smaller of two non-positive integers.
99
- *
100
- * Since non-positive integers range from negative infinity to 0, the smaller
101
- * value is the one further from zero (more negative).
102
- *
103
- * @example
61
+ * Returns the smallest of the given non-positive integers.
104
62
  *
105
- * ```ts
106
- * const result = NonPositiveInt.min(-5, -10);
107
- *
108
- * assert.strictEqual(result, -10);
109
- * ```
110
- *
111
- * @param a - The first non-positive integer
112
- * @param b - The second non-positive integer
113
- * @returns The minimum value as a non-positive integer
63
+ * @param values - The non-positive integers to compare (at least one required)
64
+ * @returns The smallest value as a `NonPositiveInt`
114
65
  */
115
66
  readonly min: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>[]) => TtfImported_NonPositiveInt;
116
67
  /**
117
- * Returns the larger of two non-positive integers.
118
- *
119
- * Since non-positive integers range from negative infinity to 0, the larger
120
- * value is the one closer to zero (less negative).
121
- *
122
- * @example
123
- *
124
- * ```ts
125
- * const result = NonPositiveInt.max(-5, -10);
126
- *
127
- * assert.strictEqual(result, -5);
128
- * ```
68
+ * Returns the largest of the given non-positive integers.
129
69
  *
130
- * @param a - The first non-positive integer
131
- * @param b - The second non-positive integer
132
- * @returns The maximum value as a non-positive integer
70
+ * @param values - The non-positive integers to compare (at least one required)
71
+ * @returns The largest value as a `NonPositiveInt`
133
72
  */
134
73
  readonly max: (...values: readonly import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>[]) => TtfImported_NonPositiveInt;
135
74
  /**
136
- * Clamps a number to the non-positive integer range.
137
- *
138
- * Any positive value is clamped to 0 (the maximum non-positive integer).
139
- * Negative values are preserved as long as they are valid integers.
140
- *
141
- * @example
142
- *
143
- * ```ts
144
- * assert.strictEqual(NonPositiveInt.clamp(5), 0);
145
- *
146
- * assert.strictEqual(NonPositiveInt.clamp(-5), -5);
75
+ * Clamps a `number` into the `NonPositiveInt` range, rounding to the nearest
76
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
147
77
  *
148
- * assert.strictEqual(NonPositiveInt.clamp(0), 0);
149
- * ```
150
- *
151
- * @param value - The number to clamp
152
- * @returns The value clamped to the non-positive integer range
78
+ * @param value - The value to clamp
79
+ * @returns The clamped value as a `NonPositiveInt`
153
80
  */
154
81
  readonly clamp: (x: number) => TtfImported_NonPositiveInt;
155
82
  /**
156
- * Generates a random non-positive integer value.
157
- *
158
- * @example
159
- *
160
- * ```ts
161
- * const randomValue = NonPositiveInt.random();
83
+ * Generates a random `NonPositiveInt` within the given range.
162
84
  *
163
- * assert.isTrue(NonPositiveInt.is(randomValue));
164
- * ```
85
+ * The range is inclusive on both ends.
165
86
  *
166
- * @returns A random non-positive integer
87
+ * @param min - The minimum value (inclusive)
88
+ * @param max - The maximum value (inclusive)
89
+ * @returns A random `NonPositiveInt` in `[min, max]`
167
90
  */
168
91
  readonly random: (min?: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt> | undefined, max?: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt> | undefined) => TtfImported_NonPositiveInt;
169
92
  /**
170
- * Raises a non-positive integer to the power of another non-positive integer.
171
- *
172
- * The result is clamped to the non-positive integer range.
173
- *
174
- * @example
175
- *
176
- * ```ts
177
- * const result = NonPositiveInt.pow(-2, -1);
178
- * ```
93
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveInt`
94
+ * (floored to an integer).
179
95
  *
180
96
  * @param a - The base non-positive integer
181
97
  * @param b - The exponent non-positive integer
182
- * @returns `a ** b` clamped to the non-positive integer range
98
+ * @returns `a ** b` as a `NonPositiveInt`
183
99
  */
184
100
  readonly pow: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
185
101
  /**
186
- * Adds two non-positive integers.
187
- *
188
- * The result is clamped to the non-positive integer range. If the sum is
189
- * positive, it is clamped to 0.
190
- *
191
- * @example
192
- *
193
- * ```ts
194
- * assert.strictEqual(NonPositiveInt.add(-5, -3), -8);
195
- *
196
- * assert.strictEqual(NonPositiveInt.add(-5, 10), 0);
197
- * ```
102
+ * Adds two non-positive integers, returning `a + b` as a `NonPositiveInt`.
198
103
  *
199
104
  * @param a - The first non-positive integer
200
105
  * @param b - The second non-positive integer
201
- * @returns `a + b` clamped to the non-positive integer range
106
+ * @returns The sum of `a` and `b` as a `NonPositiveInt`
202
107
  */
203
108
  readonly add: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
204
109
  /**
205
- * Subtracts one non-positive integer from another.
206
- *
207
- * The result is clamped to the non-positive integer range. If the result is
208
- * positive, it is clamped to 0.
110
+ * Subtracts two non-positive integers, returning `a - b` as a
111
+ * `NonPositiveInt`.
209
112
  *
210
- * @example
211
- *
212
- * ```ts
213
- * assert.strictEqual(NonPositiveInt.sub(-10, -3), -7);
214
- *
215
- * assert.strictEqual(NonPositiveInt.sub(-10, 5), 0);
216
- * ```
217
- *
218
- * @param a - The minuend non-positive integer
219
- * @param b - The subtrahend non-positive integer
220
- * @returns `a - b` clamped to the non-positive integer range
113
+ * @param a - The first non-positive integer
114
+ * @param b - The second non-positive integer
115
+ * @returns The difference of `a` and `b` as a `NonPositiveInt`
221
116
  */
222
117
  readonly sub: (x: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>, y: import("ts-type-forge").WithSmallInt<TtfImported_NonPositiveInt>) => TtfImported_NonPositiveInt;
223
118
  };
@@ -1 +1 @@
1
- {"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;OAIG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;OAYG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;IAGH;;;;;;;;;;;;;;;;;OAiBG;;CAEK,CAAC"}
1
+ {"version":3,"file":"non-positive-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/non-positive-int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGlF,MAAM,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA4BxD;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,gDAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;MAAW,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc;IACzB;;;;;;OAMG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;OAQG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;OAOG;;CAEK,CAAC"}
@@ -24,151 +24,71 @@ const NonPositiveInt = {
24
24
  /**
25
25
  * Type guard that checks if a value is a non-positive integer.
26
26
  *
27
- * @example
28
- *
29
- * ```ts
30
- * const value: number = -42;
31
- *
32
- * if (NonPositiveInt.is(value)) {
33
- * // value is now typed as NonPositiveInt
34
- * const debt = value;
35
- * }
36
- * ```
37
- *
38
27
  * @param value - The value to check
39
28
  * @returns `true` if the value is a non-positive integer, `false` otherwise
29
+ * @see {@link isNonPositiveInt} for usage examples
40
30
  */
41
31
  is,
42
32
  /**
43
- * The maximum value for a non-positive integer.
44
- *
45
- * @readonly
33
+ * The largest value representable as `NonPositiveInt`.
46
34
  */
47
35
  MAX_VALUE,
48
36
  /**
49
- * Returns the smaller of two non-positive integers.
50
- *
51
- * Since non-positive integers range from negative infinity to 0, the smaller
52
- * value is the one further from zero (more negative).
37
+ * Returns the smallest of the given non-positive integers.
53
38
  *
54
- * @example
55
- *
56
- * ```ts
57
- * const result = NonPositiveInt.min(-5, -10);
58
- *
59
- * assert.strictEqual(result, -10);
60
- * ```
61
- *
62
- * @param a - The first non-positive integer
63
- * @param b - The second non-positive integer
64
- * @returns The minimum value as a non-positive integer
39
+ * @param values - The non-positive integers to compare (at least one required)
40
+ * @returns The smallest value as a `NonPositiveInt`
65
41
  */
66
42
  min: min_,
67
43
  /**
68
- * Returns the larger of two non-positive integers.
69
- *
70
- * Since non-positive integers range from negative infinity to 0, the larger
71
- * value is the one closer to zero (less negative).
72
- *
73
- * @example
74
- *
75
- * ```ts
76
- * const result = NonPositiveInt.max(-5, -10);
77
- *
78
- * assert.strictEqual(result, -5);
79
- * ```
44
+ * Returns the largest of the given non-positive integers.
80
45
  *
81
- * @param a - The first non-positive integer
82
- * @param b - The second non-positive integer
83
- * @returns The maximum value as a non-positive integer
46
+ * @param values - The non-positive integers to compare (at least one required)
47
+ * @returns The largest value as a `NonPositiveInt`
84
48
  */
85
49
  max: max_,
86
50
  /**
87
- * Clamps a number to the non-positive integer range.
88
- *
89
- * Any positive value is clamped to 0 (the maximum non-positive integer).
90
- * Negative values are preserved as long as they are valid integers.
91
- *
92
- * @example
51
+ * Clamps a `number` into the `NonPositiveInt` range, rounding to the nearest
52
+ * integer and constraining the result to `[MIN_VALUE, MAX_VALUE]`.
93
53
  *
94
- * ```ts
95
- * assert.strictEqual(NonPositiveInt.clamp(5), 0);
96
- *
97
- * assert.strictEqual(NonPositiveInt.clamp(-5), -5);
98
- *
99
- * assert.strictEqual(NonPositiveInt.clamp(0), 0);
100
- * ```
101
- *
102
- * @param value - The number to clamp
103
- * @returns The value clamped to the non-positive integer range
54
+ * @param value - The value to clamp
55
+ * @returns The clamped value as a `NonPositiveInt`
104
56
  */
105
57
  clamp,
106
58
  /**
107
- * Generates a random non-positive integer value.
108
- *
109
- * @example
110
- *
111
- * ```ts
112
- * const randomValue = NonPositiveInt.random();
59
+ * Generates a random `NonPositiveInt` within the given range.
113
60
  *
114
- * assert.isTrue(NonPositiveInt.is(randomValue));
115
- * ```
61
+ * The range is inclusive on both ends.
116
62
  *
117
- * @returns A random non-positive integer
63
+ * @param min - The minimum value (inclusive)
64
+ * @param max - The maximum value (inclusive)
65
+ * @returns A random `NonPositiveInt` in `[min, max]`
118
66
  */
119
67
  random,
120
68
  /**
121
- * Raises a non-positive integer to the power of another non-positive integer.
122
- *
123
- * The result is clamped to the non-positive integer range.
124
- *
125
- * @example
126
- *
127
- * ```ts
128
- * const result = NonPositiveInt.pow(-2, -1);
129
- * ```
69
+ * Raises `a` to the power `b`, returning `a ** b` as a `NonPositiveInt`
70
+ * (floored to an integer).
130
71
  *
131
72
  * @param a - The base non-positive integer
132
73
  * @param b - The exponent non-positive integer
133
- * @returns `a ** b` clamped to the non-positive integer range
74
+ * @returns `a ** b` as a `NonPositiveInt`
134
75
  */
135
76
  pow,
136
77
  /**
137
- * Adds two non-positive integers.
138
- *
139
- * The result is clamped to the non-positive integer range. If the sum is
140
- * positive, it is clamped to 0.
141
- *
142
- * @example
143
- *
144
- * ```ts
145
- * assert.strictEqual(NonPositiveInt.add(-5, -3), -8);
146
- *
147
- * assert.strictEqual(NonPositiveInt.add(-5, 10), 0);
148
- * ```
78
+ * Adds two non-positive integers, returning `a + b` as a `NonPositiveInt`.
149
79
  *
150
80
  * @param a - The first non-positive integer
151
81
  * @param b - The second non-positive integer
152
- * @returns `a + b` clamped to the non-positive integer range
82
+ * @returns The sum of `a` and `b` as a `NonPositiveInt`
153
83
  */
154
84
  add,
155
85
  /**
156
- * Subtracts one non-positive integer from another.
157
- *
158
- * The result is clamped to the non-positive integer range. If the result is
159
- * positive, it is clamped to 0.
160
- *
161
- * @example
86
+ * Subtracts two non-positive integers, returning `a - b` as a
87
+ * `NonPositiveInt`.
162
88
  *
163
- * ```ts
164
- * assert.strictEqual(NonPositiveInt.sub(-10, -3), -7);
165
- *
166
- * assert.strictEqual(NonPositiveInt.sub(-10, 5), 0);
167
- * ```
168
- *
169
- * @param a - The minuend non-positive integer
170
- * @param b - The subtrahend non-positive integer
171
- * @returns `a - b` clamped to the non-positive integer range
89
+ * @param a - The first non-positive integer
90
+ * @param b - The second non-positive integer
91
+ * @returns The difference of `a` and `b` as a `NonPositiveInt`
172
92
  */
173
93
  sub
174
94
  };