labs42io / itiriri

A library built for ES6 iteration protocol.

Home Page:https://labs42io.github.io/itiriri

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async generators?

getify opened this issue · comments

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);
}

Please see itiriri-async.

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. :)