(data, length, left)
| 137 | } |
| 138 | exports.stripZerosLeft = stripZerosLeft; |
| 139 | function zeroPad(data, length, left) { |
| 140 | const bytes = getBytes(data); |
| 141 | (0, errors_js_1.assert)(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", { |
| 142 | buffer: new Uint8Array(bytes), |
| 143 | length: length, |
| 144 | offset: length + 1 |
| 145 | }); |
| 146 | const result = new Uint8Array(length); |
| 147 | result.fill(0); |
| 148 | if (left) { |
| 149 | result.set(bytes, length - bytes.length); |
| 150 | } |
| 151 | else { |
| 152 | result.set(bytes, 0); |
| 153 | } |
| 154 | return hexlify(result); |
| 155 | } |
| 156 | /** |
| 157 | * Return the [[DataHexString]] of %%data%% padded on the **left** |
| 158 | * to %%length%% bytes. |
no test coverage detected