UNPKG

@livy/util

Version:
63 lines (62 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProcessableHandlerMixin = void 0; const is_resettable_interface_1 = require("../is-resettable-interface"); const mixin_1 = require("../mixin"); /** * Adds basic processor-handling functionality */ const ProcessableHandlerMixin = (0, mixin_1.Mixin)(BaseClass => { return class ProcessableHandlerMixin extends BaseClass { constructor() { super(...arguments); /** * @protected This should not be public, but is forced to be due to microsoft/typescript#17744 */ this._processors = new Set(); } /** * @inheritdoc */ get processors() { return this._processors; } /** * Processes a record. * * @protected This should not be public, but is forced to be due to microsoft/typescript#17744 * @param record */ processRecord(record) { if (this._processors.size > 0) { for (const processor of this._processors) { if (typeof processor === 'function') { record = processor(record); } else { record = processor.process(record); } } } return record; } /** * Reset processors * @protected This should not be public, but is forced to be due to microsoft/typescript#17744 */ resetProcessors() { for (const processor of this._processors) { if ((0, is_resettable_interface_1.isResettableInterface)(processor)) { processor.reset(); } } } /** * @inheritdoc */ reset() { this.resetProcessors(); } }; }); exports.ProcessableHandlerMixin = ProcessableHandlerMixin;