[whatwg/encoding] Make TextEncoder and TextDecoder be transform streams (#127)

Add `readable` and `writable` attributes to TextEncoder and TextDecoder
objects to permit them to be used to transform ReadableStreams via the
`pipeThrough()` method.

This integrates the Encoding Standard with the Streams Standard. See
https://streams.spec.whatwg.org/#ts-model for the definition of a
"transform stream" and https://streams.spec.whatwg.org/#rs-pipe-through
for an explanation of the `pipeThrough()` method.

A TextEncoder object can be used to transform a stream of strings to a
stream of bytes in UTF-8 encoding. A TextDecoder object can be used to
transform a stream of bytes in the encoding passed to the constructor to
strings.

The implementation delegates to a TransformStream object internally,
which provides the glue logic that ties the `readable` and `writable`
together.

There is a human-readable version of these changes at
http://htmlpreview.github.io/?https://github.com/ricea/encoding-streams/blob/master/patch.html

There is a prollyfill and tests for the new functionality at
https://github.com/GoogleChromeLabs/text-encode-transform-prollyfill

Closes #72.
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/encoding/pull/127

-- Commit Summary --

  * Make TextEncoder and TextDecoder be transform streams

-- File Changes --

    M encoding.bs (266)

-- Patch Links --

https://github.com/whatwg/encoding/pull/127.patch
https://github.com/whatwg/encoding/pull/127.diff

-- 
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/encoding/pull/127

Received on Monday, 11 December 2017 09:04:21 UTC