Async generators?
getify opened this issue · comments
Kyle Simpson commented
Just wanted to see if you've considered supporting the asynchronous iteration protocol (like from async generators) with the itiriri API?
async function *getFiles(urls) {
var prs = urls.map(fetch);
for (let pr of prs) {
let file = await pr;
yield file;
}
}
var files = itiriri( getFiles([ "url1", "url2", "url3" ]) ).take(2);
for await (let file of files) {
console.log(file);
}
Dumitru commented
Please see itiriri-async
.
Kyle Simpson commented
Thanks, that's exactly what I was looking for!
BTW, itiriri-async is a nice complement to my lib: Fasy. Fasy supports eager async iteration, whereas itiriri-async supports lazy async iteration. I had been contemplating adding lazy (iterators) support to Fasy, but now that I've found itiriri-async, I can just recommend it. :)