I'm fetching images from my app through js but eslint is warning about using async promise executors. I know that in other cases like this, you could just remove the promise all-together, but not sure if that's applicable here.
Here is the code in question:
async fn() {
let urls = _.map($('#img-container img'), (img) => $(img).attr('src'));
urls = await Promise.all(urls.map((url) => new Promise(async (res) => { // FIXME - async promise executor
const blob = await (await fetch(url)).blob();
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = res;
})));
urls = urls.map((u) => u.target.result);
return Buffer.from(pako.deflate(JSON.stringify(urls))).toString('base64');
}
How could I restructure this to get rid of this pattern? Or should I just dismiss the warning?