( input: Uint8Array, aI: number, offset: number, )
| 173 | } |
| 174 | |
| 175 | function decodeFour( |
| 176 | input: Uint8Array, |
| 177 | aI: number, |
| 178 | offset: number, |
| 179 | ): [CborType[], number] { |
| 180 | if (aI <= 27) { |
| 181 | const x = calcLength(input, aI, offset); |
| 182 | // Can safely assume `x[0] < 2 ** 53` as JavaScript doesn't support an `Array` being that large. |
| 183 | const length = Number(x[0]); |
| 184 | offset = x[1]; |
| 185 | const output: CborType[] = new Array(length); |
| 186 | for (let i = 0; i < length; ++i) { |
| 187 | const y = decode(input, offset); |
| 188 | output[i] = y[0]; |
| 189 | offset = y[1]; |
| 190 | } |
| 191 | return [output, offset]; |
| 192 | } |
| 193 | if (aI === 31) { |
| 194 | const output: CborType[] = []; |
| 195 | while (input[offset] !== 0b111_11111) { |
| 196 | const x = decode(input, offset); |
| 197 | output.push(x[0]); |
| 198 | offset = x[1]; |
| 199 | } |
| 200 | return [output, offset + 1]; |
| 201 | } |
| 202 | throw new RangeError( |
| 203 | `Cannot decode value (0b100_${aI.toString(2).padStart(5, "0")})`, |
| 204 | ); |
| 205 | } |
| 206 | |
| 207 | function decodeFive( |
| 208 | input: Uint8Array, |
no test coverage detected