(encodedBool: Uint8Array)
| 12 | } |
| 13 | |
| 14 | export function decodeBool(encodedBool: Uint8Array): boolean { |
| 15 | // Any encoding of 0 is false, else true |
| 16 | for (let i = 0; i < encodedBool.byteLength; i += 1) { |
| 17 | if (encodedBool[i] !== 0) { |
| 18 | // Can be negative zero |
| 19 | if (i === encodedBool.byteLength - 1 && encodedBool[i] === 0x80) return false; |
| 20 | return true; |
| 21 | } |
| 22 | } |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | export function encodeInt(int: bigint): Uint8Array { |
| 27 | return bigIntToVmNumber(int); |
no outgoing calls
no test coverage detected