New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

horpyna

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

horpyna - npm Package Compare versions

Comparing version 0.14.2 to 0.15.0

2

dist/index.js

@@ -1,1 +0,1 @@

require("source-map-support").install(),module.exports=function(e){function t(r){if(n[r])return n[r].exports;var u=n[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=u(a),i=n(5),l=u(i),c=n(4),f=u(c),s=n(8),h=u(s),p=n(6),v=u(p),_=n(3),d=u(_),y=n(11),b=u(y),C=n(13),g=u(C),O=n(14),E=u(O),N=n(10),w=u(N),k=n(9),m=u(k),j=n(7),P=r(j),A=n(12),T=r(A);t["default"]={Component:o["default"],Channel:l["default"],InputChannel:f["default"],OutputChannel:h["default"],CallbackChannel:v["default"],ChannelManager:d["default"],Joint:b["default"],State:g["default"],Structure:E["default"],Request:w["default"],Response:m["default"],CHANNEL:P,ERROR:T}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(3),l=u(i),c=n(4),f=u(c),s=n(6),h=u(s),p=n(8),v=u(p),_=n(9),d=u(_),y=n(10),b=u(y),C=n(11),g=u(C),O=n(13),E=u(O),N=n(14),w=u(N),k=n(7),m=r(k),j=n(12),P=r(j),A=function(){function e(t,n){a(this,e),this._name=t,this._state=new E["default"],this._structure=new w["default"],this._inputChannelManager=new l["default"],this._outputChannelManager=new l["default"],this.createInputChannel(m.DEFAULT_CHANNEL),this.createOutputChannel(m.DEFAULT_CHANNEL),this.createOutputChannel(m.ERROR_CHANNEL),this.onInit(n,this.getStructure())}return o(e,[{key:"getName",value:function(){return this._name}},{key:"onInit",value:function(e,t){}},{key:"onNext",value:function(e,t,n){t.send(e.getValue())}},{key:"setInput",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?m.DEFAULT_CHANNEL:arguments[1];return this.next(new b["default"](e,null,this.getInputChannel(t)))}},{key:"next",value:function(e){var t=this,n=new d["default"](this._getResponseCallback());return setTimeout(function(){try{t.onNext(e,n,t._prepareRunStructure(e,n))}catch(r){n.send(r,m.ERROR_CHANNEL)}},0),this}},{key:"_prepareRunStructure",value:function(e,t){return function(){}}},{key:"createJoint",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?m.DEFAULT_CHANNEL:arguments[1],n=arguments.length<=2||void 0===arguments[2]?m.DEFAULT_CHANNEL:arguments[2];return new g["default"](null,this.getOutputChannel(t),e.getInputChannel(n))}},{key:"addCallback",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?m.DEFAULT_CHANNEL:arguments[1];return new g["default"](null,this.getOutputChannel(t),new h["default"](e))}},{key:"_getResponseCallback",value:function(){var e=this;return function(t,n){e.getOutputChannel(n).emitValue(t)}}},{key:"getStructure",value:function(){return this._structure}},{key:"setState",value:function(e){return this._state.setState(e),this}},{key:"getState",value:function(){return this._state.getState()}},{key:"clearState",value:function(){return this._state.clearState(),this}},{key:"isInputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?m.DEFAULT_CHANNEL:arguments[0];return this._inputChannelManager.isChannelByName(e)}},{key:"isOutputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?m.DEFAULT_CHANNEL:arguments[0];return this._outputChannelManager.isChannelByName(e)}},{key:"getInputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?m.DEFAULT_CHANNEL:arguments[0];if(this.isInputChannel(e)===!1)throw Error(P.NON_EXIST_CHANNEL);return this._inputChannelManager.getChannel(e)}},{key:"getOutputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?m.DEFAULT_CHANNEL:arguments[0];if(this.isOutputChannel(e)===!1)throw Error(P.NON_EXIST_CHANNEL);return this._outputChannelManager.getChannel(e)}},{key:"_getInputChannelSetValueCallback",value:function(){var e=this;return function(t,n,r){e.next(new b["default"](t,n,r))}}},{key:"createInputChannel",value:function(e){if(this.isInputChannel(e)===!0)throw Error(P.UNIQUE_NAME_INPUT_CHANNEL);return this._inputChannelManager.addChannel(new f["default"](e,this._getInputChannelSetValueCallback())),this}},{key:"createOutputChannel",value:function(e){if(this.isOutputChannel(e)===!0)throw Error(P.UNIQUE_NAME_OUTPUT_CHANNEL);return this._outputChannelManager.addChannel(new v["default"](e)),this}}]),e}();t["default"]=A},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];n(this,e),this._channels=t}return r(e,[{key:"isChannelByName",value:function(e){return"undefined"!=typeof this.getChannel(e)}},{key:"isChannel",value:function(e){return this.getChannels().some(function(t){return t===e})}},{key:"addChannel",value:function(e){this._channels.push(e)}},{key:"getChannel",value:function(e){return this._channels.find(function(t){return t.getName()===e})}},{key:"getChannels",value:function(){return this._channels}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),c=r(l),f=function(e){function t(e,n){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];u(this,t);var o=a(this,Object.getPrototypeOf(t).call(this,e,r));return n&&o.setCallback(n),o}return o(t,e),i(t,[{key:"setCallback",value:function(e){return this._onSetValueCallback=e,this}},{key:"setValue",value:function(e,t){this._onSetValueCallback(e,t,this)}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];u(this,t);var r=a(this,Object.getPrototypeOf(t).call(this,n));return r._name=e,r}return o(t,e),i(t,[{key:"getName",value:function(){return this._name}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(4),f=u(c),s=n(7),h=r(s),p=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];a(this,t);var r=o(this,Object.getPrototypeOf(t).call(this,h.DEFAULT_CHANNEL,void 0,n));return r.setCallback(e),r}return i(t,e),l(t,[{key:"setCallback",value:function(e){return this._callback=e,this}},{key:"setValue",value:function(e,t){this._callback(e,t)}}]),t}(f["default"]);t["default"]=p},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.DEFAULT_CHANNEL="channel_default",t.ERROR_CHANNEL="channel_error"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),c=r(l),f=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return u(this,t),a(this,Object.getPrototypeOf(t).call(this,e,n))}return o(t,e),i(t,[{key:"emitValue",value:function(e){var t=this,n=this.getChannels();n.forEach(function(n){n.setValue(e,t)})}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(7),i=r(o),l=function(){function e(t){u(this,e),this._onSendCallback=t}return a(e,[{key:"send",value:function(){var e=arguments.length<=0||void 0===arguments[0]?void 0:arguments[0],t=arguments.length<=1||void 0===arguments[1]?i.DEFAULT_CHANNEL:arguments[1];return this._onSendCallback(e,t),this}}]),e}();t["default"]=l},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(t,r,u){n(this,e),this._value=t,this._source=r,this._target=u}return r(e,[{key:"getValue",value:function(){return this._value}},{key:"getTarget",value:function(){return this._target}},{key:"getSource",value:function(){return this._source}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(12),i=r(o),l=function(){function e(t,n,r){u(this,e),this._name=t,this._source=n,this._target=r,this._join(this.getSource(),this.getTarget())}return a(e,[{key:"getName",value:function(){return this._name}},{key:"_join",value:function(e,t){if(t.isChannel(e)!==!1||e.isChannel(t)!==!1)throw Error(i.ONE_JOINT_PER_CHANNEL_PAIR);return t.addChannel(e),e.addChannel(t),this}},{key:"getSource",value:function(){return this._source}},{key:"getTarget",value:function(){return this._target}}]),e}();t["default"]=l},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=(t.ONE_JOINT_PER_CHANNEL_PAIR="two channels can have only one joint",t.NON_EXIST_CHANNEL="channel do not exist",t.UNIQUE_NAME_CHANNEL="channel need unique name");t.UNIQUE_NAME_INPUT_CHANNEL=n,t.UNIQUE_NAME_OUTPUT_CHANNEL=n},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];n(this,e),this._value=t}return r(e,[{key:"setState",value:function(e){this._value=e}},{key:"clearState",value:function(){this._value=null}},{key:"getState",value:function(){return this._value}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(15),i=r(o),l=n(11),c=r(l),f=function(){function e(){u(this,e),this._components=new i["default"],this._joints=new i["default"]}return a(e,[{key:"createComponent",value:function(e,t,n){var r=new t(e,n);return this._components.add(e,r),r}},{key:"getComponent",value:function(e){return this._components.get(e)}},{key:"createJoint",value:function(e,t,n,r,u){var a=this._components.get(t),o=this._components.get(r),i=new c["default"](e,a.getOutputChannel(n),o.getInputChannel(u));return this._joints.add(e,i),i}},{key:"getJoint",value:function(e){return this._joints.get(e)}}]),e}();t["default"]=f},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){n(this,e),this.items={}}return r(e,[{key:"add",value:function(e,t){this.items[e]=t}},{key:"has",value:function(e){return e in this.items}},{key:"get",value:function(e){return this.items[e]}}]),e}();t["default"]=u}]);
require("source-map-support").install(),module.exports=function(e){function t(r){if(n[r])return n[r].exports;var u=n[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(2),o=u(a),i=n(5),l=u(i),c=n(4),f=u(c),s=n(6),h=u(s),p=n(15),v=u(p),_=n(3),y=u(_),d=n(13),b=u(d),C=n(10),g=u(C),O=n(11),w=u(O),E=n(9),N=u(E),k=n(7),m=u(k),j=n(8),P=r(j),A=n(14),M=r(A);t["default"]={Component:o["default"],Channel:l["default"],InputChannel:f["default"],OutputChannel:h["default"],CallbackChannel:v["default"],ChannelManager:y["default"],Joint:b["default"],State:g["default"],Structure:w["default"],Request:N["default"],Response:m["default"],CHANNEL:P,ERROR:M}},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(3),l=u(i),c=n(4),f=u(c),s=n(6),h=u(s),p=n(7),v=u(p),_=n(9),y=u(_),d=n(10),b=u(d),C=n(11),g=u(C),O=n(8),w=r(O),E=n(14),N=r(E),k=function(){function e(t,n){a(this,e),this._name=t,this._state=new b["default"],this._structure=new g["default"],this._inputChannelManager=new l["default"],this._outputChannelManager=new l["default"],this.createInputChannel(w.DEFAULT_CHANNEL),this.createOutputChannel(w.DEFAULT_CHANNEL),this.createOutputChannel(w.ERROR_CHANNEL),this.onInit(n,this.getStructure())}return o(e,[{key:"getName",value:function(){return this._name}},{key:"onInit",value:function(e,t){}},{key:"onNext",value:function(e,t,n){t.send(e.getValue())}},{key:"setInput",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?w.DEFAULT_CHANNEL:arguments[1];return this.next(new y["default"](e,null,this.getInputChannel(t)))}},{key:"next",value:function(e){var t=this,n=new v["default"](this._getResponseCallback());return setTimeout(function(){try{t.onNext(e,n,t._prepareRunStructure(e,n))}catch(r){n.send(r,w.ERROR_CHANNEL)}},0),this}},{key:"_prepareRunStructure",value:function(e,t){return function(){}}},{key:"_getResponseCallback",value:function(){var e=this;return function(t,n){e.getOutputChannel(n).emitValue(t)}}},{key:"getStructure",value:function(){return this._structure}},{key:"setState",value:function(e){return this._state.setState(e),this}},{key:"getState",value:function(){return this._state.getState()}},{key:"clearState",value:function(){return this._state.clearState(),this}},{key:"isInputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?w.DEFAULT_CHANNEL:arguments[0];return this._inputChannelManager.isChannelByName(e)}},{key:"isOutputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?w.DEFAULT_CHANNEL:arguments[0];return this._outputChannelManager.isChannelByName(e)}},{key:"getInputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?w.DEFAULT_CHANNEL:arguments[0];if(this.isInputChannel(e)===!1)throw Error(N.NON_EXIST_CHANNEL);return this._inputChannelManager.getChannel(e)}},{key:"getOutputChannel",value:function(){var e=arguments.length<=0||void 0===arguments[0]?w.DEFAULT_CHANNEL:arguments[0];if(this.isOutputChannel(e)===!1)throw Error(N.NON_EXIST_CHANNEL);return this._outputChannelManager.getChannel(e)}},{key:"_getInputChannelSetValueCallback",value:function(){var e=this;return function(t,n,r){e.next(new y["default"](t,n,r))}}},{key:"createInputChannel",value:function(e){if(this.isInputChannel(e)===!0)throw Error(N.UNIQUE_NAME_INPUT_CHANNEL);return this._inputChannelManager.addChannel(new f["default"](e,this._getInputChannelSetValueCallback())),this}},{key:"createOutputChannel",value:function(e){if(this.isOutputChannel(e)===!0)throw Error(N.UNIQUE_NAME_OUTPUT_CHANNEL);return this._outputChannelManager.addChannel(new h["default"](e)),this}}]),e}();t["default"]=k},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];n(this,e),this._channels=t}return r(e,[{key:"isChannelByName",value:function(e){return"undefined"!=typeof this.getChannel(e)}},{key:"isChannel",value:function(e){return this.getChannels().some(function(t){return t===e})}},{key:"addChannel",value:function(e){this._channels.push(e)}},{key:"getChannel",value:function(e){return this._channels.find(function(t){return t.getName()===e})}},{key:"getChannels",value:function(){return this._channels}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),c=r(l),f=function(e){function t(e,n){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];u(this,t);var o=a(this,Object.getPrototypeOf(t).call(this,e,r));return n&&o.setCallback(n),o}return o(t,e),i(t,[{key:"setCallback",value:function(e){return this._onSetValueCallback=e,this}},{key:"setValue",value:function(e,t){this._onSetValueCallback(e,t,this)}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(3),c=r(l),f=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];u(this,t);var r=a(this,Object.getPrototypeOf(t).call(this,n));return r._name=e,r}return o(t,e),i(t,[{key:"getName",value:function(){return this._name}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),c=r(l),f=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];return u(this,t),a(this,Object.getPrototypeOf(t).call(this,e,n))}return o(t,e),i(t,[{key:"emitValue",value:function(e){var t=this,n=this.getChannels();n.forEach(function(n){n.setValue(e,t)})}}]),t}(c["default"]);t["default"]=f},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(8),i=r(o),l=function(){function e(t){u(this,e),this._onSendCallback=t}return a(e,[{key:"send",value:function(){var e=arguments.length<=0||void 0===arguments[0]?void 0:arguments[0],t=arguments.length<=1||void 0===arguments[1]?i.DEFAULT_CHANNEL:arguments[1];return this._onSendCallback(e,t),this}}]),e}();t["default"]=l},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.DEFAULT_CHANNEL="channel_default",t.ERROR_CHANNEL="channel_error"},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(t,r,u){n(this,e),this._value=t,this._source=r,this._target=u}return r(e,[{key:"getValue",value:function(){return this._value}},{key:"getTarget",value:function(){return this._target}},{key:"getSource",value:function(){return this._source}}]),e}();t["default"]=u},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];n(this,e),this._value=t}return r(e,[{key:"setState",value:function(e){this._value=e}},{key:"clearState",value:function(){this._value=null}},{key:"getState",value:function(){return this._value}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(12),i=r(o),l=n(13),c=r(l),f=n(15),s=r(f),h=function(){function e(){u(this,e),this._components=new i["default"],this._joints=new i["default"]}return a(e,[{key:"createComponent",value:function(e,t,n){var r=new t(e,n);return this._components.add(e,r),r}},{key:"getComponent",value:function(e){return this._components.get(e)}},{key:"createJoint",value:function(e,t,n){var r=new c["default"](e,t,n);return this._joints.add(e,r),r}},{key:"createCallback",value:function(e,t,n){var r=new c["default"](e,t,new s["default"](n));return this._joints.add(e,r),r}},{key:"getJoint",value:function(e){return this._joints.get(e)}}]),e}();t["default"]=h},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(){n(this,e),this.items={}}return r(e,[{key:"add",value:function(e,t){this.items[e]=t}},{key:"has",value:function(e){return e in this.items}},{key:"get",value:function(e){return this.items[e]}}]),e}();t["default"]=u},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(14),i=r(o),l=function(){function e(t,n,r){u(this,e),this._name=t,this._source=n,this._target=r,this._join(this.getSource(),this.getTarget())}return a(e,[{key:"getName",value:function(){return this._name}},{key:"_join",value:function(e,t){if(t.isChannel(e)!==!1||e.isChannel(t)!==!1)throw Error(i.ONE_JOINT_PER_CHANNEL_PAIR);return t.addChannel(e),e.addChannel(t),this}},{key:"getSource",value:function(){return this._source}},{key:"getTarget",value:function(){return this._target}}]),e}();t["default"]=l},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=(t.ONE_JOINT_PER_CHANNEL_PAIR="two channels can have only one joint",t.NON_EXIST_CHANNEL="channel do not exist",t.UNIQUE_NAME_CHANNEL="channel need unique name");t.UNIQUE_NAME_INPUT_CHANNEL=n,t.UNIQUE_NAME_OUTPUT_CHANNEL=n},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function u(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(4),f=u(c),s=n(8),h=r(s),p=function(e){function t(e){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];a(this,t);var r=o(this,Object.getPrototypeOf(t).call(this,h.DEFAULT_CHANNEL,void 0,n));return r.setCallback(e),r}return i(t,e),l(t,[{key:"setCallback",value:function(e){return this._callback=e,this}},{key:"setValue",value:function(e,t){this._callback(e,t)}}]),t}(f["default"]);t["default"]=p}]);
{
"name": "horpyna",
"version": "0.14.2",
"version": "0.15.0",
"description": "utility to manage async processes",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,6 +5,4 @@ import ChannelManager from "./channelManager";

import InputChannel from "./inputChannel";
import CallbackChannel from "./callbackChannel";
import OutputChannel from "./outputChannel";
import IInputSetValueCallback from "./iInputSetValueCallback";
import ICallbackSetValueCallback from "./iCallbackSetValueCallback";
import Response from "./response";

@@ -25,3 +23,3 @@ import Request from "./request";

constructor(name:string, options:any) {
constructor(name:string, options:any = {}) {
this._name = name;

@@ -70,16 +68,2 @@ this._state = new State();

/**
* @deprecated
*/
public createJoint(target: Component, currentChannelName: string = CHANNEL.DEFAULT_CHANNEL, targetChannelName: string = CHANNEL.DEFAULT_CHANNEL): Joint {
return new Joint(null, this.getOutputChannel(currentChannelName), target.getInputChannel(targetChannelName));
}
/**
* @deprecated
*/
public addCallback(target: ICallbackSetValueCallback, currentChannelName: string = CHANNEL.DEFAULT_CHANNEL): Joint {
return new Joint(null, this.getOutputChannel(currentChannelName), new CallbackChannel(target));
}
private _getResponseCallback(): IResponseCallback {

@@ -86,0 +70,0 @@ return (value: any, channelName: string) => {

import Map from "./map";
import Component from "./component";
import Channel from "./channel";
import Joint from "./joint";
import ICallbackSetValueCallback from "./iCallbackSetValueCallback";
import CallbackChannel from "./callbackChannel";
import * as CHANNEL from "../constants/channels";

@@ -14,3 +18,3 @@ class Structure {

public createComponent(name: string, AnyComponent: typeof Component, options: any): Component {
public createComponent(name: string, AnyComponent: typeof Component, options: any = {}): Component {
const component: Component = new AnyComponent(name, options);

@@ -25,6 +29,4 @@ this._components.add(name, component);

public createJoint(name: string, sourceComponentName: string, sourceChannelName: string, targetComponentName: string, targetChannelName: string) {
const sourceComponent: Component = this._components.get(sourceComponentName);
const targetComponent: Component = this._components.get(targetComponentName);
const joint = new Joint(name, sourceComponent.getOutputChannel(sourceChannelName), targetComponent.getInputChannel(targetChannelName));
public createJoint(name: string, sourceOutput: Channel, targetInput: Channel): Joint {
const joint = new Joint(name, sourceOutput, targetInput);
this._joints.add(name , joint);

@@ -34,7 +36,14 @@ return joint;

public createCallback(name: string, sourceOutput: Channel, callback: ICallbackSetValueCallback): Joint {
const joint = new Joint(name, sourceOutput, new CallbackChannel(callback));
this._joints.add(name , joint);
return joint;
}
public getJoint(name: string): Joint {
return this._joints.get(name);
}
}
export default Structure;

@@ -9,3 +9,3 @@ import sinon from "sinon";

describe("Basic functionality", () => {
describe("Basic functionality (without factories)", () => {
let dummyValue = "BBBB";

@@ -23,3 +23,3 @@

component.setInput(dummyValue);
component.addCallback((value, sourceChannel) => {
new Horpyna.Joint("someName", component.getOutputChannel(), new Horpyna.CallbackChannel((value, sourceChannel) => {
expect(spyCustomFunc.calledOnce).to.be.true;

@@ -30,3 +30,3 @@ expect(value).to.be.equal(dummyValue);

done();
});
}));
});

@@ -48,3 +48,3 @@

component.setInput(dummyValue, targetChannelName);
component.addCallback((value, sourceChannel) => {
new Horpyna.Joint("someName", component.getOutputChannel(responseChannelName), new Horpyna.CallbackChannel((value, sourceChannel) => {
expect(spyCustomFunc.calledOnce).to.be.true;

@@ -55,3 +55,3 @@ expect(value).to.be.equal(dummyValue);

done();
}, responseChannelName);
}));
});

@@ -77,4 +77,4 @@ });

parentComponent.setInput(dummyValue);
parentComponent.createJoint(childComponent);
childComponent.addCallback((value, sourceChannel) => {
new Horpyna.Joint("normalJoint", parentComponent.getOutputChannel(), childComponent.getInputChannel());
new Horpyna.Joint("someName", childComponent.getOutputChannel(), new Horpyna.CallbackChannel((value, sourceChannel) => {
expect(spyParentFunc.calledOnce).to.be.true;

@@ -87,3 +87,3 @@ expect(spyChildFunc.calledOnce).to.be.true;

done();
});
}));
})

@@ -127,7 +127,7 @@ });

};
firstComponent.createJoint(secondAComponent);
firstComponent.createJoint(secondBComponent);
secondAComponent.createJoint(thirdComponent);
secondBComponent.createJoint(thirdComponent);
thirdComponent.addCallback((value, sourceChannel) => {
new Horpyna.Joint("firstSecondA", firstComponent.getOutputChannel(), secondAComponent.getInputChannel());
new Horpyna.Joint("firstSecondB", firstComponent.getOutputChannel(), secondBComponent.getInputChannel());
new Horpyna.Joint("secondAThird", secondAComponent.getOutputChannel(), thirdComponent.getInputChannel());
new Horpyna.Joint("secondBThird", secondBComponent.getOutputChannel(), thirdComponent.getInputChannel());
new Horpyna.Joint("someName", thirdComponent.getOutputChannel(), new Horpyna.CallbackChannel((value, sourceChannel) => {
expect(spyFirst.calledOnce).to.be.true;

@@ -145,3 +145,3 @@ expect(spySecondA.calledOnce).to.be.true;

done();
});
}));

@@ -148,0 +148,0 @@ });

@@ -176,107 +176,2 @@ import sinon from "sinon";

describe("createJoint method", () => {
it("should connect component default output channel and target component input default channel", done => {
const currentComponent = new Horpyna.Component();
const targetComponent = new Horpyna.Component();
const joint = currentComponent.createJoint(targetComponent);
const currentOutputChannel = currentComponent.getOutputChannel();
const targetInputChannel = targetComponent.getInputChannel(Horpyna.CHANNEL.DEFAULT_CHANNEL);
expect(joint).to.be.an.instanceof(Horpyna.Joint);
expect(currentOutputChannel.getChannel(Horpyna.CHANNEL.DEFAULT_CHANNEL)).to.be.equal(targetInputChannel);
expect(targetInputChannel.getChannel(Horpyna.CHANNEL.DEFAULT_CHANNEL)).to.be.equal(currentOutputChannel);
done();
});
it("should connect component custom output channel and target component input custom channel", done => {
const currentChannelName = "fsg423";
const targetChannelName = "aewawe3";
const currentComponent = new Horpyna.Component();
currentComponent.createOutputChannel(currentChannelName);
const targetComponent = new Horpyna.Component();
targetComponent.createInputChannel(targetChannelName);
const joint = currentComponent.createJoint(targetComponent, currentChannelName, targetChannelName);
const currentOutputChannel = currentComponent.getOutputChannel(currentChannelName);
const targetInputChannel = targetComponent.getInputChannel(targetChannelName);
expect(joint).to.be.an.instanceof(Horpyna.Joint);
expect(currentOutputChannel.getChannel(targetChannelName)).to.be.equal(targetInputChannel);
expect(targetInputChannel.getChannel(currentChannelName)).to.be.equal(currentOutputChannel);
done();
});
it("should throw error when target channel non exist", done => {
const currentChannelName = "fsg423";
const targetChannelName = "aewawe3";
const currentComponent = new Horpyna.Component();
currentComponent.createOutputChannel(currentChannelName);
const targetComponent = new Horpyna.Component();
expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
done();
});
it("should throw error when current channel non exist", done => {
const currentChannelName = "fsg423";
const targetChannelName = "aewawe3";
const currentComponent = new Horpyna.Component();
const targetComponent = new Horpyna.Component();
targetComponent.createInputChannel(targetChannelName);
expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
done();
});
it("should throw error when two channels have joint already", done => {
const currentChannelName = "fsg423";
const targetChannelName = "aewawe3";
const currentComponent = new Horpyna.Component();
currentComponent.createOutputChannel(currentChannelName);
const targetComponent = new Horpyna.Component();
targetComponent.createInputChannel(targetChannelName);
currentComponent.createJoint(targetComponent, currentChannelName, targetChannelName);
expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.ONE_JOINT_PER_CHANNEL_PAIR);
done();
});
});
describe("addCallback method", () => {
it("in `next` method should trigger callback with default channel", done => {
const component = new Horpyna.Component();
const joint = component.addCallback((value, sourceChannel) => {
expect(value).to.be.equal(dummyValue);
expect(sourceChannel).to.be.an.instanceof(Horpyna.OutputChannel);
expect(sourceChannel.getName()).to.be.equal(Horpyna.CHANNEL.DEFAULT_CHANNEL);
done();
}, Horpyna.CHANNEL.DEFAULT_CHANNEL);
component.setInput(dummyValue);
expect(joint).to.be.an.instanceof(Horpyna.Joint);
});
it("in `next` method should trigger callback with custom channel", done => {
const currentChannelName = "fsg423";
const nextStub = sinon.stub(Horpyna.Component.prototype, "onNext", (request, response) => {
response.send(request.getValue(), currentChannelName);
nextStub.restore();
});
const component = new Horpyna.Component();
component.createOutputChannel(currentChannelName);
const joint = component.addCallback((value, sourceChannel) => {
expect(value).to.be.equal(dummyValue);
expect(sourceChannel).to.be.an.instanceof(Horpyna.OutputChannel);
expect(sourceChannel.getName()).to.be.equal(currentChannelName);
done();
}, currentChannelName);
component.setInput(dummyValue);
expect(joint).to.be.an.instanceof(Horpyna.Joint);
});
it("should throw error when current channel non exist", done => {
const currentChannelName = "fsg423";
const component = new Horpyna.Component();
expect(component.addCallback.bind(component, () => {}, currentChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
done();
});
});
});

@@ -29,7 +29,7 @@ import sinon from "sinon";

let structure;
let sourceComponentName = "sourceComponent";
let sourceChannelName = "sourceChannel";
let targetComponentName = "targetComponent";
let targetChannelName = "targetChannel";
let structure, sourceComponent, sourceChannel, targetComponent, targetChannel;
const sourceComponentName = "sourceComponent";
const sourceChannelName = "sourceChannel";
const targetComponentName = "targetComponent";
const targetChannelName = "targetChannel";
before(done => {

@@ -41,2 +41,6 @@ structure = new Horpyna.Structure();

.createInputChannel(targetChannelName);
sourceComponent = structure.getComponent(sourceComponentName);
sourceChannel = sourceComponent.getOutputChannel(sourceChannelName);
targetComponent = structure.getComponent(targetComponentName);
targetChannel = targetComponent.getInputChannel(targetChannelName);
done();

@@ -47,13 +51,91 @@ });

const jointName = "jointName";
structure.createJoint(jointName, sourceComponentName, sourceChannelName, targetComponentName, targetChannelName);
structure.createJoint(jointName, sourceChannel, targetChannel);
const joint = structure.getJoint(jointName);
expect(joint).to.be.instanceof(Horpyna.Joint);
expect(joint.getName()).to.be.equal(jointName);
const sourceChannel = joint.getSource();
const targetChannel = joint.getTarget();
expect(sourceChannel.getName()).to.be.equal(sourceChannelName);
expect(targetChannel.getName()).to.be.equal(targetChannelName);
const sourceChannelFromJoint = joint.getSource();
const targetChannelFromJoint = joint.getTarget();
expect(sourceChannelFromJoint.getName()).to.be.equal(sourceChannelName);
expect(targetChannelFromJoint.getName()).to.be.equal(targetChannelName);
done();
});
});
//describe("createJoint method", () => {
//
//
//
// it("should throw error when target channel non exist", done => {
// const currentChannelName = "fsg423";
// const targetChannelName = "aewawe3";
// const currentComponent = new Horpyna.Component();
// currentComponent.createOutputChannel(currentChannelName);
// const targetComponent = new Horpyna.Component();
// expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
// done();
// });
//
// it("should throw error when current channel non exist", done => {
// const currentChannelName = "fsg423";
// const targetChannelName = "aewawe3";
// const currentComponent = new Horpyna.Component();
// const targetComponent = new Horpyna.Component();
// targetComponent.createInputChannel(targetChannelName);
// expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
// done();
// });
//
// it("should throw error when two channels have joint already", done => {
// const currentChannelName = "fsg423";
// const targetChannelName = "aewawe3";
// const currentComponent = new Horpyna.Component();
// currentComponent.createOutputChannel(currentChannelName);
// const targetComponent = new Horpyna.Component();
// targetComponent.createInputChannel(targetChannelName);
// currentComponent.createJoint(targetComponent, currentChannelName, targetChannelName);
// expect(currentComponent.createJoint.bind(currentComponent, targetComponent, currentChannelName, targetChannelName)).to.throw(Error, Error.ONE_JOINT_PER_CHANNEL_PAIR);
// done();
// });
//});
//
//describe("addCallback method", () => {
// it("in `next` method should trigger callback with default channel", done => {
// const component = new Horpyna.Component();
// const joint = component.addCallback((value, sourceChannel) => {
// expect(value).to.be.equal(dummyValue);
// expect(sourceChannel).to.be.an.instanceof(Horpyna.OutputChannel);
// expect(sourceChannel.getName()).to.be.equal(Horpyna.CHANNEL.DEFAULT_CHANNEL);
// done();
// }, Horpyna.CHANNEL.DEFAULT_CHANNEL);
// component.setInput(dummyValue);
// expect(joint).to.be.an.instanceof(Horpyna.Joint);
// });
//
// it("in `next` method should trigger callback with custom channel", done => {
// const currentChannelName = "fsg423";
// const nextStub = sinon.stub(Horpyna.Component.prototype, "onNext", (request, response) => {
// response.send(request.getValue(), currentChannelName);
// nextStub.restore();
// });
// const component = new Horpyna.Component();
// component.createOutputChannel(currentChannelName);
// const joint = component.addCallback((value, sourceChannel) => {
// expect(value).to.be.equal(dummyValue);
// expect(sourceChannel).to.be.an.instanceof(Horpyna.OutputChannel);
// expect(sourceChannel.getName()).to.be.equal(currentChannelName);
// done();
// }, currentChannelName);
//
// component.setInput(dummyValue);
// expect(joint).to.be.an.instanceof(Horpyna.Joint);
// });
//
// it("should throw error when current channel non exist", done => {
// const currentChannelName = "fsg423";
// const component = new Horpyna.Component();
// expect(component.addCallback.bind(component, () => {}, currentChannelName)).to.throw(Error, Error.NON_EXIST_CHANNEL);
// done();
// });
//});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc