39 lines
732 B
JavaScript
39 lines
732 B
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = SafeSink;
|
|
/** @license MIT License (c) copyright 2010-2016 original author or authors */
|
|
/** @author Brian Cavalier */
|
|
/** @author John Hann */
|
|
|
|
function SafeSink(sink) {
|
|
this.sink = sink;
|
|
this.active = true;
|
|
}
|
|
|
|
SafeSink.prototype.event = function (t, x) {
|
|
if (!this.active) {
|
|
return;
|
|
}
|
|
this.sink.event(t, x);
|
|
};
|
|
|
|
SafeSink.prototype.end = function (t, x) {
|
|
if (!this.active) {
|
|
return;
|
|
}
|
|
this.disable();
|
|
this.sink.end(t, x);
|
|
};
|
|
|
|
SafeSink.prototype.error = function (t, e) {
|
|
this.disable();
|
|
this.sink.error(t, e);
|
|
};
|
|
|
|
SafeSink.prototype.disable = function () {
|
|
this.active = false;
|
|
return this.sink;
|
|
}; |