UNPKG

@dooboostore/dom-render

Version:
36 lines 742 B
/** * Base compiler class */ export class Compiler { /** * Initialize a compiler. */ constructor(opts = {}) { this.options = opts; } /** * Emit `str` */ emit(str) { return str; } /** * Visit `node`. */ visit(node) { return this[node.type](node); } /** * Map visit over array of `nodes`, optionally using a `delim` */ mapVisit(nodes, delim = '') { let buf = ''; for (let i = 0, length = nodes.length; i < length; i++) { buf += this.visit(nodes[i]); if (delim && i < length - 1) buf += this.emit(delim); } return buf; } } //# sourceMappingURL=compiler.js.map