the original array that's passed to xaa.map
indicate if another map operation during concurrent map has failed Mapping should observe this flag whenever possible and avoid continuing if it makes sense.
During concurrent map, if any mapper failed, this allow other inflight map functions to assert that no failure has occurred, else stop.
callback function for xaa.map to map the value.
value to map
index of the value in the array
MapContext
any or a promise
options for xaa.map
number of items to map concurrently
the this passed to the map callback
delay some milliseconds and then return valOrFunc
Sample:
await xaa.delay(500);
await xaa.delay(500, "Result");
await xaa.delay(500, () => "Result");
number milliseconds to delay
valOrFunc
or its returned value if it's a function.
async version of array.forEach
Sample:
await xaa.each([1, 2, 3], async val => await xaa.delay(val))
array to each
callback for each
async filter array
Sample:
await xaa.filter([1, 2, 3], async val => await validateResult(val))
Beware: concurrency is fixed to 1.
array to filter
callback for filter
filtered result
Create a promise Defer object
Sample:
async function waitEvent() {
const defer = xaa.makeDefer();
someThing.on("event", (data) => defer.resolve(data))
return defer.promise;
}
optional Promise constructor.
Defer instance
async map array with concurrency
bluebird.map
array to map, if any item is promise-like, it will be resolved first.
callback to map values from the array
MapOptions
promise with mapped result
Calls timeout(maxMs, rejectMsg).run(tasks)
Promise or function or array of them
milliseconds to wait for the tasks to fulfill
message to reject with if operation timed out
promise results from all tasks
Create a TimeoutRunner to run tasks (promises) with timeout
Sample:
await xaa.timeout(1000, "timeout fetching data").run(() => fetch(url))
with promises:
await xaa.timout(1000).run([promise1, promise2])
number of milliseconds to allow tasks to run
message to reject with when timeout triggers
TimeoutRunner object
try to:
If exception occur, then return valOrFunc
valOrFunc
is a function, then return valOrFunc(err)
function or promise to try
value, or callback to get value, to return if func
throws
result, valOrFunc
, or valOrFunc(err)
.
Wrap the calling of a function into async/await (promise) context
bluebird.try
function to wrap in async context
result from func
Generated using TypeDoc
context from xaa.map to the mapper callback