[whatwg/streams] [Question] how do you "unpipe"? (#1012)

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