/** * A bounds-checked byte cursor. * * Every format parser in this library reads through this class and never touches * a raw `DataView` offset. That is deliberate: an unchecked read past the end of * a buffer is the single most common vulnerability class in media parsers, and * the only reliable way to avoid it is to make the unchecked path unavailable. * * `DataView` does throw `RangeError` on overrun by itself, but the message tells * a caller nothing about which file failed or where. Routing through `ensure()` * turns every overrun into a {@link DecodeError} carrying a byte offset. */ export declare class Reader { private readonly view; private readonly bytes; private pos; constructor(source: Uint8Array | ArrayBuffer); /** Total bytes available. */ get length(): number; /** Current read position. */ get offset(): number; /** Bytes between the cursor and the end. */ get remaining(): number; /** True when at least `n` bytes remain. Never throws — use to branch, not to guard. */ has(n: number): boolean; /** * Asserts `n` readable bytes remain. Every read in this class calls it first. * * @throws {DecodeError} when the buffer would be overrun. */ ensure(n: number): void; /** Moves the cursor to an absolute position. */ seek(offset: number): void; /** Advances the cursor by `n` bytes. */ skip(n: number): void; /** * Returns the next `n` bytes as a zero-copy view into the same memory. * * Zero-copy is what keeps large-file handling cheap, but it means the result * aliases the caller's buffer. Use {@link copy} when the bytes must outlive or * be mutated independently of the source. */ bytesView(n: number): Uint8Array; /** Returns the next `n` bytes as a fresh, independent copy. */ copy(n: number): Uint8Array; /** Reads `n` bytes as Latin-1 text. Used for chunk tags and format identifiers. */ ascii(n: number): string; /** * Reads a 4-byte chunk identifier without moving the cursor past it in a way * that hides mismatches — the cursor advances by exactly 4. */ fourCC(): string; /** Peeks a 4-byte identifier without moving the cursor. */ peekFourCC(): string; /** Peeks a single byte at `delta` from the cursor without moving it. */ peekU8(delta?: number): number; u8(): number; i8(): number; u16(littleEndian: boolean): number; i16(littleEndian: boolean): number; /** Reads a 24-bit unsigned integer. Common in WAV; absent from `DataView`. */ u24(littleEndian: boolean): number; /** Reads a 24-bit signed integer, sign-extended to a JS number. */ i24(littleEndian: boolean): number; u32(littleEndian: boolean): number; i32(littleEndian: boolean): number; /** * Reads a 64-bit unsigned integer as a JS number. * * Values above `Number.MAX_SAFE_INTEGER` are rejected rather than silently * rounded. RF64 and W64 use 64-bit sizes, and a quietly-truncated size is a * bounds check that passes when it should not. */ u64(littleEndian: boolean): number; f32(littleEndian: boolean): number; f64(littleEndian: boolean): number; /** * Reads an 80-bit IEEE 754 extended-precision float. * * AIFF stores its sample rate this way and nothing else in modern computing * does, so this exists solely for that field. */ f80(): number; /** * Aligns the cursor to an even offset, as RIFF and IFF chunk padding requires. * Tolerates a missing final pad byte, which real-world files often omit. */ align2(): void; /** Returns a reader scoped to the next `n` bytes and advances past them. */ subReader(n: number): Reader; }