files.map(file => {
console.log(file)
setTimeout(() => {
console.log('TIMEOUT!!!')
}, 2000)
})
console.log('END OF EXEC')
const result = await Promise.all([ 1, 2, 3 ].map((n, i) => {
return new Promise(resolve => {
setTimeout(() => {
console.log(`timeout #${i}`);
resolve(n * 10);
}, Math.random() * 3000 | 0);
});
}));
console.log('result:', result);
const {map} = require('p-iteration')
const {promisify} = require('util')
const timeout = promisify(setTimeout)
let files = [1, 2, 3, 4, 5]
async function foo () {
await map(files, async file => {
console.log(file)
await timeout(2000)
console.log('TIMEOUT!!!')
})
console.log('END OF EXEC')
}
foo()