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

captureErrors(e, req, res, next)

capture any errors that may occur - should be last middleware function in the request cycle

Parameters:
Name Type Description
e Error | null

null unless an error occurs

req http.Request

HTTP Request

res http.Response

HTTP Response

next function

next middleware function

Source:

packet(req, res, next)

construct basic wrapper operations for consistent api responses

Parameters:
Name Type Description
req http.Request

HTTP Request

res http.Response

HTTP Response

next function

next middleware function

Source:

wait(t, vopt) → {Promise.<any>}

similar to usleep in C++

Parameters:
Name Type Attributes Description
t milliseconds

time to wait

v * <optional>

optional value to pass through when promise resolves

Source:
Returns:
  • promise to be resolved in [t] milliseconds
Type
Promise.<any>
Example
wait( 100, 'hello world' )
    .then() // -> will pass 'hello world' in 100ms