0π
β
I simply call on my βon Dataβ event a separate function and copy the data/chunks to a string. When I recreate my terminal component, I initialize the content with the buffer string. Also, I can watch if my "buffer" is too full and slice it.
If someone gets in the same situation, here is a example:
stream.on('data', (data) => {
...
this.buffer(data)
})
...
buffer(data) {
this.streamBuffer += data // Saving data/chunks
const bufferLength = this.streamBuffer.length
if (bufferLength > 10000) {
this.streamBuffer = this.streamBuffer.slice(bufferLength - 8000)
}
}
Source:stackexchange.com