Async is a utility module that provides powerful, straight-forward functions for working with asynchronous JavaScript.
Async reflectAll is a helper function that wraps an array or an object of functions with async reflect. It returns a type array of async functions that are each wrapped in async.reflect
. Reflect
is useful as it wraps any async function in another function and always results a return object. If there is an error, the result object will return a NULL value.
module:utils
.Array|Object|Iterable
tasks.async.reflect
.The default code for this method is reflectAll
:
export default function
// tasks is the parameters
reflectAll(tasks) {
var results;
// if it's an array, simply perform reflect on the whole array
if (Array.isArray(tasks)) {
results = tasks.map(reflect);
} else {
// otherwise, call reflect individually on each task and store it in an array
results = {};
Object.keys(tasks).forEach(key => {
results[key] = reflect.call(this, tasks[key]);
});
}
return results;
}
For more information, click here.
Free Resources