gherkin-ast
Version:
JS model for Gherkin feature files
40 lines • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataTable = void 0;
const common_1 = require("../common");
const tableRow_1 = require("./tableRow");
const uniqueObject_1 = require("./uniqueObject");
const debug_1 = require("../debug");
const debug = (0, debug_1.getDebugger)("DataTable");
/**
* Model for DataTable
*/
class DataTable extends uniqueObject_1.UniqueObject {
static parse(obj, comments) {
var _a, _b;
debug("parse(obj: %o, comments: %d)", obj, (_a = comments === null || comments === void 0 ? void 0 : comments.comments) === null || _a === void 0 ? void 0 : _a.length);
if (!obj || !Array.isArray(obj.rows)) {
throw new Error("The given object is not a DataTable!");
}
const table = new DataTable();
table.rows = tableRow_1.TableRow.parseAll(obj.rows, comments);
debug("parse(this: {rows: %d})", (_b = table.rows) === null || _b === void 0 ? void 0 : _b.length);
return table;
}
constructor(rows = []) {
super();
this.rows = rows;
debug("constructor(rows: %d)", rows.length);
}
clone() {
var _a;
debug("clone(this: {rows: %d})", (_a = this.rows) === null || _a === void 0 ? void 0 : _a.length);
return new DataTable((0, common_1.cloneArray)(this.rows));
}
replace(key, value) {
debug("replace(key: '%s', value: '%s')", key, value);
(0, common_1.replaceArray)(this.rows, key, value);
}
}
exports.DataTable = DataTable;
//# sourceMappingURL=dataTable.js.map