I was reading these docs: https://nodejs.org/ja/docs/guides/backpressuring-in-streams/
It says:
Readable.pipe(Transformable).pipe(Writable);
"Backpressure will be automatically applied, but note that both the incoming and outgoing highWaterMark of the Transform stream may be manipulated and will effect the backpressure system."
I can change the highWaterMark
this way:
export class JSONParser extends stream.Transform {
constructor() {
super({objectMode: true, highWaterMark: 3}); // 3 objects is high water mark
}
}
but since it says that both incoming and outgoing highWaterMark
of the transform stream can be manipulated - how do I change the highWaterMark
of the incoming/outgoing data? My guess is that this one property controls both levels?
In essence, I am trying to slow the amount of reads in my stream, so that other I/O can be processed. The readable stream in my case is process.stdin
and process.stdin
is being piped to a transform stream, which I control. How can I slow the rate of reading from stdin?