Created
May 15, 2020 00:59
-
-
Save itacirgabral/6203992d27da37b285cd910cee813bc6 to your computer and use it in GitHub Desktop.
This file contains 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
var arrayzao = [ | |
'a', | |
'e', | |
'i', | |
'o', | |
'u', | |
'æ' | |
] | |
const delay = x => new Promise(res => { | |
const delay = (1 + Math.random()) * 300 | |
setTimeout(() => res(x), delay) | |
}) | |
const gen = function *(arr) { | |
for (let i=0; i<arr.length; i=i+2) { | |
yield Promise.all([delay(arr[i]), delay(arr[i + 1])]) | |
} | |
} | |
;(async () => { | |
for await (const [a0, a1] of gen(arrayzao)) { | |
console.log(`a0=${a0} a1=${a1}`) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment