Global

Methods

bytesToSize(bytes) → {string}

Convert bytes to human readable format
Parameters:
Name Type Description
bytes bytes unit in bytes to parse
Source:
Returns:
- pretty string in the format [n unit]
Type
string
Example
bytesToSize( 1073741824 ) // -> 1 GB

normalizeHighResolutionTime(hrtime) → {number}

converts a "final" high resolution time stamp into nanoseconds
Parameters:
Name Type Description
hrtime hrtime high resolution time tuple returned from process.hrtime
Source:
Returns:
nanoseconds based on passed in high resolution time tuple
Type
number
Example
const
    start = process.hrtime(),
    end   = process.hrtime( start );

normalizeHighResolutionTime( end ); // -> 2000

sizeToBytes(bytes) → {bytes}

Convert human readable format to bytes
Recognized conversion units:
(Unit)[Standard Base 10][Digital Storage Unit 2ⁿ]
(B)BytesBytes
(kB|KiB)KilobytesKibibytes
(mB|MiB)MegabytesMegibytes
(gB|GiB)GigabytesGigibytes
(tB|TiB)TerabytesTeribytes
Parameters:
Name Type Description
bytes string | number string represending the bytes and unit to calculate the conversion
Source:
Returns:
- returns the number of bytes represented by the string
Type
bytes
Example
sizeToBytes( '1 KB' )        // -> 1000
sizeToBytes( '1 KiB' )       // -> 1024
sizeToBytes( '1 Kilobytes' ) // -> 1000
sizeToBytes( '1 Kibibytes' ) // -> 1024

Type Definitions

bytes

A number expected to be evaluated as bytes
Type:
  • number
Source:
Example
1024

hrtime

A "tuple" assumed to be a result of calling for high resolution time process.hrtime
typically, a resulting hrtime should be the returned value of process.hrtime( process.hrtime() ); where the inner hrtime is likely called before a function is run to calculate the time it took to run a process. tuple is assumed to be in nanoseconds
Type:
  • Array.<number>
Source:
Example
[ 22727, 841838045 ]