@nberlette/utf8
Version:
Blazing fast universal ponyfills for TextEncoder and TextDecoder.
42 lines (41 loc) • 1.58 kB
TypeScript
import { type BufferSource, type TextDecoderOptions } from "./text_decoder.js";
/**
* Zero-dependency ponyfill for the native `TextDecoderStream` Web API.
*
* Uses the {@linkcode TextDecoder} ponyfill to decode UTF-8 bytes into strings
* 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/TextDecoderStream
* @category Streams
* @tags utf-8, decoder
*/
export declare class TextDecoderStream {
#private;
constructor(label?: string, options?: TextDecoderOptions);
/**
* @returns the encoding standard being used by the underlying `TextDecoder`.
*/
get encoding(): string;
/**
* If true, invalid bytes will throw a TypeError. This reflects the value of
* the `fatal` option passed to the `TextDecoderStream` constructor.
*/
get fatal(): boolean;
/**
* If true, the BOM (Byte Order Mark) will be ignored. This reflects the
* value of the `ignoreBOM` option passed to the `TextDecoderStream`
* constructor.
*/
get ignoreBOM(): boolean;
/**
* @returns the readable stream side of the `TextDecoderStream`, which can be
* used to read the decoded strings as they are produced by the decoder.
*/
get readable(): ReadableStream<string>;
/**
* @returns the writable stream side of the `TextDecoderStream`, which can be
* used to write UTF-8 bytes to be decoded by the underlying `TextDecoder`.
*/
get writable(): WritableStream<BufferSource>;
}