Intent to Implement: TransformStream (part of the Streams Standard)

113 views
Skip to first unread message

Adam Rice

unread,
Nov 5, 2017, 10:00:35 PM11/5/17
to blink-dev

Contact emails

ri...@chromium.org (spec and implementation), dom...@chromium.org (spec), tyos...@chromium.org (TL)


Explainer

Examples and motivation are included in the standard text: https://streams.spec.whatwg.org/#ts and https://streams.spec.whatwg.org/#example-ts-lipfuzz.


Design doc/Spec

Specification: https://streams.spec.whatwg.org/#ts


Tag review: https://github.com/w3ctag/design-reviews/issues/211



Summary

A TransformStream takes chunks from an input stream and performs arbitrary transformations on them before supplying them to an output stream. The pipeThrough API which shipped in M59 provided a way to pipe a stream through a {writable, readable} pair; TransformStream provides a helper to make creating such a pair much easier in the common case where it represents a transformation.


Motivation

TransformStream makes it easy to transform streaming data. Without it authoring a transformation involves a considerable amount of boilerplate. There is also a risk of developers creating transformations with non-standard APIs and losing the benefit of composition.


Risks

Interoperability and Compatibility

TransformStream is a new constructor in the global namespace. Its public API has been stable in the reference implementation since 2015, with only minor changes.


Edge: No signals

Firefox: Public support

Safari: No signals

Web developers: Positive


There is general support for the Streams API among browser vendors, however we have not yet collected signals specific to TransformStream. Although it has existed in reference implementation form for a number of years, promotion to the written standard has only happened recently. Since Edge, Firefox and Safari have shipped or are shipping other parts of the Streams API, we can expect they will also ship TransformStream. Firefox has commented favorably on TransformStreams in particular, noting how they help with several service worker use cases.


The reference implementation (a line-by-line transcription of the spec into JavaScript) has a full set of web platform tests (https://github.com/whatwg/streams/tree/master/reference-implementation/to-upstream-wpts/transform-streams) with 100% coverage of the reference implementation. These will be moved to the web-platform-tests repository as part of this implementation work.


Ergonomics

This is commonly used with response body streaming in the fetch API, as shown by some of the linked examples.


Stream APIs including TransformStream naturally function in an asynchronous chunked fashion which fits well into highly responsive web apps.


Activation

It will be immediately useful. Polyfills have existed for a while, and can be used to bridge the gap until all browsers reach feature parity.




Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes.


Link to entry on the feature dashboard

https://www.chromestatus.com/feature/5466425791610880


Requesting approval to ship?

No


Reply all
Reply to author
Forward
0 new messages