This is a polyfill for the transform streams TextEncoderStream and TextDecoderStream. It is based on the TextEncoderStream and TextDecoderStream interfaces from the Encoding Standard:
https://encoding.spec.whatwg.org/#interface-textdecoderstream
It is intended for experimentation with the standard.
You need implementations of TextEncoder, TextDecoder, ReadableStream, WritableStream and TransformStream, either natively or via polyfill.
Include the polyfill in the page:
<script src="text-encode-transform.js">
It can also be used in a Worker environment:
importScripts('text-encode-transform.js');
Then you can use it in a pipe like this:
byteSource
.pipeThrough(new TextDecoderStream())
.pipeTo(textDestination);
Any arguments that the TextDecoder constructor normally accepts will also work when used as a stream transform.
TextEncoderStream works the same way:
textSource
.pipeThrough(new TextEncoderStream())
.pipeTo(byteDestination);
Tests have moved to the main web-platform-tests repository at https://github.com/web-platform-tests/wpt/tree/master/encoding/streams.
This is not an official Google product.