- From: Jimmy Wärting <notifications@github.com>
- Date: Tue, 27 Aug 2019 05:18:50 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 27 August 2019 12:19:11 UTC
i want to have a transform stream that sits in the middle of one readable stream (source) and writable stream (dest) and i want to have that transformer stream in the middle to filter out the beginning of the stream until it encounter a certain value. After that i just want everything else to pass through. While this solution works i wonder if there is a better way to "terminate" the transform stream. ```js // (source) a = new ReadableStream({ start(ctrl) { ctrl.enqueue('a') ctrl.enqueue('b') ctrl.enqueue('c') ctrl.enqueue('d') } }) let goThrought = false b = new TransformStream({ transform(chunk, ctrl) { if (goThrought) { ctrl.enqueue(chunk) } if (chunk === 'b') { // filter out first chunks // preferable unpipe this transform stream so it // goes directly from a -> c goThrought = true } } }) // (dest) c = new WritableStream({ write(chunk) { console.log(chunk) } }) a.pipeThrough(b).pipeTo(c) ``` expected output: c, d -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1012
Received on Tuesday, 27 August 2019 12:19:11 UTC