1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isHex = exports.REGEX_HEX_NOPREFIX = exports.REGEX_HEX_PREFIXED = void 0;
|
4 | exports.REGEX_HEX_PREFIXED = /^0x[\da-fA-F]+$/;
|
5 | exports.REGEX_HEX_NOPREFIX = /^[\da-fA-F]+$/;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | function isHex(value, bitLength = -1, ignoreLength) {
|
22 | return (typeof value === 'string' && (value === '0x' ||
|
23 | exports.REGEX_HEX_PREFIXED.test(value))) && (bitLength === -1
|
24 | ? (ignoreLength || (value.length % 2 === 0))
|
25 | : (value.length === (2 + Math.ceil(bitLength / 4))));
|
26 | }
|
27 | exports.isHex = isHex;
|