Skip to content

Instantly share code, notes, and snippets.

@emilhein
Last active March 25, 2022 12:32
Show Gist options
  • Save emilhein/4277d232ee50bdb94387c3324e86b435 to your computer and use it in GitHub Desktop.
Save emilhein/4277d232ee50bdb94387c3324e86b435 to your computer and use it in GitHub Desktop.
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