( input: Uint8Array, aI: number, offset: number, )
| 263 | } |
| 264 | |
| 265 | function decodeSix( |
| 266 | input: Uint8Array, |
| 267 | aI: number, |
| 268 | offset: number, |
| 269 | ): [Date | bigint | Map<CborType, CborType> | CborTag<CborType>, number] { |
| 270 | if (aI > 27) { |
| 271 | throw new RangeError( |
| 272 | `Cannot decode value (0b110_${aI.toString(2).padStart(5, "0")})`, |
| 273 | ); |
| 274 | } |
| 275 | const x = decodeZero(input, aI, offset); |
| 276 | switch (BigInt(x[0])) { |
| 277 | case 0n: { |
| 278 | const y = decode(input, x[1]); |
| 279 | if (typeof y[0] !== "string") { |
| 280 | throw new TypeError('Invalid TagItem: Expected a "text string"'); |
| 281 | } |
| 282 | return [new Date(y[0]), y[1]]; |
| 283 | } |
| 284 | case 1n: { |
| 285 | const y = decode(input, x[1]); |
| 286 | if (typeof y[0] !== "number" && typeof y[0] !== "bigint") { |
| 287 | throw new TypeError('Invalid TagItem: Expected a "integer" or "float"'); |
| 288 | } |
| 289 | return [new Date(Number(y[0]) * 1000), y[1]]; |
| 290 | } |
| 291 | case 2n: { |
| 292 | const y = decode(input, x[1]); |
| 293 | if (!(y[0] instanceof Uint8Array)) { |
| 294 | throw new TypeError('Invalid TagItem: Expected a "byte string"'); |
| 295 | } |
| 296 | let z = 0n; |
| 297 | for (const byte of y[0]) z = (z << 8n) | BigInt(byte); |
| 298 | return [z, y[1]]; |
| 299 | } |
| 300 | case 3n: { |
| 301 | const y = decode(input, x[1]); |
| 302 | if (!(y[0] instanceof Uint8Array)) { |
| 303 | throw new TypeError('Invalid TagItem: Expected a "byte string"'); |
| 304 | } |
| 305 | let z = 0n; |
| 306 | for (const byte of y[0]) z = (z << 8n) | BigInt(byte); |
| 307 | return [-z - 1n, y[1]]; |
| 308 | } |
| 309 | case 259n: |
| 310 | return decodeMap(input, x[1]); |
| 311 | default: { |
| 312 | const y = decode(input, x[1]); |
| 313 | return [new CborTag(x[0], y[0]), y[1]]; |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | function decodeSeven( |
| 319 | input: Uint8Array, |
no test coverage detected