# All files / src/html Context.ts

100% Statements 10/10
0% Branches 0/1
100% Functions 5/5
100% Lines 9/9

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
    21
    22
    23
    24
    25
    269x

    9x

    388x

    388x
    388x
    388x

    220x

    220x

    10100x

     import CyclicReferenceError from '../errors/CyclicReferenceError';

    export class Context {
      constructor(
        public cwf: string,
        /**
         * Array of cwfs file paths processed so far
         */
        public callStack: string[],
        public variables: Record<string, string>,
        public processingOptions: { omitFrontmatter?: boolean } = {},
      ) {}

      addCwfToCallstack(cwf: string) {
        this.callStack.push(cwf);
      }

      hasExceededMaxCallstackSize() {
        return this.callStack.length > CyclicReferenceError.MAX_RECURSIVE_DEPTH;
      }

      clone() {
        return new Context(this.cwf, this.callStack.map(cwf => cwf), this.variables, this.processingOptions);
      }
    }