import { PrimitiveSymbol } from './types.ts'; declare global { interface DataView { getUint24(pos: number, littleEndian: boolean): number; getInt24(pos: number, littleEndian: boolean): number; setUint24(pos: number, val: number, littleEndian: boolean): void; setInt24(pos: number, val: number, littleEndian: boolean): void; } } /** * Cursor */ export declare abstract class Cursor extends DataView { abstract offset(): number; abstract move(address: number): number; abstract read(primitive: PrimitiveSymbol): number | bigint; abstract write(primitive: PrimitiveSymbol, value: number | bigint): void; forward(x: number): number; } export declare enum BinaryCursorEndianness { BigEndian = 0, LittleEndian = 1 } export declare abstract class BinaryCursor extends Cursor { protected index: number; protected length: number; protected endianness: BinaryCursorEndianness; move(offset: number): number; offset(): number; getEndian(): BinaryCursorEndianness; setEndian(endian: BinaryCursorEndianness): void; static getPrimitiveSize(primType: PrimitiveSymbol): number; } export declare class BinaryReader extends BinaryCursor { protected _readPrimitive(primType: PrimitiveSymbol): number | bigint; write(_: PrimitiveSymbol, _2: number | bigint): void; read(primitive: PrimitiveSymbol): number | bigint; constructor(array: ArrayBufferView | ArrayBufferLike, endian?: BinaryCursorEndianness); } export declare class BinaryWriter extends BinaryCursor { protected hasChanged: boolean; protected cachedBuffer: ArrayBufferLike; protected data: Array<[(number | bigint), PrimitiveSymbol, number, BinaryCursorEndianness]>; /** * This accessor overwrite the `byteLength` property inherited from the DataView. * * Because the `byteLength` property is readOnly the decorator here is used as * an hack to remain compliant as a ArrayBufferView but manage to show * dynamic data. */ accessor byteLength: number; /** * This accessor overwrite the `buffer` property inherited from the DataView. * * This accessor is used because `buffer` are difficult to resize with * DataView. * The decorator is used as an hack to re-write the getter of this property * and returns the ArrayBuffer based on the data written at any time while * remaining compliant with the ArrayBufferView interface. */ accessor buffer: ArrayBufferLike; write(primitive: PrimitiveSymbol, value: number | bigint): void; read(_: PrimitiveSymbol): number | bigint; constructor(endian?: BinaryCursorEndianness); }