Basically, I'm looking for something like Promise.all(), but one that calls a function in then()for each result, as soon as this result is ready. It's trivial to write using standard callbacks like this (file reading example):
function foo(files, bar) {
for (let file of files) {
const fr = new FileReader();
fr.onload = e => bar(e.target.result);
fr.readAsDataURL(file);
}
}
I am sure there is a library there that does what I want, but I would like to do it in pure JS.
To clarify, I would like to have something like this:
function foo(files) {
}
foo(['1','2','3']).then();`
source
share