UNPKG

@livy/util

Version:
69 lines (68 loc) 2.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormattableHandlerMixin = void 0; const line_formatter_1 = require("../formatters/line-formatter"); const mixin_1 = require("../mixin"); /** * Adds basic formatter functionality */ exports.FormattableHandlerMixin = (0, mixin_1.Mixin)(BaseClass => { return class FormattableHandlerMixin extends BaseClass { /** * Get the default formatter * * This exists to be overridden, because getters/setters of mixins can not * be properly overridden due to TS2611 * * @protected This should also not be public, but is forced to be due to microsoft/typescript#17744 */ getDefaultFormatter() { return new line_formatter_1.LineFormatter(); } /** * @inheritdoc */ get defaultFormatter() { return this.getDefaultFormatter(); } /** * @inheritdoc */ set formatter(formatter) { this.setFormatter(formatter); } /** * @inheritdoc */ get formatter() { return this.getFormatter(); } /** * Get the formatter * * This exists to be overridden, because getters/setters of mixins can not * be properly overridden due to TS2611 * * @protected This should also not be public, but is forced to be due to microsoft/typescript#17744 */ setFormatter(formatter) { this.explicitFormatter = formatter; } /** * Set the formatter * * This exists to be overridden, because getters/setters of mixins can not * be properly overridden due to TS2611 * * @protected This should also not be public, but is forced to be due to microsoft/typescript#17744 */ getFormatter() { // Default formatter is committed as the handler's formatter // as soon as the formatter is requested if (typeof this.explicitFormatter === 'undefined') { this.explicitFormatter = this.defaultFormatter; } return this.explicitFormatter; } }; });