UNPKG

@iotize/device-client.js

Version:

IoTize Device client for Javascript

137 lines (136 loc) 5.47 kB
export declare type StreamBufferType = ArrayBufferLike | DataView; export declare abstract class KaitaiStream { protected _byteOffset: number; protected _buffer: ArrayBuffer; protected _dataView: DataView; protected _pos: number; /** * Number of bits left (when read bit by bit instead of bytes) */ bitsLeft: number; bits: number; /** Virtual byte length of the KaitaiStream backing buffer. Updated to be max of original buffer size and last written size. If dynamicSize is false is set to buffer size. @type {number} */ _byteLength: number; static iconvlite: any; static zlib: any; /** Dependency configuration data. Holds urls for (optional) dynamic loading of code dependencies from a remote server. For use by (static) processing functions. Caller should the supported keys to the asset urls as needed. NOTE: `depUrls` is a static property of KaitaiStream (the factory),like the various processing functions. It is NOT part of the prototype of instances. @type {Object} */ static depUrls: { zlib: undefined; }; /** Native endianness. Either KaitaiStream.BIG_ENDIAN or KaitaiStream.LITTLE_ENDIAN depending on the platform endianness. @type {boolean} */ static endianness: boolean; _isBigEndian: boolean; /** KaitaiStream is an implementation of Kaitai Struct API for JavaScript. Based on DataStream - https://github.com/kig/DataStream.js @param {ArrayBuffer} arrayBuffer ArrayBuffer to read from. @param {?Number} byteOffset Offset from arrayBuffer beginning for the KaitaiStream. */ constructor(arrayBuffer?: StreamBufferType, byteOffset?: number, isBigEndian?: boolean); readonly byteLeft: number; pos: number; getStreamSize(): number; alignToByte(): void; /** Set/get the backing ArrayBuffer of the KaitaiStream object. The setter updates the DataView to point to the new buffer. @type {Object} */ buffer: ArrayBuffer; readonly toBytes: Uint8Array; readonly isBigEndian: boolean; readonly isLittleEndian: boolean; /** Set/get the byteOffset of the KaitaiStream object. The setter updates the DataView to point to the new byteOffset. @type {number} */ byteOffset: number; /** Set/get the backing DataView of the KaitaiStream object. The setter updates the buffer and byteOffset to point to the DataView values. @type {Object} */ dataView: DataView; /** Internal function to trim the KaitaiStream buffer when required. Used for stripping out the extra bytes from the backing buffer when the virtual byteLength is smaller than the buffer byteLength (happens after growing the buffer with writes and not filling the extra space completely). @return {null} */ _trimAlloc(): void; static bytesStripRight(data: Uint8Array, padByte: number): Uint8Array; static bytesTerminate(data: Uint8Array, term: number, include?: boolean): Uint8Array; static bytesToStr(arr: Uint8Array, encoding: string): string; /** Returns true if the KaitaiStream seek pointer is at the end of buffer and there's no more data to read. @return {boolean} True if the seek pointer is at the end of the buffer. */ isEof(): boolean; forward(relativePosition: number): this; /** Sets the KaitaiStream read/write position to given position. Clamps between 0 and KaitaiStream length. @param {number} pos Position to seek to. @return {null} */ seek(pos: number): void; /** Returns the byte length of the KaitaiStream object. @type {number} */ readonly size: number; static mod(a: number, b: number): number; static arrayMin(arr: Uint8Array): number; static arrayMax(arr: Uint8Array): number; static byteArrayCompare(a: Uint8Array, b: Uint8Array): number; /** Creates an array from an array of character codes. Uses String.fromCharCode in chunks for memory efficiency and then concatenates the resulting string chunks. @param {array} array Array of character codes. @return {string} String created from the character codes. **/ static createStringFromArray(array: any): string; static processXorOne(data: Uint8Array, key: number): Uint8Array; static processXorMany(data: Uint8Array, key: Uint8Array): Uint8Array; static processRotateLeft(data: Uint8Array, amount: number, groupSize: number): Uint8Array; /** Maps a Uint8Array into the KaitaiStream buffer. Nice for quickly reading in data. @param {number} length Number of elements to map. @return {Object} Uint8Array to the KaitaiStream backing buffer. */ mapUint8Array(length: number): Uint8Array; } export declare class EOFError extends Error { bytesReq: number; bytesAvail: number; constructor(bytesReq: number, bytesAvail: number); } export declare class UnexpectedDataError extends Error { expected: Uint8Array; actual: Uint8Array; constructor(expected: Uint8Array, actual: Uint8Array); } export declare class UndecidedEndiannessError extends Error { constructor(); }