HeartBeat stream will slow down chunks when number of them is below bufferSize.
constructor (inherits from Duplex) takes object with following options:
- bufferSize - threshold of items
- delay - each element below will be emitted with every
delay
milliseconds
const readableStream = /*...*/
const writeStream = /*...*/
const heartBeatStream = new HeartBeatStream({ bufferSize: 1000, delay: 1000 })
readableStream
.pipe(heartBeatStream)
.pipe(writeStream)