Last active
April 9, 2018 18:48
-
-
Save eioo/50d4cd8d9d543c4dd0728535fcbb3522 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
import * as _ from 'lodash'; | |
const jokuArray = [1,2,3,4,5]; | |
function sleep(ms) { | |
return new Promise(res => setTimeout(res, ms)); | |
} | |
async function main() { | |
// await wörkkii | |
console.log('Odotan 3 sekuntia.'); | |
await sleep(1000); | |
console.log('3 sekuntia on nyt odotettu.') | |
_.map(jokuArray, async solution => { | |
// await ei wörki | |
console.log('Odotan sekuntin.'); | |
await sleep(1000); | |
console.log('Sekunti odotettu\'d'); | |
}); | |
} | |
main(); | |
/* | |
> ts-node test.ts | |
Odotan 3 sekuntia. | |
3 sekuntia on nyt odotettu. | |
Odotan sekuntin. | |
Odotan sekuntin. | |
Odotan sekuntin. | |
Odotan sekuntin. | |
Odotan sekuntin. | |
Sekunti odotettu'd | |
Sekunti odotettu'd | |
Sekunti odotettu'd | |
Sekunti odotettu'd | |
Sekunti odotettu'd | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment