UNPKG

gherkin-ast

Version:

JS model for Gherkin feature files

37 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Comment = void 0; const common_1 = require("../common"); const uniqueObject_1 = require("./uniqueObject"); const debug_1 = require("../debug"); const debug = (0, debug_1.getDebugger)("Comment"); class Comment extends uniqueObject_1.UniqueObject { static parse(...objs) { debug("parse(objs: %d)", objs.length); if (!objs.length || objs.some(o => !o.text)) { throw new TypeError("The given object is not a Comment!"); } const comment = new Comment(objs.map(o => o.text).join("\n")); debug("parse(this: {text: '%s'})", comment.text); return comment; } constructor(text) { super(); debug("constructor(text: '%s')", text); this.text = (0, common_1.prefixString)((0, common_1.normalizeString)(text), "#"); } clone() { debug("clone()"); return new Comment(this.text); } replace(key, value) { debug("replace(key: '%s', value: '%s')", key, value); this.text = (0, common_1.replaceAll)(this.text, key, value); } toString() { debug('toString()'); return this.text; } } exports.Comment = Comment; //# sourceMappingURL=comment.js.map