Created
June 9, 2019 12:19
-
-
Save LinZap/bb2826367aa19398f8ce070d2571ad27 to your computer and use it in GitHub Desktop.
Node.js - HK6
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
function delay(ms) { | |
return new Promise(resolve => setTimeout(() => { | |
console.log(new Date()) | |
resolve() | |
}, ms)) | |
} | |
let p = delay(1000); | |
for (let i = 0; i < 4; i++) { | |
p = p.then(() => delay(1000)) | |
} |
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
2019-06-09T12:16:24.854Z | |
2019-06-09T12:16:25.864Z | |
2019-06-09T12:16:26.866Z | |
2019-06-09T12:16:27.867Z | |
2019-06-09T12:16:28.868Z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment