1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-04 01:59:15 +02:00

Update Typescript types for 1.1.0

This commit is contained in:
Jeff Schiller 2023-05-28 10:50:31 -07:00
parent 63e84dadb0
commit 3120bba0df
12 changed files with 388 additions and 242 deletions

39
types/archive/decompress.d.ts vendored Normal file
View file

@ -0,0 +1,39 @@
/**
* Factory method that creates an unarchiver based on the byte signature found
* in the arrayBuffer.
* @param {ArrayBuffer} ab The ArrayBuffer to unarchive. Note that this ArrayBuffer
* must not be referenced after calling this method, as the ArrayBuffer is marked
* as Transferable and sent to a Worker thread once start() is called.
* @param {Object|string} options An optional object of options, or a string
* representing where the path to the unarchiver script files.
* @returns {Unarchiver}
*/
export function getUnarchiver(ab: ArrayBuffer, options?: any | string): Unarchiver;
export class Unzipper extends UnzipperInternal {
constructor(ab: any, options: any);
}
export class Unrarrer extends UnrarrerInternal {
constructor(ab: any, options: any);
}
export class Untarrer extends UntarrerInternal {
constructor(ab: any, options: any);
}
export type UnarchivedFile = {
filename: string;
fileData: Uint8Array;
};
import { Unarchiver } from "./decompress-internal.js";
import { UnarchiveAppendEvent } from "./decompress-internal.js";
import { UnarchiveErrorEvent } from "./decompress-internal.js";
import { UnarchiveEvent } from "./decompress-internal.js";
import { UnarchiveEventType } from "./decompress-internal.js";
import { UnarchiveExtractEvent } from "./decompress-internal.js";
import { UnarchiveFinishEvent } from "./decompress-internal.js";
import { UnarchiveInfoEvent } from "./decompress-internal.js";
import { UnarchiveProgressEvent } from "./decompress-internal.js";
import { UnarchiveStartEvent } from "./decompress-internal.js";
import { UnzipperInternal } from "./decompress-internal.js";
import { UnrarrerInternal } from "./decompress-internal.js";
import { UntarrerInternal } from "./decompress-internal.js";
export { UnarchiveAppendEvent, UnarchiveErrorEvent, UnarchiveEvent, UnarchiveEventType, UnarchiveExtractEvent, UnarchiveFinishEvent, UnarchiveInfoEvent, UnarchiveProgressEvent, UnarchiveStartEvent, Unarchiver };
//# sourceMappingURL=decompress.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../archive/decompress.js"],"names":[],"mappings":"AAuEA;;;;;;;;;EASE;AACF,kCAPU,WAAW,YAGX,MAAO,MAAM,GAEX,UAAU,CAIrB;AAxBD;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;AAED;IACE,mCAAgE;CACjE;;cAjCa,MAAM;cACN,UAAU"}

3
types/index.d.ts vendored
View file

@ -1,11 +1,12 @@
export { findMimeType } from "./file/sniffer.js";
export { BitBuffer } from "./io/bitbuffer.js";
export { BitStream } from "./io/bitstream.js";
export { ByteBuffer } from "./io/bytebuffer.js";
export { ByteStream } from "./io/bytestream.js";
export type ProbeStream = import('./codecs/codecs.js').ProbeStream;
export type ProbeFormat = import('./codecs/codecs.js').ProbeFormat;
export type ProbeInfo = import('./codecs/codecs.js').ProbeInfo;
export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/archive.js";
export { UnarchiveEvent, UnarchiveEventType, UnarchiveInfoEvent, UnarchiveErrorEvent, UnarchiveStartEvent, UnarchiveFinishEvent, UnarchiveProgressEvent, UnarchiveExtractEvent, Unarchiver, Unzipper, Unrarrer, Untarrer, getUnarchiver } from "./archive/decompress.js";
export { getFullMIMEString, getShortMIMEString } from "./codecs/codecs.js";
export { convertWebPtoPNG, convertWebPtoJPG } from "./image/webp-shim/webp-shim.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";;;;0BASa,OAAO,oBAAoB,EAAE,WAAW;0BAGxC,OAAO,oBAAoB,EAAE,WAAW;wBAGxC,OAAO,oBAAoB,EAAE,SAAS"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";;;;;0BASa,OAAO,oBAAoB,EAAE,WAAW;0BAGxC,OAAO,oBAAoB,EAAE,WAAW;wBAGxC,OAAO,oBAAoB,EAAE,SAAS"}

55
types/io/bitbuffer.d.ts vendored Normal file
View file

@ -0,0 +1,55 @@
/**
* A write-only Bit buffer which uses a Uint8Array as a backing store.
*/
export class BitBuffer {
/**
* @param {number} numBytes The number of bytes to allocate.
* @param {boolean} mtl The bit-packing mode. True means pack bits from most-significant (7) to
* least-significant (0). Defaults false: least-significant (0) to most-significant (8).
*/
constructor(numBytes: number, mtl?: boolean);
/**
* @type {Uint8Array}
* @public
*/
public data: Uint8Array;
/**
* Whether we pack bits from most-significant-bit to least. Defaults false (least-to-most
* significant bit packing).
* @type {boolean}
* @private
*/
private mtl;
/**
* The current byte we are filling with bits.
* @type {number}
* @public
*/
public bytePtr: number;
/**
* Points at the bit within the current byte where the next bit will go. This number ranges
* from 0 to 7 and the direction of packing is indicated by the mtl property.
* @type {number}
* @public
*/
public bitPtr: number;
/** @returns {boolean} */
getPackingDirection(): boolean;
/**
* Sets the bit-packing direction. Default (false) is least-significant-bit (0) to
* most-significant (7). Changing the bit-packing direction when the bit pointer is in the
* middle of a byte will fill the rest of that byte with 0s using the current bit-packing
* direction and then set the bit pointer to the appropriate bit of the next byte. If there
* are no more bytes left in this buffer, it will throw an error.
*/
setPackingDirection(mtl?: boolean): void;
/**
* writeBits(3, 6) is the same as writeBits(0b000011, 6).
* Will throw an error (without writing) if this would over-flow the buffer.
* @param {number} val The bits to pack into the buffer. Negative values are not allowed.
* @param {number} numBits Must be positive, non-zero and less or equal to than 53, since
* JavaScript can only support 53-bit integers.
*/
writeBits(val: number, numBits: number): void;
}
//# sourceMappingURL=bitbuffer.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bitbuffer.d.ts","sourceRoot":"","sources":["../../io/bitbuffer.js"],"names":[],"mappings":"AAuBA;;GAEG;AACH;IACE;;;;OAIG;IACH,sBAJW,MAAM,QACN,OAAO,EAoCjB;IA5BC;;;OAGG;IACH,aAHU,UAAU,CAGgB;IAEpC;;;;;OAKG;IACH,YAAc;IAEd;;;;OAIG;IACH,gBAHU,MAAM,CAGA;IAEhB;;;;;OAKG;IACH,eAHU,MAAM,CAGc;IAGhC,yBAAyB;IACzB,uBADc,OAAO,CAGpB;IAED;;;;;;OAMG;IACH,yCAkBC;IAED;;;;;;OAMG;IACH,eAJW,MAAM,WACN,MAAM,QA4FhB;CACF"}

View file

@ -1,90 +1,125 @@
export const BitStream: {
new (ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number): {
/**
* The bytes in the stream.
* @type {Uint8Array}
* @private
*/
bytes: Uint8Array;
/**
* The byte in the stream that we are currently on.
* @type {Number}
* @private
*/
bytePtr: number;
/**
* The bit in the current byte that we will read next (can have values 0 through 7).
* @type {Number}
* @private
*/
bitPtr: number;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
bitsRead_: number;
peekBits: (n: number, opt_movePointers: any) => number;
/**
* Returns how many bites have been read in the stream since the beginning of time.
* @returns {number}
*/
getNumBitsRead(): number;
/**
* Returns how many bits are currently in the stream left to be read.
* @returns {number}
*/
getNumBitsLeft(): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at least-significant bit (0) of byte0 and moves left until it reaches
* bit7 of byte0, then jumps to bit0 of byte1, etc.
* @param {number} n The number of bits to peek, must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_ltm(n: number, opt_movePointers: any): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at bit7 of byte0 and moves right until it reaches
* bit0 of byte0, then goes to bit7 of byte1, etc.
* @param {number} n The number of bits to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_mtl(n: number, opt_movePointers: any): number;
/**
* Peek at 16 bits from current position in the buffer.
* Bit at (bytePtr,bitPtr) has the highest position in returning data.
* Taken from getbits.hpp in unrar.
* TODO: Move this out of BitStream and into unrar.
* @returns {number}
*/
getBits(): number;
/**
* Reads n bits out of the stream, consuming them (moving the bit pointer).
* @param {number} n The number of bits to read. Must be a positive integer.
* @returns {number} The read bits, as an unsigned number.
*/
readBits(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true. Only use this for uncompressed blocks as this throws away remaining
* bits in the current byte.
* @param {number} n The number of bytes to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, opt_movePointers: any): Uint8Array;
/**
* @param {number} n The number of bytes to read.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
};
};
/**
* This object allows you to peek and consume bits and bytes out of a stream.
* Note that this stream is optimized, and thus, will *NOT* throw an error if
* the end of the stream is reached. Only use this in scenarios where you
* already have all the bits you need.
*
* Bit reading always proceeds from the first byte in the buffer, to the
* second byte, and so on. The MTL flag controls which bit is considered
* first *inside* the byte.
*
* An Example for how Most-To-Least vs Least-to-Most mode works:
*
* If you have an ArrayBuffer with the following two Uint8s:
* 185 (0b10111001) and 66 (0b01000010)
* and you perform a series of readBits: 2 bits, then 3, then 5, then 6.
*
* A BitStream in "mtl" mode will yield the following:
* - readBits(2) => 2 ('10')
* - readBits(3) => 7 ('111')
* - readBits(5) => 5 ('00101')
* - readBits(6) => 2 ('000010')
*
* A BitStream in "ltm" mode will yield the following:
* - readBits(2) => 1 ('01')
* - readBits(3) => 6 ('110')
* - readBits(5) => 21 ('10101')
* - readBits(6) => 16 ('010000')
*/
export class BitStream {
/**
* @param {ArrayBuffer} ab An ArrayBuffer object or a Uint8Array.
* @param {boolean} mtl Whether the stream reads bits from the byte starting with the
* most-significant-bit (bit 7) to least-significant (bit 0). False means the direction is
* from least-significant-bit (bit 0) to most-significant (bit 7).
* @param {Number} opt_offset The offset into the ArrayBuffer
* @param {Number} opt_length The length of this BitStream
*/
constructor(ab: ArrayBuffer, mtl: boolean, opt_offset: number, opt_length: number);
/**
* The bytes in the stream.
* @type {Uint8Array}
* @private
*/
private bytes;
/**
* The byte in the stream that we are currently on.
* @type {Number}
* @private
*/
private bytePtr;
/**
* The bit in the current byte that we will read next (can have values 0 through 7).
* @type {Number}
* @private
*/
private bitPtr;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
private bitsRead_;
peekBits: (n: number, opt_movePointers: any) => number;
/**
* Returns how many bites have been read in the stream since the beginning of time.
* @returns {number}
*/
getNumBitsRead(): number;
/**
* Returns how many bits are currently in the stream left to be read.
* @returns {number}
*/
getNumBitsLeft(): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at least-significant bit (0) of byte0 and moves left until it reaches
* bit7 of byte0, then jumps to bit0 of byte1, etc.
* @param {number} n The number of bits to peek, must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_ltm(n: number, opt_movePointers: any): number;
/**
* byte0 byte1 byte2 byte3
* 7......0 | 7......0 | 7......0 | 7......0
*
* The bit pointer starts at bit7 of byte0 and moves right until it reaches
* bit0 of byte0, then goes to bit7 of byte1, etc.
* @param {number} n The number of bits to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {number} The peeked bits, as an unsigned number.
*/
peekBits_mtl(n: number, opt_movePointers: any): number;
/**
* Peek at 16 bits from current position in the buffer.
* Bit at (bytePtr,bitPtr) has the highest position in returning data.
* Taken from getbits.hpp in unrar.
* TODO: Move this out of BitStream and into unrar.
* @returns {number}
*/
getBits(): number;
/**
* Reads n bits out of the stream, consuming them (moving the bit pointer).
* @param {number} n The number of bits to read. Must be a positive integer.
* @returns {number} The read bits, as an unsigned number.
*/
readBits(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true. Only use this for uncompressed blocks as this throws away remaining
* bits in the current byte.
* @param {number} n The number of bytes to peek. Must be a positive integer.
* @param {boolean=} movePointers Whether to move the pointer, defaults false.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, opt_movePointers: any): Uint8Array;
/**
* @param {number} n The number of bytes to read.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
}
//# sourceMappingURL=bitstream.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bitstream.d.ts","sourceRoot":"","sources":["../../io/bitstream.js"],"names":[],"mappings":"AACA;aA8Ce,WAAW,OACX,OAAO;QAchB;;;;WAIG;eAFO,UAAU;QAKpB;;;;WAIG;;QAGH;;;;WAIG;;QAGH;;;;WAIG;;sBAuFM,MAAM,4BAEJ,MAAM;QAnFnB;;;WAGG;0BADU,MAAM;QAMnB;;;WAGG;0BADU,MAAM;QAOnB;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAkDnB;;;;;;;;;WASG;wBAHQ,MAAM,0BAEJ,MAAM;QAgDnB;;;;;;WAMG;mBADU,MAAM;QAQnB;;;;WAIG;oBAFQ,MAAM,GACJ,MAAM;QAMnB;;;;;;;WAOG;qBAHQ,MAAM,0BAEJ,UAAU;QAmDvB;;;WAGG;qBAFQ,MAAM,GACJ,UAAU;;EAQtB"}
{"version":3,"file":"bitstream.d.ts","sourceRoot":"","sources":["../../io/bitstream.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACE;;;;;;;OAOG;IACH,gBAPW,WAAW,OACX,OAAO,0CA2CjB;IA7BC;;;;OAIG;IACH,cAA+C;IAE/C;;;;OAIG;IACH,gBAAgB;IAEhB;;;;OAIG;IACH,eAAe;IAEf;;;;OAIG;IACH,kBAAkB;IAElB,cAoFS,MAAM,4BAEJ,MAAM,CAtF0C;IAG7D;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAKlB;IAED;;;;;;;;;OASG;IACH,gBAJW,MAAM,0BAEJ,MAAM,CAgDlB;IAED;;;;;;;;;OASG;IACH,gBAJW,MAAM,0BAEJ,MAAM,CA8ClB;IAED;;;;;;OAMG;IACH,WAFa,MAAM,CAMlB;IAED;;;;OAIG;IACH,YAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aAJW,MAAM,0BAEJ,UAAU,CAiDtB;IAED;;;OAGG;IACH,aAHW,MAAM,GACJ,UAAU,CAItB;CACF"}

View file

@ -1,41 +1,46 @@
export const ByteBuffer: {
new (numBytes: number): {
/**
* @type {Uint8Array}
* @public
*/
data: Uint8Array;
/**
* @type {number}
* @public
*/
ptr: number;
/**
* @param {number} b The byte to insert.
*/
insertByte(b: number): void;
/**
* @param {Array.<number>|Uint8Array|Int8Array} bytes The bytes to insert.
*/
insertBytes(bytes: Array<number> | Uint8Array | Int8Array): void;
/**
* Writes an unsigned number into the next n bytes. If the number is too large
* to fit into n bytes or is negative, an error is thrown.
* @param {number} num The unsigned number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeNumber(num: number, numBytes: number): void;
/**
* Writes a signed number into the next n bytes. If the number is too large
* to fit into n bytes, an error is thrown.
* @param {number} num The signed number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeSignedNumber(num: number, numBytes: number): void;
/**
* @param {string} str The ASCII string to write.
*/
writeASCIIString(str: string): void;
};
};
/**
* A write-only Byte buffer which uses a Uint8 Typed Array as a backing store.
*/
export class ByteBuffer {
/**
* @param {number} numBytes The number of bytes to allocate.
*/
constructor(numBytes: number);
/**
* @type {Uint8Array}
* @public
*/
public data: Uint8Array;
/**
* @type {number}
* @public
*/
public ptr: number;
/**
* @param {number} b The byte to insert.
*/
insertByte(b: number): void;
/**
* @param {Array.<number>|Uint8Array|Int8Array} bytes The bytes to insert.
*/
insertBytes(bytes: Array<number> | Uint8Array | Int8Array): void;
/**
* Writes an unsigned number into the next n bytes. If the number is too large
* to fit into n bytes or is negative, an error is thrown.
* @param {number} num The unsigned number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeNumber(num: number, numBytes: number): void;
/**
* Writes a signed number into the next n bytes. If the number is too large
* to fit into n bytes, an error is thrown.
* @param {number} num The signed number to write.
* @param {number} numBytes The number of bytes to write the number into.
*/
writeSignedNumber(num: number, numBytes: number): void;
/**
* @param {string} str The ASCII string to write.
*/
writeASCIIString(str: string): void;
}
//# sourceMappingURL=bytebuffer.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bytebuffer.d.ts","sourceRoot":"","sources":["../../io/bytebuffer.js"],"names":[],"mappings":"AACA;mBAkBe,MAAM;QAOf;;;WAGG;cAFO,UAAU;QAKpB;;;WAGG;aAFO,MAAM;QAOlB;;WAEG;sBADQ,MAAM;QAOjB;;WAEG;2BADQ,MAAO,MAAM,CAAC,GAAC,UAAU,GAAC,SAAS;QAQ9C;;;;;WAKG;yBAFQ,MAAM,YACN,MAAM;QAyBjB;;;;;WAKG;+BAFQ,MAAM,YACN,MAAM;QAuBjB;;WAEG;8BADQ,MAAM;;EAchB"}
{"version":3,"file":"bytebuffer.d.ts","sourceRoot":"","sources":["../../io/bytebuffer.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE;;OAEG;IACH,sBAFW,MAAM,EAkBhB;IAXC;;;OAGG;IACH,aAHU,UAAU,CAGgB;IAEpC;;;OAGG;IACH,YAHU,MAAM,CAGJ;IAId;;OAEG;IACH,cAFW,MAAM,QAKhB;IAED;;OAEG;IACH,mBAFW,MAAO,MAAM,CAAC,GAAC,UAAU,GAAC,SAAS,QAM7C;IAED;;;;;OAKG;IACH,iBAHW,MAAM,YACN,MAAM,QAuBhB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,YACN,MAAM,QAqBhB;IAED;;OAEG;IACH,sBAFW,MAAM,QAUhB;CACF"}

View file

@ -1,109 +1,118 @@
export const ByteStream: {
new (ab: ArrayBuffer, opt_offset?: number | undefined, opt_length?: number | undefined): {
/**
* The current page of bytes in the stream.
* @type {Uint8Array}
* @private
*/
bytes: Uint8Array;
/**
* The next pages of bytes in the stream.
* @type {Array<Uint8Array>}
* @private
*/
pages_: Array<Uint8Array>;
/**
* The byte in the current page that we will read next.
* @type {Number}
* @private
*/
ptr: number;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
bytesRead_: number;
/**
* Returns how many bytes have been read in the stream since the beginning of time.
*/
getNumBytesRead(): number;
/**
* Returns how many bytes are currently in the stream left to be read.
*/
getNumBytesLeft(): number;
/**
* Move the pointer ahead n bytes. If the pointer is at the end of the current array
* of bytes and we have another page of bytes, point at the new page. This is a private
* method, no validation is done.
* @param {number} n Number of bytes to increment.
* @private
*/
movePointer_(n: number): void;
/**
* Peeks at the next n bytes as an unsigned number but does not advance the
* pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
peekNumber(n: number): number;
/**
* Returns the next n bytes as an unsigned number (or -1 on error)
* and advances the stream pointer n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
readNumber(n: number): number;
/**
* Returns the next n bytes as a signed number but does not advance the
* pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
peekSignedNumber(n: number): number;
/**
* Returns the next n bytes as a signed number and advances the stream pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
readSignedNumber(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @param {boolean} movePointers Whether to move the pointers.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, movePointers: boolean): Uint8Array;
/**
* Reads the next n bytes as a sub-array.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
/**
* Peeks at the next n bytes as an ASCII string but does not advance the pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
peekString(n: number): string;
/**
* Returns the next n bytes as an ASCII string and advances the stream pointer
* n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
readString(n: number): string;
/**
* Feeds more bytes into the back of the stream.
* @param {ArrayBuffer} ab
*/
push(ab: ArrayBuffer): void;
/**
* Creates a new ByteStream from this ByteStream that can be read / peeked.
* @returns {ByteStream} A clone of this ByteStream.
*/
tee(): any;
};
};
/**
* This object allows you to peek and consume bytes as numbers and strings out
* of a stream. More bytes can be pushed into the back of the stream via the
* push() method.
*/
export class ByteStream {
/**
* @param {ArrayBuffer} ab The ArrayBuffer object.
* @param {number=} opt_offset The offset into the ArrayBuffer
* @param {number=} opt_length The length of this ByteStream
*/
constructor(ab: ArrayBuffer, opt_offset?: number | undefined, opt_length?: number | undefined);
/**
* The current page of bytes in the stream.
* @type {Uint8Array}
* @private
*/
private bytes;
/**
* The next pages of bytes in the stream.
* @type {Array<Uint8Array>}
* @private
*/
private pages_;
/**
* The byte in the current page that we will read next.
* @type {Number}
* @private
*/
private ptr;
/**
* An ever-increasing number.
* @type {Number}
* @private
*/
private bytesRead_;
/**
* Returns how many bytes have been read in the stream since the beginning of time.
*/
getNumBytesRead(): number;
/**
* Returns how many bytes are currently in the stream left to be read.
*/
getNumBytesLeft(): number;
/**
* Move the pointer ahead n bytes. If the pointer is at the end of the current array
* of bytes and we have another page of bytes, point at the new page. This is a private
* method, no validation is done.
* @param {number} n Number of bytes to increment.
* @private
*/
private movePointer_;
/**
* Peeks at the next n bytes as an unsigned number but does not advance the
* pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
peekNumber(n: number): number;
/**
* Returns the next n bytes as an unsigned number (or -1 on error)
* and advances the stream pointer n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The n bytes interpreted as an unsigned number.
*/
readNumber(n: number): number;
/**
* Returns the next n bytes as a signed number but does not advance the
* pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
peekSignedNumber(n: number): number;
/**
* Returns the next n bytes as a signed number and advances the stream pointer.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {number} The bytes interpreted as a signed number.
*/
readSignedNumber(n: number): number;
/**
* This returns n bytes as a sub-array, advancing the pointer if movePointers
* is true.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @param {boolean} movePointers Whether to move the pointers.
* @returns {Uint8Array} The subarray.
*/
peekBytes(n: number, movePointers: boolean): Uint8Array;
/**
* Reads the next n bytes as a sub-array.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {Uint8Array} The subarray.
*/
readBytes(n: number): Uint8Array;
/**
* Peeks at the next n bytes as an ASCII string but does not advance the pointer.
* @param {number} n The number of bytes to peek at. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
peekString(n: number): string;
/**
* Returns the next n bytes as an ASCII string and advances the stream pointer
* n bytes.
* @param {number} n The number of bytes to read. Must be a positive integer.
* @returns {string} The next n bytes as a string.
*/
readString(n: number): string;
/**
* Feeds more bytes into the back of the stream.
* @param {ArrayBuffer} ab
*/
push(ab: ArrayBuffer): void;
/**
* Creates a new ByteStream from this ByteStream that can be read / peeked.
* @returns {ByteStream} A clone of this ByteStream.
*/
tee(): ByteStream;
}
//# sourceMappingURL=bytestream.d.ts.map

View file

@ -1 +1 @@
{"version":3,"file":"bytestream.d.ts","sourceRoot":"","sources":["../../io/bytestream.js"],"names":[],"mappings":"AACA;aAoBe,WAAW,eACX,MAAM,2BACN,MAAM;QAUf;;;;WAIG;eAFO,UAAU;QAKpB;;;;WAIG;gBAFO,MAAM,UAAU,CAAC;QAK3B;;;;WAIG;;QAGH;;;;WAIG;;QAIL;;WAEG;;QAKH;;WAEG;;QAMH;;;;;;WAMG;wBAFQ,MAAM;QAYjB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QAqCnB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QASnB;;;;;WAKG;4BAFQ,MAAM,GACJ,MAAM;QAanB;;;;WAIG;4BAFQ,MAAM,GACJ,MAAM;QASnB;;;;;;WAMG;qBAHQ,MAAM,gBACN,OAAO,GACL,UAAU;QA2CvB;;;;WAIG;qBAFQ,MAAM,GACJ,UAAU;QAMvB;;;;WAIG;sBAFQ,MAAM,GACJ,MAAM;QA+BnB;;;;;WAKG;sBAFQ,MAAM,GACJ,MAAM;QAQnB;;;WAGG;iBADQ,WAAW;QAatB;;;WAGG;;;EAYF"}
{"version":3,"file":"bytestream.d.ts","sourceRoot":"","sources":["../../io/bytestream.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH;IACE;;;;OAIG;IACH,gBAJW,WAAW,eACX,MAAM,2BACN,MAAM,cAqChB;IA3BC;;;;OAIG;IACH,cAA+C;IAE/C;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,YAAY;IAEZ;;;;OAIG;IACH,mBAAmB;IAGrB;;OAEG;IACH,0BAEC;IAED;;OAEG;IACH,0BAGC;IAED;;;;;;OAMG;IACH,qBAOC;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,MAAM,CAkClB;IAGD;;;;;OAKG;IACH,cAHW,MAAM,GACJ,MAAM,CAMlB;IAGD;;;;;OAKG;IACH,oBAHW,MAAM,GACJ,MAAM,CAUlB;IAGD;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAMlB;IAGD;;;;;;OAMG;IACH,aAJW,MAAM,gBACN,OAAO,GACL,UAAU,CAyCtB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,UAAU,CAItB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,MAAM,CA6BlB;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;OAGG;IACH,SAFW,WAAW,QAWrB;IAED;;;OAGG;IACH,OAFa,UAAU,CAStB;CACF"}