(data: BytesLike, length: number, left: boolean)
| 152 | } |
| 153 | |
| 154 | function zeroPad(data: BytesLike, length: number, left: boolean): string { |
| 155 | const bytes = getBytes(data); |
| 156 | assert(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", { |
| 157 | buffer: new Uint8Array(bytes), |
| 158 | length: length, |
| 159 | offset: length + 1 |
| 160 | }); |
| 161 | |
| 162 | const result = new Uint8Array(length); |
| 163 | result.fill(0); |
| 164 | if (left) { |
| 165 | result.set(bytes, length - bytes.length); |
| 166 | } else { |
| 167 | result.set(bytes, 0); |
| 168 | } |
| 169 | |
| 170 | return hexlify(result); |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Return the [[DataHexString]] of %%data%% padded on the **left** |
no test coverage detected