formatFileSize

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.format

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

  1. size*-Number|String

    The size to transform in bytes

  2. settings{}Object

    The “filesize” settings to customize the output. See [filesize](https://www.npmjs.com/package/filesize) settings

Return

  1. -String

    The human readable version of the passed size

Example

import { formatFilesize } from '@blackbyte/sugar/format';
formatFilesize(163931); // => 326.86 KB

Settings

  1. base10Number

    (number) Number base, default is 10

  2. bitsfalseBoolean

    (boolean) Enables bit sizes, default is false

  3. exponent0Number

    (number) Specifies the SI suffix via exponent, e.g. 2 is MB for bytes, default is 0

  4. fullformfalseBoolean

    (boolean) Enables full form of unit of measure, default is false

  5. [fullforms]*-Array

    (array) Array of full form overrides, default is []

  6. localefalseBoolean|String

    (boolean|string) Localize the output, default is false

  7. padfalseBoolean

    (boolean) Should the output be padded to the left, default is false

  8. precision2Number

    (number) The precision to use when outputting decimal values, default is 2

  9. round2Number

    (number) The rounding function, default is 2

  10. separator’.‘String

    (string) Separator of thousands, default is ’.‘

  11. spacer’ ‘String

    (string) Spacer of the output, default is ’ ‘

Todo

  • testsnormal