API reference › @evolu/common › Number
Number arithmetic, comparison, and branded numeric types.
Functions
| Function | Description |
|---|---|
| clamp | Clamps a number within a given range. |
| computeBalancedBuckets | Divides items into buckets as evenly as possible, ensuring each bucket has at least the minimum number of items. Returns a success result if the minimum is met, or an error result with the required number of items if not. |
| decrement | - |
| fibonacciAt | Returns the Fibonacci number at the given index (1-indexed: 1,1,2,3,5,8,...). |
| increment | - |
| isBetween | Creates a predicate that checks if a number is within a range, inclusive. |
| max | Returns the maximum value, preserving branded type if applicable. |
| min | Returns the minimum value, preserving branded type if applicable. |
| percentageToRatio | Converts a Percentage to its numeric Ratio. |
Type Aliases
| Type Alias | Description |
|---|---|
| FibonacciIndex | Valid index for fibonacciAt, constrained to 1-78. |
| Int0To100OrNonNegativeInt | Integer literal from 0 to 100 or NonNegativeInt. |
| Int1To100 | Integer literal from 1 to 100. |
| Int1To100OrPositiveInt | Int1To100 or PositiveInt. |
| Int1To99 | Integer literal from 1 to 99. |
| Percentage | PercentageLiteral or Ratio. |
| PercentageLiteral | Percentage literal from "0%" to "100%". |
Variables
| Variable | Description |
|---|---|
| FibonacciIndex | Valid index for fibonacciAt, constrained to 1-78. |
| PercentageLiteral | Percentage literal from "0%" to "100%". |