@dfinity/candid
Version:
JavaScript and TypeScript library to work with candid interfaces
86 lines • 2.67 kB
TypeScript
/**
* Concatenate multiple Uint8Arrays.
* @param uint8Arrays The Uint8Arrays to concatenate.
*/
export declare function concat(...uint8Arrays: Uint8Array[]): Uint8Array;
/**
* A class that abstracts a pipe-like Uint8Array.
*/
export declare class PipeArrayBuffer {
/**
* The reading view. It's a sliding window as we read and write, pointing to the buffer.
* @private
*/
private _view;
/**
* Save a checkpoint of the reading view (for backtracking)
*/
save(): Uint8Array;
/**
* Restore a checkpoint of the reading view (for backtracking)
* @param checkPoint a previously saved checkpoint
*/
restore(checkPoint: Uint8Array): void;
/**
* The actual buffer containing the bytes.
* @private
*/
private _buffer;
/**
* Creates a new instance of a pipe
* @param buffer an optional buffer to start with
* @param length an optional amount of bytes to use for the length.
*/
constructor(buffer?: Uint8Array, length?: number);
get buffer(): Uint8Array;
get byteLength(): number;
/**
* Read `num` number of bytes from the front of the pipe.
* @param num The number of bytes to read.
*/
read(num: number): Uint8Array;
readUint8(): number | undefined;
/**
* Write a buffer to the end of the pipe.
* @param buf The bytes to write.
*/
write(buf: Uint8Array): void;
/**
* Whether or not there is more data to read from the buffer
*/
get end(): boolean;
/**
* Allocate a fixed amount of memory in the buffer. This does not affect the view.
* @param amount A number of bytes to add to the buffer.
*/
alloc(amount: number): void;
}
/**
* Returns a true Uint8Array from an ArrayBufferLike object.
* @param bufLike a buffer-like object
* @returns Uint8Array
*/
export declare function uint8FromBufLike(bufLike: ArrayBuffer | Uint8Array | DataView | ArrayBufferView | ArrayBufferLike | [number] | number[] | {
buffer: ArrayBuffer;
}): Uint8Array;
/**
*
* @param u1 uint8Array 1
* @param u2 uint8Array 2
* @returns number - negative if u1 < u2, positive if u1 > u2, 0 if u1 === u2
*/
export declare function compare(u1: Uint8Array, u2: Uint8Array): number;
/**
* Checks two uint8Arrays for equality.
* @param u1 uint8Array 1
* @param u2 uint8Array 2
* @returns boolean
*/
export declare function uint8Equals(u1: Uint8Array, u2: Uint8Array): boolean;
/**
* Helpers to convert a Uint8Array to a DataView.
* @param uint8 Uint8Array
* @returns DataView
*/
export declare function uint8ToDataView(uint8: Uint8Array): DataView;
//# sourceMappingURL=buffer.d.ts.map