UNPKG

1.56 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Numberish } from './types';
3export declare const hexUtils: {
4 concat: typeof concat;
5 random: typeof random;
6 leftPad: typeof leftPad;
7 rightPad: typeof rightPad;
8 invert: typeof invert;
9 slice: typeof slice;
10 hash: typeof hash;
11 size: typeof size;
12 toHex: typeof toHex;
13 isHex: typeof isHex;
14};
15/**
16 * Concatenate all arguments as a hex string.
17 */
18declare function concat(...args: Array<string | number | Buffer>): string;
19/**
20 * Generate a random hex string.
21 */
22declare function random(_size?: number): string;
23/**
24 * Left-pad a hex number to a number of bytes.
25 */
26declare function leftPad(n: Numberish, _size?: number): string;
27/**
28 * Right-pad a hex number to a number of bytes.
29 */
30declare function rightPad(n: Numberish, _size?: number): string;
31/**
32 * Inverts a hex word.
33 */
34declare function invert(n: Numberish, _size?: number): string;
35/**
36 * Slices a hex number.
37 */
38declare function slice(n: Numberish, start: number, end?: number): string;
39/**
40 * Get the keccak hash of some data.
41 */
42declare function hash(n: Numberish | Buffer): string;
43/**
44 * Get the length, in bytes, of a hex string.
45 */
46declare function size(hex: string): number;
47/**
48 * Convert a string, a number, a Buffer, or a BigNumber into a hex string.
49 * Works with negative numbers, as well.
50 */
51declare function toHex(n: Numberish | Buffer, _size?: number): string;
52/**
53 * Check if a string is a hex string.
54 */
55declare function isHex(s: string): boolean;
56export {};
57//# sourceMappingURL=hex_utils.d.ts.map
\No newline at end of file