@stardazed/streams-text-encoding
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@stardazed/streams-text-encoding

This package provides an implementation of the TextEncoderStream and TextDecoderStream types from the Encoding 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";

// encode
const textReadable = /* Get a readable stream that produces string chunks */;
textReadable
    .pipeThrough(new TextEncoderStream()) // no options available
    .pipeTo(byteWritable);

// decode
const byteReadable = /* Get a readable stream that produces binary chunks */;
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

Readme

Keywords

none

Package Sidebar

Install

npm i @stardazed/streams-text-encoding

Weekly Downloads

391

Version

1.0.2

License

MIT

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • zenmumbler