SHARE
TWEET

Untitled

a guest Mar 25th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function series<T>(promises: (() => Promise<T>)[],): Promise<T[]> {
  2.     const results: T[] = [];
  3.     async function seriesInner(promises: (() => Promise<T>)[]): Promise<T[]> {
  4.         if (promises.length > 0) {
  5.             const p = promises.shift();
  6.             const result = await p();
  7.             results.push(result);
  8.             return seriesInner(promises);
  9.         } else {
  10.             return results;
  11.         }
  12.     }
  13.  
  14.     seriesInner(promises);
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top