@chix/flow
Version:
82 lines • 3 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var _debug = require("debug");
var forOf = require("object-forof");
var common_1 = require("../common");
var events_1 = require("../events");
var util_1 = require("../util");
var export_1 = require("./export");
var ports_1 = require("./ports");
var debug = _debug('chix:node:control');
function $Control(Base) {
return (function (_super) {
__extends(Control$, _super);
function Control$() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.active = false;
_this.runCount = 0;
_this.outputCount = 0;
_this.state = {};
_this.__halted = false;
return _this;
}
Control$.prototype.start = function () {
throw Error('Node needs to implement start() method');
};
Control$.prototype.hold = function () {
this.setStatus('hold');
this.__halted = true;
};
Control$.prototype.release = function () {
this.setStatus('running');
if (this.__halted) {
this.__halted = false;
}
};
Control$.prototype.isHalted = function () {
return this.__halted;
};
Control$.prototype.complete = function () {
this.active = false;
this.event(events_1.NodeEvents.COMPLETE, {
node: this.export(),
});
};
Control$.prototype.reset = function () {
debug('%s: reset', this.identifier);
this.freeInput();
this.state = {};
this.runCount = 0;
this.status = 'stopped';
this.start();
};
Control$.prototype.freeInput = function () {
forOf(function (_name, port) {
port.reset();
}, this.ports.input);
};
Control$.prototype.destroy = function () { };
return Control$;
}(Base));
}
exports.$Control = $Control;
(function ($Control) {
function create(Base) {
return util_1.mixin(common_1.$Event.create, export_1.$Export.create, common_1.$Identity.create, ports_1.$Ports.create, common_1.$Status.create)(Base);
}
$Control.create = create;
})($Control = exports.$Control || (exports.$Control = {}));
//# sourceMappingURL=control.js.map