async-iterator-to-stream
Convert an async iterator/iterable to a readable stream
Even though this library is dedicated to async iterators, it is fully compatible with synchronous ones.
Furthermore, generators can be used to create readable stream factories!
Install
Installation of the npm package:
> npm install --save async-iterator-to-stream
Usage
const asyncIteratorToStream = ; // sync/async iterators; // sync/async iterablesasyncIteratorToStream; // if you pass a sync/async generator, it will return a factory instead of a// streamconst createRangeStream = asyncIteratorToStream;;
Example
Let's implement a simpler fs.createReadStream
to illustrate the usage of this
library.
const asyncIteratorToStream = ; // promisified fsconst fs = ; const createReadStream = ; ;
If your environment does not support async generators, you may use a sync generator instead and
yield
promises to wait for them.
Development
# Install dependencies
> npm
# Run the tests
> npm test
# Continuously compile
> npm run dev
# Continuously run the tests
> npm run dev-test
# Build for production
> npm run build
Contributions
Contributions are very welcomed, either on the documentation or on the code.
You may:
- report any issue you've encountered;
- fork and create a pull request.
License
ISC © Julien Fontanet