* Converts %%value%% to a Big Endian Uint8Array.
(_value)
| 192 | * Converts %%value%% to a Big Endian Uint8Array. |
| 193 | */ |
| 194 | function toBeArray(_value) { |
| 195 | const value = getUint(_value, "value"); |
| 196 | if (value === BN_0) { |
| 197 | return new Uint8Array([]); |
| 198 | } |
| 199 | let hex = value.toString(16); |
| 200 | if (hex.length % 2) { |
| 201 | hex = "0" + hex; |
| 202 | } |
| 203 | const result = new Uint8Array(hex.length / 2); |
| 204 | for (let i = 0; i < result.length; i++) { |
| 205 | const offset = i * 2; |
| 206 | result[i] = parseInt(hex.substring(offset, offset + 2), 16); |
| 207 | } |
| 208 | return result; |
| 209 | } |
| 210 | exports.toBeArray = toBeArray; |
| 211 | /** |
| 212 | * Returns a [[HexString]] for %%value%% safe to use as a //Quantity//. |
no test coverage detected