Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Latest commit

 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Encode Transformations

Overview

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.

Requirements

You need implementations of TextEncoder, TextDecoder, ReadableStream, WritableStream and TransformStream, either natively or via polyfill.

How to use

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

Tests have moved to the main web-platform-tests repository at https://github.com/web-platform-tests/wpt/tree/master/encoding/streams.

See also

Disclaimer

This is not an official Google product.

About

Prollyfill for using TextEncoder and TextDecoder as transform streams

Resources

Contributing

Stars

20 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages