This file contains some functionalities related to units and their conversions.
Members
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. |
- 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. |
- 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. |
- 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. |
- Rounded value.
number
# static toCSVFormat(num) → {string}
Prepare a number for CSV visualization.
Parameters:
Name | Type | Description |
---|---|---|
num |
number
|
The number to prepare. |
- 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 |
- Percentage value.
string