js-draw
Version:
Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.
18 lines (17 loc) • 560 B
JavaScript
/**
* Resolves when all given promises have resolved. If no promises are given,
* does not return a Promise.
*
* If all elements of `results` are known to be `Promise`s, use `Promise.all`.
*/
const waitForAll = (results) => {
// If any are Promises...
if (results.some((command) => command && command['then'])) {
// Wait for all commands to finish.
return (Promise.all(results)
// Ensure we return a Promise<void> and not a Promise<void[]>
.then(() => { }));
}
return;
};
export default waitForAll;