UNPKG

@kayahr/text-encoding

Version:
24 lines (23 loc) 979 B
import type { ByteBuffer } from "./ByteBuffer.ts"; import type { Decoder } from "./Decoder.ts"; /** * Base class for decoders. */ export declare abstract class AbstractDecoder implements Decoder { /** True to throw an exception when a character can't be decoded. False to decode to a replacement character instead. */ protected readonly fatal: boolean; /** * @param fatal - True to throw an exception when a character can't be decoded. False to decode to a * replacement character instead. */ constructor(fatal?: boolean); /** * Fails the decoding by throwing an exception (if fatal flag is true) or returning a replacement character. * * @returns Replacement character to use for the character which could not be decoded. * @throws TypeError - When fatal flag is set to true. */ protected fail(): number; /** @inheritdoc */ abstract decode(buffer: ByteBuffer): number | number[] | null; }