Re: [whatwg/streams] light weight transformations (#461)

Hey, great to have you here!

In general the design of transform streams, and even writable streams, is still in flux and open to suggestions. (Readable streams, we're pretty happy with.) So feedback like this is definitely good to have.

The big struggle we've had so far is figuring out the balance between two positions:

- Readable streams only, with transforms being functions mapping readable streams to readable streams, and writables being functions that accept readable streams
- The Node-style ecosystem with three first class concepts and pipe chains between them

For example, service worker APIs have leaned us toward the former for various technical reasons, which IMO as a fan of the Node style is disappointing.

My way of interpreting your feedback is that we'd want to preserve the three-concept ecosystem, but provide a performant and lightweight way to make synchronous transformations work. Here would be my strawman:

```js
const transform = TransformStream.map(syncMappingFunction);

readable.pipeThrough(transform).pipeTo(writable);
```

Here:

- transform.writable and transform.readable exist, and can be used directly if desired
- But pipeThrough performs a more optimal fast-path that avoids ever reifying those two streams

In general I like the conceptual simplify of a transform always being a { writable, readable } pair, and always having the same API, instead of having one for duplex and one for simple mappings. That's why I suggest the above, which preserves that API, but should also give us the benefits of lightweight transforms when desired.

What do you think?

---
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/461#issuecomment-222826827

Received on Tuesday, 31 May 2016 21:29:17 UTC