All files / src/html Context.ts

100% Statements 8/8
0% Branches 0/1
100% Functions 5/5
100% Lines 7/7

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 26        384x       384x 384x 384x       212x       212x       10100x      
import { CyclicReferenceError } from '../errors/CyclicReferenceError.js';
 
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);
  }
}