UNPKG

@lodestar/utils

Version:

Utilities required across multiple lodestar packages

37 lines 1.63 kB
export declare function toHex(bytes: Uint8Array): string; /** * Convert a Uint8Array, length 32, to 0x-prefixed hex string */ export declare function toRootHex(root: Uint8Array): string; /** * Convert a Uint8Array, length 48, to 0x-prefixed hex string */ export declare function toPubkeyHex(pubkey: Uint8Array): string; export declare function fromHex(hex: string): Uint8Array; export declare function fromHexInto(hex: string, buffer: Uint8Array): void; type Endianness = "le" | "be"; /** * @deprecated Use toHex() instead. */ export declare function toHexString(bytes: Uint8Array): string; /** * Return a byte array from a number or BigInt */ export declare function intToBytes(value: bigint | number, length: number, endianness?: Endianness): Uint8Array; /** * Convert byte array in LE to integer. */ export declare function bytesToInt(value: Uint8Array, endianness?: Endianness): number; export declare function bigIntToBytes(value: bigint, length: number, endianness?: Endianness): Uint8Array; export declare function bytesToBigInt(value: Uint8Array, endianness?: Endianness): bigint; export declare function xor(a: Uint8Array, b: Uint8Array): Uint8Array; /** Count set bits in a Uint8Array without allocation (Brian Kernighan's algorithm) */ export declare function bitCount(arr: Uint8Array): number; /** * Compare two byte arrays for equality. * Note: In Node.js environment, the implementation in nodejs.ts uses Buffer.compare * which is significantly faster due to native code. */ export declare function byteArrayEquals(a: Uint8Array, b: Uint8Array): boolean; export {}; //# sourceMappingURL=browser.d.ts.map