Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scalecube/addressable

Package Overview
Dependencies
Maintainers
7
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalecube/addressable - npm Package Compare versions

Comparing version 0.0.0 to 0.2.10-snapshot.feature-addressable.1596051005

LICENSE

2

dist/index.js

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

var sc=function(e){"use strict";var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},n=function(){function e(){this.values={},this.subscribers=[]}return e.prototype.next=function(e){this.values=t({},e),this.notify()},e.prototype.subscribe=function(e){var n=this;return this.subscribers.push(e),e(t({},this.values)),function(){n.subscribers=n.subscribers.filter((function(t){return t!==e}))}},e.prototype.notify=function(){for(var e=0,n=this.subscribers;e<n.length;e++){(0,n[e])(t({},this.values))}},e}();var r,s,o=function(){function e(){this.id=Math.random().toString()+"-"+Math.random().toString()+"-"+Math.random().toString()+"-"+Math.random().toString(),this.peers={},this.peers$=new n}return e.prototype.subscribe=function(e){return function(e,t){return{subscribe:function(n){return t.subscribe((function(t){n(e(t))}))}}}((function(e){return{id:e.key,port:e.value}}),(t=this.peers$,{subscribe:function(e){var n={},r=function(t){return e(t)};return t.subscribe((function(e){for(var t in e)n[t]&&n[t]===e[t]||r({key:t,value:e[t]});for(var t in n)e[t]||r({key:t,value:void 0});n=e}))}})).subscribe(e);var t},e.prototype.get=function(){return t({},this.peers)},e.prototype.add=function(e,t){this.peers[e]=t,this.peers$.next(this.peers)},e.prototype.remove=function(e){delete this.peers[e],this.peers$.next(this.peers)},e}(),a="addChannel",i="channelInit",d="registerAddress",c="connect",u="incomingServerConnection",p="incomingClientConnection";function f(){var e=new o,r={},s=new n;function f(o){var a,i;return o.data.type===c&&o.data.sourceNodeId&&o.data.remoteAddress&&(a=s,i=e,{subscribe:function(e){var t=new n,r=a.subscribe((function(e){return t.next(e)})),s=i.subscribe((function(e){return t.next(e)})),o=t.subscribe(e);return function(){r(),s(),o()}}}).subscribe((function(){var n=e.get();if(n[o.data.sourceNodeId]&&r[o.data.remoteAddress]){o.data.remoteAddress,o.data.sourceNodeId;var s=new MessageChannel,a={remoteAddress:o.data.remoteAddress,connectionId:o.data.connectionId,sourceNodeId:o.data.sourceNodeId};n[o.data.sourceNodeId].postMessage(t(t({},a),{type:p}),[s.port2]),n[r[o.data.remoteAddress]].postMessage(t(t({},a),{type:u}),[s.port1])}})),!1}function v(e){e&&e.data&&(f(e)||function(e){e.data.type===d&&e.data.address&&e.data.peerId&&(e.data.address,r[e.data.address]=e.data.peerId,s.next({address:e.data.address,peerId:e.data.peerId}))}(e))}var l=e.subscribe((function(e){e.port.addEventListener("message",v)}));return{channelHandler:function(t){t.data.type===a&&(e.add(t.data.nodeId,t.ports[0]),t.ports[0].start(),t.ports[0].postMessage({type:i,nodeId:t.data.nodeId}))},shutdown:function(){l();var t=e.get();for(var n in t)t[n].removeEventListener("message",v)}}}"undefined"!=typeof window&&(r=window),"undefined"!=typeof WorkerGlobalScope&&(s=self);var v=function(e,n){var r,s,p=f(),v=(r=new o,s={},r.subscribe((function(e){e.port.addEventListener("message",(function(e){e&&e.data&&e.data.type===u&&e.data.remoteAddress&&s[e.data.remoteAddress]&&e.ports[0]&&(e.ports[0].addEventListener("message",(function(t){e.data.remoteAddress,s[e.data.remoteAddress](t,e.ports[0])})),e.ports[0].start())}))})),{createChannel:function(e,t){void 0===t&&(t=5e3);var n=Date.now()+t;return new Promise((function(t,s){var o=function(){var d=new MessageChannel,c=setTimeout((function(){d.port1.close(),d.port2.close(),Date.now()<n?o():s()}),100);e({type:a,nodeId:r.id},[d.port1]),d.port2.addEventListener("message",(function(e){e.data.type===i&&(r.add(e.data.nodeId,d.port2),clearTimeout(c),t())})),d.port2.start()};o()}))},listen:function(e,t){s[e]=t,r.subscribe((function(t){t.port.postMessage({type:d,peerId:r.id,address:e})}))},connect:function(e,n){return void 0===n&&(n=5e3),new Promise((function(s,o){var a={remoteAddress:e,sourceNodeId:r.id,connectionId:Date.now()+"-"+Math.random()},i=function(){var e=r.get();for(var t in e)e[t].removeEventListener("message",u)},d=setTimeout((function(){p(),i(),o("connection timeout")}),n),u=function(e){e&&e.data&&e.data.connectionId===a.connectionId&&e.ports[0]&&(i(),clearTimeout(d),e.ports[0].start(),s(e.ports[0]))},p=r.subscribe((function(e){e.id;var n=e.port;n.addEventListener("message",u),n.postMessage(t(t({},a),{type:c}),[])}))}))}});if("undefined"!=typeof Worker){var l=Worker;Worker=function(e,t){void 0===t&&(t={});var n=new l(e,t);return n.addEventListener("message",p.channelHandler),n}}if(void 0!==n){var b=new MessageChannel;b.port1.start(),b.port2.start(),n.addEventListener("message",p.channelHandler),b.port2.addEventListener("message",p.channelHandler),v.createChannel(b.port1.postMessage.bind(b.port1)),v.createChannel(n.postMessage.bind(n))}else e&&e.top&&e.top!==e.self?(v.createChannel((function(t,n){return e.postMessage.bind(e)(t,"*",n)})),v.createChannel((function(t,n){return e.top.postMessage.bind(e.top)(t,"*",n)})),e.addEventListener("message",p.channelHandler)):(v.createChannel((function(t,n){return e.postMessage(t,"*",n)})),e.addEventListener("message",p.channelHandler));return v}(r,s),l=v.connect,b=v.listen;return e.connect=l,e.listen=b,e}({});
var sc=function(e){"use strict";var t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)},n=function(){function e(){this.values={},this.subscribers=[]}return e.prototype.next=function(e){this.values=t({},e),this.notify()},e.prototype.subscribe=function(e){var n=this;return this.subscribers.push(e),e(t({},this.values)),function(){n.subscribers=n.subscribers.filter((function(t){return t!==e}))}},e.prototype.notify=function(){for(var e=0,n=this.subscribers;e<n.length;e++){(0,n[e])(t({},this.values))}},e}();var r,s,o=function(){function e(){this.id=Math.random().toString()+"-"+Math.random().toString()+"-"+Math.random().toString()+"-"+Math.random().toString(),this.peers={},this.peers$=new n}return e.prototype.subscribe=function(e){return function(e,t){return{subscribe:function(n){return t.subscribe((function(t){n(e(t))}))}}}((function(e){return{id:e.key,port:e.value}}),(t=this.peers$,{subscribe:function(e){var n={},r=function(t){return e(t)};return t.subscribe((function(e){for(var t in e)n[t]&&n[t]===e[t]||r({key:t,value:e[t]});for(var t in n)e[t]||r({key:t,value:void 0});n=e}))}})).subscribe(e);var t},e.prototype.get=function(){return t({},this.peers)},e.prototype.add=function(e,t){this.peers[e]=t,this.peers$.next(this.peers)},e}(),a="addChannel",i="channelInit",d="registerAddress",c="connect",u="incomingServerConnection",p="incomingClientConnection";function f(){var e=new o,r={},s=new n;function f(o){var a,i;return o.data.type===c&&o.data.sourceNodeId&&o.data.remoteAddress&&(a=s,i=e,{subscribe:function(e){var t=new n,r=a.subscribe((function(e){return t.next(e)})),s=i.subscribe((function(e){return t.next(e)})),o=t.subscribe(e);return function(){r(),s(),o()}}}).subscribe((function(){var n=e.get();if(n[o.data.sourceNodeId]&&r[o.data.remoteAddress]){o.data.remoteAddress,o.data.sourceNodeId;var s=new MessageChannel,a={remoteAddress:o.data.remoteAddress,connectionId:o.data.connectionId,sourceNodeId:o.data.sourceNodeId};n[o.data.sourceNodeId].postMessage(t(t({},a),{type:p}),[s.port2]),n[r[o.data.remoteAddress]].postMessage(t(t({},a),{type:u}),[s.port1])}})),!1}function v(e){e&&e.data&&(f(e)||function(e){e.data.type===d&&e.data.address&&e.data.peerId&&(e.data.address,r[e.data.address]=e.data.peerId,s.next({address:e.data.address,peerId:e.data.peerId}))}(e))}var b=e.subscribe((function(e){e.port.addEventListener("message",v)}));return{channelHandler:function(t){t.data.type===a&&(e.add(t.data.nodeId,t.ports[0]),t.ports[0].start(),t.ports[0].postMessage({type:i,nodeId:t.data.nodeId}))},shutdown:function(){b();var t=e.get();for(var n in t)t[n].removeEventListener("message",v)}}}"undefined"!=typeof window&&(r=window),"undefined"!=typeof WorkerGlobalScope&&(s=self);var v=function(e,n){var r,s,p=f(),v=(r=new o,s={},r.subscribe((function(e){e.port.addEventListener("message",(function(e){e&&e.data&&e.data.type===u&&e.data.remoteAddress&&s[e.data.remoteAddress]&&e.ports[0]&&(e.ports[0].addEventListener("message",(function(t){e.data.remoteAddress,s[e.data.remoteAddress](t,e.ports[0])})),e.ports[0].start())}))})),{createChannel:function(e,t){void 0===t&&(t=5e3);var n=Date.now()+t;return new Promise((function(t,s){var o=function(){var d=new MessageChannel,c=setTimeout((function(){d.port1.close(),d.port2.close(),Date.now()<n?o():s()}),100);e({type:a,nodeId:r.id},[d.port1]),d.port2.addEventListener("message",(function(e){e.data.type===i&&(r.add(e.data.nodeId,d.port2),clearTimeout(c),t())})),d.port2.start()};o()}))},listen:function(e,t){s[e]=t,r.subscribe((function(t){t.port.postMessage({type:d,peerId:r.id,address:e})}))},connect:function(e,n){return void 0===n&&(n=5e3),new Promise((function(s,o){var a={remoteAddress:e,sourceNodeId:r.id,connectionId:Date.now()+"-"+Math.random()},i=function(){var e=r.get();for(var t in e)e[t].removeEventListener("message",u)},d=setTimeout((function(){p(),i(),o("connection timeout")}),n),u=function(e){e&&e.data&&e.data.connectionId===a.connectionId&&e.ports[0]&&(i(),clearTimeout(d),e.ports[0].start(),s(e.ports[0]))},p=r.subscribe((function(e){e.id;var n=e.port;n.addEventListener("message",u),n.postMessage(t(t({},a),{type:c}),[])}))}))}});if("undefined"!=typeof Worker){var b=Worker;Worker=function(e,t){void 0===t&&(t={});var n=new b(e,t);return n.addEventListener("message",p.channelHandler),n}}if(void 0!==n){var l=new MessageChannel;l.port1.start(),l.port2.start(),n.addEventListener("message",p.channelHandler),l.port2.addEventListener("message",p.channelHandler),v.createChannel(l.port1.postMessage.bind(l.port1)),v.createChannel(n.postMessage.bind(n))}else e&&e.top&&e.top!==e.self?(v.createChannel((function(t,n){return e.postMessage.bind(e)(t,"*",n)})),v.createChannel((function(t,n){return e.top.postMessage.bind(e.top)(t,"*",n)})),e.addEventListener("message",p.channelHandler)):(v.createChannel((function(t,n){return e.postMessage(t,"*",n)})),e.addEventListener("message",p.channelHandler));return v}(r,s),b=v.connect,l=v.listen;return e.connect=b,e.listen=l,e}({});

@@ -36,9 +36,2 @@ import { Peer } from './types';

add(id: string, port: MessagePort): void;
/**
* @method remove
* Remove peer from node
*
* @param id
*/
remove(id: string): void;
}

@@ -111,2 +111,17 @@ 'use strict';

this.peers$ = new Subject();
/**
* Peer removal right now is not needed
* Right now we create Node for every process
* There isn't any use case we are doing that the process will be remove
* At the moment it won't clear up the memory
*
* @method remove
* Remove peer from node
*
* @param id
*/
// public remove(id: string) {
// delete this.peers[id];
// this.peers$.next(this.peers);
// }
}

@@ -141,12 +156,2 @@ /**

};
/**
* @method remove
* Remove peer from node
*
* @param id
*/
Node.prototype.remove = function (id) {
delete this.peers[id];
this.peers$.next(this.peers);
};
return Node;

@@ -153,0 +158,0 @@ }());

@@ -36,9 +36,2 @@ import { Peer } from './types';

add(id: string, port: MessagePort): void;
/**
* @method remove
* Remove peer from node
*
* @param id
*/
remove(id: string): void;
}
{
"name": "@scalecube/addressable",
"version": "0.0.0",
"version": "0.2.10-snapshot.feature-addressable.1596051005",
"private": false,

@@ -28,5 +28,4 @@ "unpkg": "dist/index.js",

"author": "Scalecube (https://github.com/scalecube/scalecube-js)",
"dependencies": {},
"devDependencies": {
"@scalecube/utils": "^0.2.9",
"@scalecube/utils": "^0.2.10-snapshot.feature-addressable.1596051005",
"@types/expect-puppeteer": "^4.4.3",

@@ -51,3 +50,4 @@ "@types/jest-environment-puppeteer": "^4.3.2",

"typescript": "^3.2.4"
}
},
"gitHead": "99045aa37640f5d36b0216d4fa6265d9c986b5b4"
}

@@ -36,2 +36,3 @@ # Addressable

Cleaning connections
```ts

@@ -38,0 +39,0 @@ import {connect, listen} from '@scalecube/addressable';

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