formatFileSize
Transform into human readable string a file size from a number (float or integer) or string. This function use the wonderfull “filesize” npm package under the houd.
Params
- size*-Number|String
The size to transform in bytes
- settings{}Object
The “filesize” settings to customize the output. See [filesize](https://www.npmjs.com/package/filesize) settings
Return
- -String
The human readable version of the passed size
Example
import { formatFilesize } from '@blackbyte/sugar/format';
formatFilesize(163931); // => 326.86 KBSettings
- base10Number
(number) Number base, default is 10
- bitsfalseBoolean
(boolean) Enables
bitsizes, default is false - exponent0Number
(number) Specifies the SI suffix via exponent, e.g. 2 is MB for bytes, default is 0
- fullformfalseBoolean
(boolean) Enables full form of unit of measure, default is false
- [fullforms]*-Array
(array) Array of full form overrides, default is []
- localefalseBoolean|String
(boolean|string) Localize the output, default is false
- padfalseBoolean
(boolean) Should the output be padded to the left, default is false
- precision2Number
(number) The precision to use when outputting decimal values, default is 2
- round2Number
(number) The rounding function, default is 2
- separator’.‘String
(string) Separator of thousands, default is ’.‘
- spacer’ ‘String
(string) Spacer of the output, default is ’ ‘
Todo
- testsnormal