Created
April 28, 2021 06:57
-
-
Save Namchee/a1b00d34d1663e016163b96e578ad521 to your computer and use it in GitHub Desktop.
Revisions
-
Namchee created this gist
Apr 28, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ // really quick and dirty way to solve it. let count = 0; const promisified = (time) => new Promise(resolve => { setTimeout(resolve, time); }); async function timeoutProms(proms, c, time) { count++; await promisified(time); console.log(time); count--; serialCon(proms, c); } function serialCon(proms, c) { if (count < c && proms.length) { timeoutProms(proms, c, proms[0]); proms.shift(); serialCon(proms, c); } else { return; } } const arr = [5000, 1000, 100, 300, 2000]; serialCon(arr, 2);