Created
November 26, 2019 12:41
-
-
Save mholtzhausen/0c7b3641cbc7e007613989be5959cbf1 to your computer and use it in GitHub Desktop.
Bytes represented in human readable form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (bytes, siUnits = false, m, l, d, e) => (m = Math, l = m.log, d = siUnits ? 1024 : 1e3, e = l(bytes) / l(d) | 0, `${bytes / m.pow(d, e).toFixed(2)} ${e ? `${'KMGTPEZY'[--e]}${siUnits ? 'iB' : 'B'}` : 'Bytes'}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment