All files / src/codec/ber/decoder misc.ts

80% Statements 8/10
60% Branches 3/5
100% Functions 2/2
80% Lines 8/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x   1x 64x   38x   5x   21x               1x 64x    
import {TagClass} from '../../../interfaces/TagClass';
 
export function getTagClass(octet: number): TagClass {
  switch (octet >> 6) {
    case 0:
      return TagClass.UNIVERSAL;
    case 1:
      return TagClass.APPLICATION;
    case 2:
      return TagClass.CONTEXT_SPECIFIC;
    case 3:
      return TagClass.PRIVATE;
    default:
      throw new Error('octet should be < 128');
  }
}
 
export function isConstructed(octet: number): boolean {
  return (octet & 0b0010_0000) > 0;
}