Last active
March 25, 2022 12:32
-
-
Save emilhein/4277d232ee50bdb94387c3324e86b435 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
function executeSequentially(promiseFactories) { | |
var result = Promise.resolve(); | |
promiseFactories.forEach(function (promiseFactory) { | |
result = result.then(promiseFactory); | |
}); | |
return result; | |
} | |
const logger = async (input) => { | |
console.log('Heelloo', input) | |
} | |
const runner = async () => { | |
let start = 1; | |
let end = 150; | |
let promises = []; | |
for (let i = start; i <= end; i++) { | |
let factoryFunction = function myPromiseFactory() { | |
return logger(i); | |
}; | |
promises.push(factoryFunction); | |
} | |
await executeSequentially(promises); | |
}; | |
// runner() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment