Module

units

This file contains some functionalities related to units and their conversions.

View Source utils/units.js, line 1

Members

# static BYTE_SIZES

Array of units of digital information.

View Source utils/units.js, line 12

Methods

# static bytesToByteBaseSize(bytes, decopt, ordopt) → {string}

Get the best readable representation of a number of bytes.

Parameters:
Name Type Attributes Default Description
bytes number

Number of bytes.

dec number <optional>
2

Number of decimal positions.

ord number <optional>
null

Order of the unit.

View Source utils/units.js, line 21

  • A string representation.
string

# static getByteBaseOrder(bytes) → {number}

Return the index of the unit based on bytes.

Parameters:
Name Type Description
bytes number

Number of bytes.

View Source utils/units.js, line 47

  • A string representation.
number

# static getByteBaseSize(bytes, unit, dec) → {number}

Get the bytes in the unit specified.

Parameters:
Name Type Description
bytes number

Number of bytes.

unit string

The unit to change: B, KB, MB, GB, TB, PB, EB, ZB or YB.

dec number

Number of decimal positions.

View Source utils/units.js, line 37

  • A string representation.
number

# static roundWithDecimals(num, dec) → {number}

Round with decimals.

Parameters:
Name Type Description
num number

Number for round.

dec number

Number of decimal positions.

View Source utils/units.js, line 57

  • Rounded value.
number

# static toCSVFormat(num) → {string}

Prepare a number for CSV visualization.

Parameters:
Name Type Description
num number

The number to prepare.

View Source utils/units.js, line 76

  • CSV format.
string

# static toPercent(num, dec) → {string}

Format a number as a percentage.

Parameters:
Name Type Description
num number

The number to format

dec number

The number of decimals to use

View Source utils/units.js, line 67

  • Percentage value.
string