Hello,
Consider the following toy example:
const replaceStream = require('replacestream');
const { PassThrough } = require('stream');
const input = new PassThrough(), param = new PassThrough(), out = new PassThrough();
input.end('hello{{sep}}world');
param.end(', ');
const replace = replaceStream('{{sep}}', match => {
replace.pause();
param.on('end', () => replace.resume());
param.pipe(out, { end: false });
return '';
});
input.pipe(replace).pipe(out);
What I was expecting out to contain: hello, world
What out actually contained: , helloworld
Without knowing the internals, my best guess is that the stream before the match is still being held on to when pause is called, making chunks arrive in out out of the expected order. Is there a way to force the left context out beforehand?
Hello,
Consider the following toy example:
What I was expecting
outto contain:hello, worldWhat
outactually contained:, helloworldWithout knowing the internals, my best guess is that the stream before the match is still being held on to when
pauseis called, making chunks arrive inoutout of the expected order. Is there a way to force the left context out beforehand?