@lodestar/utils
Version:
Utilities required across multiple lodestar packages
22 lines • 1.19 kB
TypeScript
export declare function toHex(buffer: Uint8Array | Parameters<typeof Buffer.from>[0]): string;
/**
* Convert a Uint8Array, length 32, to 0x-prefixed hex string
*/
export declare function toRootHex(root: Uint8Array): string;
export declare function toPubkeyHex(pubkey: Uint8Array): string;
export declare function fromHex(hex: string): Uint8Array;
/**
* Compare two byte arrays for equality using the most performant method based on size.
*
* Node v24.13.0 benchmark results:
* - 32 bytes: Loop 14.7 ns/op vs Buffer.compare 49.7 ns/op (Loop 3.4x faster)
* - 48 bytes: Loop 36 ns/op vs Buffer.compare 56 ns/op (Loop 1.5x faster)
* - 96 bytes: Loop 130 ns/op vs Buffer.compare 50 ns/op (Buffer 2.6x faster)
* - 1024 bytes: Loop 940 ns/op vs Buffer.compare 55 ns/op (Buffer 17x faster)
*
* Uses loop for small arrays (<=48 bytes) where V8 JIT is more efficient,
* and Buffer.compare for larger arrays where native code wins.
*/
export declare function byteArrayEquals(a: Uint8Array, b: Uint8Array): boolean;
export { bigIntToBytes, bitCount, bytesToBigInt, bytesToInt, fromHexInto, intToBytes, toHexString, xor, } from "./browser.js";
//# sourceMappingURL=nodejs.d.ts.map