An iterator abstraction for async operations
Install
npm install --save async-iterable
Usage (ES6 + modules + async/await)
// Create an infinite number generator (for the iteration seed) { var index = 0 while true index++} // Create the AsyncIterable.// note that defining an AsyncIterator is an immediate sync operation,// none of the callbacks below will be called before it is iteratedlet repoNamesEndingWithJsAsyncIterable = // (you can define sync or async data transformations) // (you can define sync or async data filters) // (you can define max items count) // Iterate the AsyncIterator.let firstMillionJsGithubRepoNames = await repoNamesEndingWithJsAsyncIterable
Usage (ES6 + modules + async/await + babel-plugin-transform-async-generator-functions)
AsyncIterable is also iterable via the new tc39 async-iteration proposal syntex (for now, the babel plugin 'babel-plugin-transform-async-generator-functions' is required to support this syntex)
// Create the AsyncIterable.let repoNamesEndingWithJsAsyncIterable = 1 2 3 // Iterate the AsyncIterator using the tc39 async-iteration proposal syntexfor { console;}