UNPKG

@chix/flow

Version:
81 lines 3.2 kB
"use strict"; 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 forOf = require("object-forof"); var common_1 = require("../common/"); var flow_1 = require("../events/flow"); var util_1 = require("../util"); var control_1 = require("./control"); var iip_1 = require("./iip"); var ports_1 = require("./ports"); function $Expose(Base) { return (function (_super) { __extends(Expose$, _super); function Expose$() { return _super !== null && _super.apply(this, arguments) || this; } Expose$.prototype.expose = function (input, output) { var _this = this; var iips = []; if (this.hasOwnProperty('ports')) { if (this.ports.hasOwnProperty('input')) { forOf(function (name, port) { var iip = { data: input[name], target: { id: port.nodeId, port: port.name, }, }; iips.push(iip); }, this.ports.input); } else { throw Error('The map provided does not have any input ports available'); } if (output) { var cb_1 = output; if (this.ports.hasOwnProperty('output')) { this.on(flow_1.FlowEvents.OUTPUT.name, function (data) { if (data.node.id === _this.id && cb_1.hasOwnProperty(data.port)) { cb_1[data.port](data.out); } }); } else { throw Error('The map provided does not have any output ports available'); } } } else { throw Error('The map provided does not have any ports available'); } if (iips.length) { this.sendIIPs(iips); } this.push(); return this; }; return Expose$; }(Base)); } exports.$Expose = $Expose; (function ($Expose) { function create(Base) { return util_1.mixin($Expose, control_1.$Control.create, common_1.$Event.create, common_1.$Identity.create, iip_1.$IIP.create, ports_1.$Ports.create)(Base); } $Expose.create = create; })($Expose = exports.$Expose || (exports.$Expose = {})); //# sourceMappingURL=expose.js.map