streamtoarray converts streams to arrays.
Category | Status |
---|---|
Version | |
Dependencies | |
Dev dependencies | |
Build | |
License |
$ npm install streamtoarray
First you need to integrate streamtoarray into your application:
const { toArray } = require('streamtoarray');
If you use TypeScript, use the following code instead:
import { toArray } from 'streamtoarray';
Then you can call toArray
with a stream. The stream gets converted and its contents are returned as an array once the stream has ended:
const array = await toArray(stream);
If the stream emits an error
event, an exception is thrown, and the partially parsed array is provided as the array
property of the exception:
try {
const array = await toArray(stream);
} catch (ex) {
console.log(ex.array);
// ...
}
To run quality assurance for this module use roboter:
$ npx roboter