softkave-js-utils
Version:
JavaScript & Typescript utility functions, types, and classes
14 lines • 535 B
JavaScript
/** Returns a function that calls input functions in parallel with any arguments
* passed to it. */
export function overArgsAsync(fns,
/** Whether to use `Promise.allSettled()` or `Promise.all()` */
usePromiseSettled, transformFn) {
return async (...args) => {
const promises = fns.map(fn => fn(...args));
const result = await (usePromiseSettled
? Promise.allSettled(promises)
: Promise.all(promises));
return transformFn(result);
};
}
//# sourceMappingURL=overArgsAsync.js.map