Skip to content

Instantly share code, notes, and snippets.

@eioo
Last active April 9, 2018 18:48
Show Gist options
  • Save eioo/50d4cd8d9d543c4dd0728535fcbb3522 to your computer and use it in GitHub Desktop.
Save eioo/50d4cd8d9d543c4dd0728535fcbb3522 to your computer and use it in GitHub Desktop.
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