import { SIZE, Struct, StructDefinition } from "./reader.mjs"; //#region src/writableStream.d.ts interface DataViewWritableStreamOptions { /** Passed to ByteLengthQueuingStrategy for superclass. */ highWaterMark?: number; /** * If specified, start with these bytes enqueued. Strings are encoded as * UTF-8. */ input?: Uint8Array | ArrayBuffer | string; /** * Default endianness for the stream. */ littleEndian?: boolean; /** If there is an error in UTF8 encoding, use the replacement character. */ ignoreUTF8errors?: boolean; } /** * This is readable in the DataView sense, but writable in the stream sense. */ declare class DataViewWritableStream extends WritableStream { #private; static readonly SIZE: typeof SIZE; constructor(options?: DataViewWritableStreamOptions | string | Uint8Array); /** * Current number of bytes queued but unread. */ get length(): number; /** * Current default endianness. May be changed in the middle of the stream * for formats like pcapng. */ get littleEndian(): boolean; set littleEndian(value: boolean); /** * Current read position in bytes from the original start of the stream. */ get offset(): number; /** * Wait for a number of bytes to be available to read immediately from the * stream. * * @param size Number of bytes. * @returns Promise that is rejected if stream is closed without enough data. */ waitFor(size: number): Promise; /** * Fully read a number of bytes from the stream. * * @param size Number of bytes. * @returns Promise that is rejected if stream is closed without enough data. */ bytes(size: number): Promise; /** * Peek at some bytes at the front of the queue. This will cut the buffers * in the queue up, so it's likely to be slightly less performant than * reading chunks of the correct size, unless you're going to read this * exact size again next. * * @param size Number of bytes to peek at. * @returns Promise fulfilled with array of the expected size. */ peek(size: number): Promise; /** * Wait for an unsigned byte to be available in the stream. * * @returns Promise that is rejected if stream is closed without enough data. */ u8(): Promise; /** * Wait for an unsigned short integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ u16(littleEndian?: boolean): Promise; /** * Wait for an unsigned integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ u32(littleEndian?: boolean): Promise; /** * Wait for an unsigned long integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ u64(littleEndian?: boolean): Promise; /** * Wait for an signed byte to be available in the stream. * * @returns Promise that is rejected if stream is closed without enough data. */ i8(): Promise; /** * Wait for an signed short integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ i16(littleEndian?: boolean): Promise; /** * Wait for an signed integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ i32(littleEndian?: boolean): Promise; /** * Wait for an signed long integer to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ i64(littleEndian?: boolean): Promise; /** * Wait for a short float to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ f16(littleEndian?: boolean): Promise; /** * Wait for a float to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ f32(littleEndian?: boolean): Promise; /** * Wait for a double to be available in the stream. * * @param littleEndian Override th endianness of the stream for a single read. * @returns Promise that is rejected if stream is closed without enough data. */ f64(littleEndian?: boolean): Promise; /** * Wait for an ASCII string of a given size (in bytes) to be available in the * stream. Decoding turns each byte into a single JS character directly, * which may not be exactly what you want for characters over 127. * * @param length Number of bytes to read. * @returns Promise that is rejected if stream is closed without enough data. */ ascii(length: number): Promise; /** * Wait for a UTF8-encoded string of a given size (in bytes) to be available * in the stream. * * @param length Number of bytes to read. * @returns Promise that is rejected if stream is closed without enough * data. */ utf8(length: number): Promise; /** * Wait for an entire packet structure at once. Only useful for relatively- * simplistic structures. If all of the fields have known size, the length * is not required. * * @param description Field descriptions, in the order you want them read. * @param length Number of bytes, if needed. * @returns This, for chaining. */ struct(description: T, length?: number): Promise>; } //#endregion export { DataViewWritableStream, DataViewWritableStreamOptions };