@zkochan/pnpm
Version:
Fast, disk space efficient package manager
55 lines (43 loc) • 1.07 kB
JavaScript
/** @license MIT License (c) copyright 2010-2016 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
import fatal from '../fatalError'
export default function PropagateTask (run, value, sink) {
this._run = run
this.value = value
this.sink = sink
this.active = true
}
PropagateTask.event = function (value, sink) {
return new PropagateTask(emit, value, sink)
}
PropagateTask.end = function (value, sink) {
return new PropagateTask(end, value, sink)
}
PropagateTask.error = function (value, sink) {
return new PropagateTask(error, value, sink)
}
PropagateTask.prototype.dispose = function () {
this.active = false
}
PropagateTask.prototype.run = function (t) {
if (!this.active) {
return
}
this._run(t, this.value, this.sink)
}
PropagateTask.prototype.error = function (t, e) {
if (!this.active) {
return fatal(e)
}
this.sink.error(t, e)
}
function error (t, e, sink) {
sink.error(t, e)
}
function emit (t, x, sink) {
sink.event(t, x)
}
function end (t, x, sink) {
sink.end(t, x)
}