Unitformat-js is a project mainly written in JavaScript, based on the View license.
Unit formatter for JavaScript
JavaScript unit formatter. Has methods for formatting: bits, bytes, microseconds, miliseconds.
unitformat.bits(10000) => 10 Kbit (Kilobits) unitformat.bytes(10000) => 10 KB (Kilobytes) unitformat.microseconds(10000) => 10 ms (miliseconds) unitformat.miliseconds(10000) => 10 s (seconds)
value = the value to be formatted.
si = flag for enabling the SI notation for bits / bytes. On by default. If SI is on, the order of magnitude has the powers of 10, otherwise, the powers of 2.
long_unit = flag for enabling the printing of long units names. Off by default.
decimals = the number of decimals to print for the converted and formatted value.