Skip to content

Number Helpers

Utility functions for working with number operations.

FunctionDescription
ceil / floornative JS Math.ceil() / Math.floor() (ES1)
clampClamps a number between min and max values
formatSizeFormat a byte count into a human-readable string with the appropriate unit.
min / maxnative JS Math.min(...arr) / Math.max(...arr) (ES1)
randomBetweenGenerates a random number between min and max (inclusive)
randomIntBetweenGenerates a random integer between min and max (inclusive)
roundToRounds a number to specified decimal places
sumCalculates the sum of an array of numbers.
toInt / toFloatnative JS parseInt(str, 10) / parseFloat(str) (ES1)