JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2191812
  • Score
    100M100P100Q202739F
  • License MIT

Convert a bytes value to a more human-readable format. Choose between metric or IEC units.

Package Exports

  • byte-size

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (byte-size) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

view on npm npm module downloads per month Build Status Dependency Status js-standard-style

byte-size

Convert a bytes value to a more human-readable format. Choose between metric or IEC units, summarised below.

Value Metric
1000 kB kilobyte
1000^2 MB megabyte
1000^3 GB gigabyte
1000^4 TB terabyte
1000^5 PB petabyte
1000^6 EB exabyte
1000^7 ZB zettabyte
1000^8 YB yottabyte
Value IEC
1024 KiB kibibyte
1024^2 MiB mebibyte
1024^3 GiB gibibyte
1024^4 TiB tebibyte
1024^5 PiB pebibyte
1024^6 EiB exbibyte
1024^7 ZiB zebibyte
1024^8 YiB yobibyte

byteSize(bytes, [options]) ⇒ string

Kind: Exported function

Param Type Default Description
bytes number the bytes value to convert
[options] object optional config
[options.precision] number 1 number of decimal places
[options.units] string "metric" select "metric" or "iec" units

Example

> var byteSize = require("byte-size")

> byteSize(1580)
'1.6 kB'

> byteSize(1580, { units: 'iec' })
'1.5 KiB'

> byteSize(1580, { units: 'iec', precision: 3 })
'1.543 KiB'

> byteSize(1580, { units: 'iec', precision: 0 })
'2 KiB'

© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.