UNPKG

@nberlette/utf8

Version:

Blazing fast universal ponyfills for TextEncoder and TextDecoder.

28 lines (27 loc) 1 kB
/** * Zero-dependency ponyfill for the native `TextEncoderStream` Web API. * * Uses the {@linkcode TextEncoder} ponyfill to encode strings into UTF-8 * bytes in a streaming fashion. Requires the `TransformStream` API to be * available in the current environment. * * @see https://developer.mozilla.org/en-US/docs/Web/API/TextEncoderStream * @category Streams * @tags utf-8, encoder */ export declare class TextEncoderStream { #private; constructor(); /** The encoding standard to use. This is always `"utf-8"`. */ get encoding(): string; /** * @returns the readable stream side of the `TextEncoderStream`, which can be * used to read the encoded bytes as they are produced by the encoder. */ get readable(): ReadableStream<Uint8Array>; /** * @returns the writable stream side of the `TextEncoderStream`, which can be * used to write strings to be encoded by the underlying `TextEncoder`. */ get writable(): WritableStream<string>; }