UNPKG

@chix/flow

Version:
59 lines 2.34 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 _debug = require("debug"); var debug = _debug('chix:io'); function $Pointer(Base) { return (function (_super) { __extends(Pointer$, _super); function Pointer$() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.pointerPorts = new Map(); return _this; } Pointer$.prototype.addPointerPort = function (link) { if (!link.source.pid) { throw Error('Could not find pid for source.'); } if (!this.pointerPorts.has(link.source.pid)) { this.pointerPorts.set(link.source.pid, []); } var pointers = this.pointerPorts.get(link.source.pid); pointers.push(link.source.port); debug('%s: added pointer port `%s`', link.ioid, link.source.port); }; Pointer$.prototype.removePointerPort = function (link) { var src = this.pointerPorts.get(link.source.pid); if (!src) { throw Error("Could not find " + link.source.pid); } src.splice(src.indexOf(link.source.port), 1); if (src.length === 0) { this.pointerPorts.delete(link.source.pid); } }; Pointer$.prototype.getPointerPorts = function (originId) { if (this.pointerPorts.has(originId)) { return this.pointerPorts.get(originId); } else { throw new Error(originId + " s has no pointer ports"); } }; return Pointer$; }(Base)); } exports.$Pointer = $Pointer; //# sourceMappingURL=pointer.js.map