Module sizes

Some utility functions for formatting of data sizes i.e.

file sizes.

Functions

format (size[, base=1024[, ssuffix=""]]) Format a size with the given base.
format10 (size) Format a size in base 10.


Functions

format (size[, base=1024[, ssuffix=""]])
Format a size with the given base. This function returns a string with the last character set accordingly. For example, sizes.format(2048) returns "2K". base defaults to 1024. The resulting size is always rounded to the nearest whole number.

Parameters:

  • size number The size to format
  • base number What to divide size by if it is larger than base (default 1024)
  • ssuffix string A suffix to concatenate if size >= base (default "")

Returns:

    string The formatted size
format10 (size)
Format a size in base 10. Equivalent to sizes.format(size, 1000, "i"). format10(4096) returns 4Ki.

Parameters:

  • size number The size to format

Returns:

    string The formatted size
generated by LDoc 1.4.6 Last updated 2023-03-04 11:42:14