UNPKG

2.32 kBTypeScriptView Raw
1/**
2 * Returns a `Boolean` on whether or not the a `String` starts with '0x'
3 * @param str the string input value
4 * @return a boolean if it is or is not hex prefixed
5 * @throws if the str input is not a string
6 */
7export declare function isHexPrefixed(str: string): boolean;
8/**
9 * Removes '0x' from a given `String` if present
10 * @param str the string value
11 * @returns the string without 0x prefix
12 */
13export declare const stripHexPrefix: (str: string) => string;
14/**
15 * Pads a `String` to have an even length
16 * @param value
17 * @return output
18 */
19export declare function padToEven(value: string): string;
20/**
21 * Get the binary size of a string
22 * @param str
23 * @returns the number of bytes contained within the string
24 */
25export declare function getBinarySize(str: string): number;
26/**
27 * Returns TRUE if the first specified array contains all elements
28 * from the second one. FALSE otherwise.
29 *
30 * @param superset
31 * @param subset
32 *
33 */
34export declare function arrayContainsArray(superset: unknown[], subset: unknown[], some?: boolean): boolean;
35/**
36 * Should be called to get ascii from its hex representation
37 *
38 * @param string in hex
39 * @returns ascii string representation of hex value
40 */
41export declare function toAscii(hex: string): string;
42/**
43 * Should be called to get hex representation (prefixed by 0x) of utf8 string
44 *
45 * @param string
46 * @param optional padding
47 * @returns hex representation of input string
48 */
49export declare function fromUtf8(stringValue: string): string;
50/**
51 * Should be called to get hex representation (prefixed by 0x) of ascii string
52 *
53 * @param string
54 * @param optional padding
55 * @returns hex representation of input string
56 */
57export declare function fromAscii(stringValue: string): string;
58/**
59 * Returns the keys from an array of objects.
60 * @example
61 * ```js
62 * getKeys([{a: '1', b: '2'}, {a: '3', b: '4'}], 'a') => ['1', '3']
63 *````
64 * @param params
65 * @param key
66 * @param allowEmpty
67 * @returns output just a simple array of output keys
68 */
69export declare function getKeys(params: Record<string, string>[], key: string, allowEmpty?: boolean): string[];
70/**
71 * Is the string a hex string.
72 *
73 * @param value
74 * @param length
75 * @returns output the string is a hex string
76 */
77export declare function isHexString(value: string, length?: number): boolean;