@ayonli/jsext
Version:
A JavaScript extension package for building strong and modern applications.
26 lines (25 loc) • 1.26 kB
TypeScript
declare global {
interface Uint8ArrayConstructor {
/** Copies bytes from `src` array to `dest` and returns the number of bytes copied. */
copy(src: Uint8Array, dest: Uint8Array): number;
/** Like `Buffer.concat` but for native `Uint8Array`. */
concat<T extends Uint8Array>(...arrays: T[]): T;
/** Like `Buffer.compare` but for native `Uint8Array`. */
compare(arr1: Uint8Array, arr2: Uint8Array): -1 | 0 | 1;
}
interface Uint8Array {
/** Checks if the two byte arrays are equal to each other. */
equals(another: Uint8Array): boolean;
/** Checks if the byte array contains another array as a slice of its contents. */
includesSlice(subset: Uint8Array): boolean;
/** Checks if the byte array starts with the given prefix. */
startsWith(prefix: Uint8Array): boolean;
/** Checks if the byte array ends with the given suffix. */
endsWith(suffix: Uint8Array): boolean;
/** Breaks the byte array into smaller chunks according to the given delimiter. */
split(delimiter: number): this[];
/** Breaks the byte array into smaller chunks according to the given length. */
chunk(length: number): this[];
}
}
export {};