All files / common/src/annotation/registry annotation.registry.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6

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    10x 74x   1093x       1093x 1x   1092x        
import { AnnotationRef } from '../annotation-ref';
 
export class AnnotationRegistry {
  private readonly annotations: Set<AnnotationRef['value']> = new Set();
  has(annotationRef: AnnotationRef): boolean {
    return this.annotations.has(annotationRef.toString());
  }
 
  register(annotationRef: AnnotationRef) {
    if (this.has(annotationRef)) {
      throw new Error(`Annotation "${annotationRef}" already exists`);
    } else {
      this.annotations.add(annotationRef.toString());
    }
  }
}