aah
A JavaScript library of async/await helpers
object
aah : Kind: global namespace
- aah :
object
- .Callbackify ⇒
function
- .CatchError ⇒
function
- .Delay ⇒
function
- .InOrder ⇒
function
- .InParallel ⇒
function
- .InSeries ⇒
function
- .ParallelFilter ⇒
function
- .ParallelMap ⇒
function
- .PassThrough
- .Promisify ⇒
function
- .Race ⇒
function
- .TimeIn ⇒
function
- .TimeOut ⇒
function
- .Assert(validator, message) ⇒
taskFunction
- .Logging(...statements) ⇒
function
- .Callbackify ⇒
function
aah.Callbackify ⇒ const task = ; // logs 'res 1', eventually ;
Kind: static property of aah
Returns: function
- a callback-expecting function
Params
- task
function
- an async function
function
aah.CatchError ⇒ let task = ; const error result = await ;
Kind: static property of aah
Returns: function
- an async wrapper function around the task
Params
- task
function
- an async function to wrap around with a catch wrapper.
function
aah.Delay ⇒ const task = ; const result = await ; // result is 1, after 1 second
Kind: static property of aah
Returns: function
- an async function
Params
- time
number
- the time to delay
function
aah.InOrder ⇒ const task = ; const results = await ; // results is 3
Kind: static property of aah
Returns: function
- an async wrapper function that runs all of the tasks in order, calling each one with original request
Params
- ...tasks
function
- any number of async tasks.
function
aah.InParallel ⇒ const task = ; const results = await ; // results is [1, 2, 3]
Kind: static property of aah
Returns: function
- an async wrapper function that runs all the tasks in parallel, and returns an array of results
Params
- ...tasks
function
- any number of async tasks.
function
aah.InSeries ⇒ const task = ; const results = await ; // results is 3
Kind: static property of aah
Returns: function
- an async wrapper function that runs all of the tasks in series, calling each one with the results of the previous one
Params
- ...tasks
function
- any number of async tasks.
function
aah.ParallelFilter ⇒ const task = ; const results = await ; // results is [0, 2]
Kind: static property of aah
Returns: function
- an async wrapper function that takes in an array of requests, runs the task in parallel, once for each input in the array, and returns an array of results
Params
- task
function
- the filtering task
function
aah.ParallelMap ⇒ const task = ; const results = await ; // results is [1, 2, 3]
Kind: static property of aah
Returns: function
- an async wrapper function that takes in an array of requests, runs the task in parallel, once for each input in the array, and returns an array of results
Params
- task
function
- the mapping task
aah.PassThrough
const task = PassThrough; const results = await ; // results is 0
PassThrough does nothing, just passes the request through as the result
Kind: static property of aah
function
aah.Promisify ⇒ const task = ; const results = await ; // results is 2 const results2 = await ; // throws 'i cant be 0 Error
Kind: static property of aah
Returns: function
- an async function
Params
- task
function
- a callback-expecting function
function
aah.Race ⇒ const task = ; const result = await ; // 2
Kind: static property of aah
Returns: function
- an async task that resolves or rejects as soon as the first one of its "children" resolves or rejects
Params
- ...tasks
function
- any number of async tasks
function
aah.TimeIn ⇒ const task = ; const result = await ; // result1 = 2, after 1000 ms
Kind: static property of aah
Returns: function
- an async task
Params
- task
function
- an async task - timeIn
function
- the minimum time the task can take
function
aah.TimeOut ⇒ const task1 = ; const task2 = ; const result1 = await ; // result1 = 1, after 100 ms const result2 = await ; // throws a timeout error after 100 ms
Kind: static property of aah
Returns: function
- an async task
Params
- task
function
- an async tasks - timeOut
function
- the number of ms before throwing an error
taskFunction
aah.Assert(validator, message) ⇒ Builds an async assertion task. When called, if the arguments do not match the validator functions,
Kind: static method of aah
Returns: taskFunction
- an assertion task
Params
- validator
function
- a function that checks the request. - message
string
- an optional error message to throw if the assertion fails, or a message builder function.
function
aah.Logging(...statements) ⇒ A logging utility. It passes the request received into all the statements, collects the results, and pushes them into console.log
Kind: static method of aah
Returns: function
- a logging task
Params
- ...statements
*
- any number of logging values. Functions are called with the calling request, everything else is passed directly to