API reference@evolu/common › Number

Number arithmetic, comparison, and branded numeric types.

Functions

FunctionDescription
clampClamps a number within a given range.
computeBalancedBucketsDivides 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-
fibonacciAtReturns the Fibonacci number at the given index (1-indexed: 1,1,2,3,5,8,...).
increment-
isBetweenCreates a predicate that checks if a number is within a range, inclusive.
maxReturns the maximum value, preserving branded type if applicable.
minReturns the minimum value, preserving branded type if applicable.
percentageToRatioConverts a Percentage to its numeric Ratio.

Type Aliases

Type AliasDescription
FibonacciIndexValid index for fibonacciAt, constrained to 1-78.
Int0To100OrNonNegativeIntInteger literal from 0 to 100 or NonNegativeInt.
Int1To100Integer literal from 1 to 100.
Int1To100OrPositiveIntInt1To100 or PositiveInt.
Int1To99Integer literal from 1 to 99.
PercentagePercentageLiteral or Ratio.
PercentageLiteralPercentage literal from "0%" to "100%".

Variables

VariableDescription
FibonacciIndexValid index for fibonacciAt, constrained to 1-78.
PercentageLiteralPercentage literal from "0%" to "100%".