@stardazed/streams-text-encoding
This package provides an implementation of the TextEncoderStream
and TextDecoderStream
types from the Encodings Standard.
⚠️ Important: this is NOT a polyfill. The classes are just normal exports.
👉 If you want an all-in-one polyfill for streams, fetch interop and text encoding streams,
use the ⭐️Stardazed streams polyfill⭐️!
Installation
npm install @stardazed/streams-text-encoding
pnpm install @stardazed/streams-text-encoding
yarn add @stardazed/streams-text-encoding
Usage
import { TextEncoderStream, TextDecoderStream } from "@stardazed/streams-text-encoding";
const textReadable = ;
textReadable
.pipeThrough(new TextEncoderStream())
.pipeTo(byteWritable);
const byteReadable = ;
const decoder = new TextDecoderStream(encoding, options);
byteReadable
.pipeThrough(decoder)
.pipeTo(textWritable);
The options passed to the TextDecoderStream are identical to those passed to the
TextDecoder
class. See MDN's docs
for more.
Copyright
© 2018 by Arthur Langereis - @zenmumbler
License
MIT