Created
October 15, 2020 01:25
-
-
Save itacirgabral/a35e8f6b2ab6f5fe8724ab3de12e8fef to your computer and use it in GitHub Desktop.
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 characters
const delay = t => new Promise(res => setTimeout(() => res(), t)) | |
const arr = Array(5).fill() | |
const delayed = async function* delayed(arr, t = 1000) { | |
for(const el of arr) { | |
yield delay(t) | |
} | |
} | |
const it = delayed(arr) | |
;(async () => { | |
let dArr | |
let pDArr | |
let tPDArr | |
let notDone = true | |
while (notDone) { | |
dArr = Array(3).fill().map(el => it.next()) | |
pDArr = Promise.all(dArr) | |
tPDArr = await pDArr | |
notDone = !tPDArr.find(el => el.done) | |
} | |
})() |
Author
itacirgabral
commented
Oct 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment