d2lang-js
Version:
An unofficial interface for building D2 diagram files in javascript
19 lines (18 loc) • 511 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class D2Text {
constructor(property, text, format, pipes = 1) {
this.property = property;
this.text = text;
this.format = format;
this.pipes = pipes;
}
lines() {
let sep = "|".repeat(this.pipes);
return [`${this.property}:${sep}${this.format}`, ...this.text.split("\n"), sep];
}
toString() {
return this.lines().join("\n");
}
}
exports.default = D2Text;