pnpm
Version:
Fast, disk space efficient package manager
34 lines (28 loc) • 626 B
JavaScript
/** @license MIT License (c) copyright 2010-2016 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
export default 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
}