UNPKG

@kayahr/text-encoding

Version:
35 lines (34 loc) 1.06 kB
/** Special value returned when end of the buffer has been hit. */ export declare const END_OF_BUFFER = -1; /** * A buffer backed by by a dynamic byte array. Bytes can be read to or written from the buffer. */ export declare class ByteBuffer { /** The bytes in the buffer. */ private readonly bytes; /** * Creates a new byte buffer backed by the given byte array. * * @param bytes - Array of initial bytes in the buffer. */ constructor(bytes: number[] | Uint8Array); /** * Checks if end of buffer has been hit. * * @returns True if end of buffer, false if not. */ isEndOfBuffer(): boolean; /** * Reads the next byte from the buffer and returns it. END_OF_BUFFER is returned when there are no more bytes to * read. * * @returns The read byte or END_OF_BUFFER when no more bytes to read. */ read(): number; /** * Writes the specified bytes to the buffer. * * @param bytes - The bytes to write. */ write(...bytes: number[]): void; }