This is the object stream instance.
Create a new instance of PureStream
You wouldn't normally create a stream this way, instead you would use transformers.
import {PureStream} from 'pure-stream';
const stream = new PureStream({
highWaterMark: 1
});
Pipe from one stream to another.
Errors are propagated from the source to the destination.
import {PureStream} from 'pure-stream';
new PureStream().pipe(new PureStream());
Write a value to the stream.
Returns false
if the stream wishes for the calling code to wait for the 'drain'
event to be emitted before continuing to write additional data; otherwise true
.
import {PureStream} from 'pure-stream';
const written = new PureStream().write(1);
Destroy the stream and end with an error.
import {PureStream} from 'pure-stream';
new PureStream().destroy(new Error('Bad));
Ends a stream gracefully.
Takes an optional value that is written to the stream before end.
import {PureStream} from 'pure-stream';
new PureStream().end();
Calls the given method when data is received.
import {PureStream} from 'pure-stream';
new PureStream().each((value) => console.log(value));
Calls the given method when the stream ends.
The first argument will be an error if one occurred.
import {PureStream} from 'pure-stream';
new PureStream().done((err) => console.log('Stream ended', err));
Convert the stream into a promise that resolves to an array of each item in the stream.
import {PureStream} from 'pure-stream';
const stream = new PureStream();
stream.write(1);
stream.write(2);
stream.toPromise(); // Promise<[1, 2]>
Convert the stream into a node passthrough stream.
import {PureStream} from 'pure-stream';
const stream = new PureStream();
stream.write(1);
stream.write(2);
const nodeStream = stream.toNodeStream();
nodeStream.on('data', () => {}); // 1, 2