Utilities
delay(duration)
duration
(number|string)
Amount of time to wait- Returns:
(Promise)
Wait for a given amount of time. The input can be a string compatible to the ms
module.
Examples
; { await ; // wait for 1 second await ; // wait for 1 minute} ;
hash(message[,algorithm][,salt])
message
(string|Buffer)
Input messagealgorithm
(string)
Algorithmsalt
(string|Buffer)
- Returns:
(Promise<Buffer>)
Generate hash.
Examples
; ;;;
hmac(message[,key][,algorithm])
message
(string|Buffer)
Input messagekey
(string|Buffer)
algorithm
(string)
Algorithm- Returns:
(Promise<Buffer>)
Generate hash.
Examples
; ;;
rateLimiter(params)
params
(Object)
tokensPerInterval
(Number)
Number of tokens to drip into the bucket over the course of one interval.interval
(String|Number)
The interval length in milliseconds, or as one of the following strings:second
,minute
,hour
,day
.maxRetry
(Number)
Number of tries before it will be considered as a fail.minInterval
(Number)
Number of the minimum interval for retry delay.
- Returns:
(Promise<Function>)
consumeToken
(Number)
Number of token to consume.cb
(Function)
Function to be called when there is enough token to consume.err
(Object)
Error object when there is an error occured.remainingRequests
Number of remaining token to be consumed right this moment.
; const limiter = ; { await ; } process;
rateLimiter.consume
Logger
Class: Generate logs that follow a certain format.
new Logger(tags)
tags
(Array<string>)
logger.tag(tag)
-
tag
(string)
- Returns:
(Logger)
logger.error(arg0[,arg1][,arg2]...)
arg0
(string|Object|)
arg1
(string|Object|)
arg2
(string|Object|)
logger.warn(arg0[,arg1][,arg2]...)
arg0
(string|Object|)
arg1
(string|Object|)
arg2
(string|Object|)
logger.info(arg0[,arg1][,arg2]...)
arg0
(string|Object|)
arg1
(string|Object|)
arg2
(string|Object|)
logger.verbose(arg0[,arg1][,arg2]...)
arg0
(string|Object|)
arg1
(string|Object|)
arg2
(string|Object|)
logger.silly(arg0[,arg1][,arg2]...)
arg0
(string|Object|)
arg1
(string|Object|)
arg2
(string|Object|)
Examples
; const logger = 'api'; logger;logger;logger;logger;logger; logger;