(input: Uint8Array, index: number)
| 27 | // CBOR item starting from the given index. Returns the length of the CBOR item |
| 28 | // in bytes. |
| 29 | function deterministicRec(input: Uint8Array, index: number): number { |
| 30 | const b = input[index]; |
| 31 | |
| 32 | switch (getMajorType(b)) { |
| 33 | case MajorType.PosInt: { |
| 34 | const { lengthInBytes } = unsignedIntegerDeterministic(input, index); |
| 35 | return lengthInBytes + 1; |
| 36 | } |
| 37 | case MajorType.ByteString: |
| 38 | case MajorType.Text: |
| 39 | return textOrByteStringDeterministic(input, index) + 1; |
| 40 | |
| 41 | case MajorType.Array: |
| 42 | return arrayDeterministic(input, index); |
| 43 | |
| 44 | case MajorType.Map: |
| 45 | return mapDeterministic(input, index); |
| 46 | |
| 47 | default: |
| 48 | throw new Error('Missing implementation for a major type.'); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // unsignedIntegerDeterministic calculates the value of the unsigned integer to ensure that |
| 53 | // the right amount of bytes is used in the CBOR encoding. It returns both, |
no test coverage detected