1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.hexFixLength = void 0;
|
4 | const addPrefix_js_1 = require("./addPrefix.js");
|
5 | const stripPrefix_js_1 = require("./stripPrefix.js");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function hexFixLength(value, bitLength = -1, withPadding = false) {
|
23 | const strLength = Math.ceil(bitLength / 4);
|
24 | const hexLength = strLength + 2;
|
25 | return (0, addPrefix_js_1.hexAddPrefix)((bitLength === -1 || value.length === hexLength || (!withPadding && value.length < hexLength))
|
26 | ? (0, stripPrefix_js_1.hexStripPrefix)(value)
|
27 | : (value.length > hexLength)
|
28 | ? (0, stripPrefix_js_1.hexStripPrefix)(value).slice(-1 * strLength)
|
29 | : `${'0'.repeat(strLength)}${(0, stripPrefix_js_1.hexStripPrefix)(value)}`.slice(-1 * strLength));
|
30 | }
|
31 | exports.hexFixLength = hexFixLength;
|