UNPKG

@lodestar/utils

Version:

Utilities required across multiple lodestar packages

50 lines 1.78 kB
/** * Format bytes as `0x1234…1234` * 4 bytes can represent 4294967296 values, so the chance of collision is low */ export declare function prettyBytes(root: Uint8Array | string): string; /** * Format bytes as `0x1234…` * Paired with block numbers or slots, it can still act as a decent identify-able format */ export declare function prettyBytesShort(root: Uint8Array | string): string; /** * Truncate and format bytes as `0x123456789abc` * 6 bytes is sufficient to avoid collisions and it allows to easily look up * values on explorers like beaconcha.in while improving readability of logs */ export declare function truncBytes(root: Uint8Array | string): string; /** * Format a bigint value as a decimal string */ export declare function formatBigDecimal(numerator: bigint, denominator: bigint, maxDecimalFactor: bigint): string; /** * Format wei as ETH, with up to 5 decimals */ export declare function formatWeiToEth(wei: bigint): string; /** * Format wei as ETH, with up to 5 decimals and append ' ETH' */ export declare function prettyWeiToEth(wei: bigint): string; /** * Format milliseconds to time format HH:MM:SS.ms */ export declare function prettyMsToTime(timeMs: number): string; /** * Remove 0x prefix from a string */ export declare function strip0xPrefix(hex: string): string; export declare function groupSequentialIndices(indices: number[]): string[]; /** * Pretty print indices from an array of numbers. * * example: * ```ts * const indices = [1, 3, 109, 110, 111, 112, 113, 127]; * console.log(prettyPrintIndices(indices)); * // `1,3,110-113,127` * ``` */ export declare function prettyPrintIndices(indices: number[]): string; export declare function formatBytes(bytes: number): string; //# sourceMappingURL=format.d.ts.map