(
bytes_: ByteArray,
opts: BytesToBoolOpts = {},
)
| 147 | * // true |
| 148 | */ |
| 149 | export function bytesToBool( |
| 150 | bytes_: ByteArray, |
| 151 | opts: BytesToBoolOpts = {}, |
| 152 | ): boolean { |
| 153 | let bytes = bytes_ |
| 154 | if (typeof opts.size !== 'undefined') { |
| 155 | assertSize(bytes, { size: opts.size }) |
| 156 | bytes = trim(bytes) |
| 157 | } |
| 158 | if (bytes.length > 1 || bytes[0] > 1) |
| 159 | throw new InvalidBytesBooleanError(bytes) |
| 160 | return Boolean(bytes[0]) |
| 161 | } |
| 162 | |
| 163 | export type BytesToNumberOpts = BytesToBigIntOpts |
| 164 |
no test coverage detected