UNPKG

approvals

Version:

Approval Tests Library - Capturing Human Intelligence

71 lines (70 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Options = void 0; const Namer_1 = require("../Namer"); class FileOptions { constructor(options) { this.options = options; } withFileExtention(extensionWithDot) { return this.options.modify("FileExtention", extensionWithDot); } getFileExtension() { return this.options.get("FileExtention", () => ".txt"); } } class Options { constructor() { this.fields = {}; } modify(key, value) { const next = new Options(); for (const key1 in this.fields) { next.fields[key1] = this.fields[key1]; } next.fields[key] = value; return next; } forFile() { return new FileOptions(this); } get(key, default1) { if (this.fields[key] == undefined) { return default1(); } return this.fields[key]; } withScrubber(scrubber) { return this.modify("Scrubber", scrubber); } getScrubber() { return this.get("Scrubber", () => (t) => t); } scrub(text) { const scrubber = this.getScrubber(); return scrubber(text); } withConfig(configModifier) { return this.modify("ConfigModifier", configModifier); } getConfig(config) { const modifier = this.get("ConfigModifier", () => (t) => t); return modifier(config); } withNamer(namer) { return this.modify("Namer", namer); } getNamer() { return this.get("Namer", () => new Namer_1.Namer("", "")); } withReporter(reporter) { const previousModifier = this.get("ConfigModifier", () => (t) => t); const previousModifierWithReporter = (c) => { c = previousModifier(c); c.reporters = [reporter]; return c; }; return this.withConfig(previousModifierWithReporter); } } exports.Options = Options;