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

@scalecube/utils

Package Overview
Dependencies
Maintainers
7
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalecube/utils - npm Package Compare versions

Comparing version 0.0.2-alpha.6 to 0.0.2-alpha.7

es/connectWorkers.d.ts

3

es/index.d.ts
import * as check from './check';
import { getFullAddress, validateAddress, getAddress } from './address';
import * as constants from './constants';
export { check, getFullAddress, validateAddress, constants, getAddress };
import { addWorker, removeWorker } from './connectWorkers';
export { check, getFullAddress, validateAddress, constants, getAddress, addWorker, removeWorker };

@@ -135,2 +135,54 @@ var assert = function (predicate, msg) {

export { check, constants, getAddress, getFullAddress, validateAddress };
var workersMap = {};
// @ts-ignore
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
console.warn("Don't use this on webworkers, only on the main thread");
}
else {
addEventListener('message', function (ev) {
if (ev && ev.data && !ev.data.workerId) {
if (ev.data.detail) {
ev.data.workerId = 1;
var propogateTo = workersMap[ev.data.detail.to] || workersMap[ev.data.detail.address]; // discoveryEvents || rsocketEvents
if (propogateTo) {
// console.log('window -> propogateTo', ev.data);
// @ts-ignore
propogateTo.postMessage(ev.data, ev.ports || undefined);
}
}
}
});
}
function workerEventHandler(ev) {
if (ev.data && ev.data.detail && ev.data.type) {
if (!ev.data.workerId) {
ev.data.workerId = 1;
if (ev.data.type === 'ConnectWorkerEvent') {
if (ev.data.detail.whoAmI) {
// @ts-ignore
workersMap[ev.data.detail.whoAmI] = this;
}
}
else {
var propogateTo = workersMap[ev.data.detail.to] || workersMap[ev.data.detail.address]; // discoveryEvents || rsocketEvents
// console.log('worker -> propogateTo', ev.data);
if (propogateTo) {
// @ts-ignore
propogateTo.postMessage(ev.data, ev.ports || undefined);
}
else {
// @ts-ignore
postMessage(ev.data, '*', ev.ports || undefined);
}
}
}
}
}
var addWorker = function (worker) {
worker.addEventListener('message', workerEventHandler.bind(worker));
};
var removeWorker = function (worker) {
worker.removeEventListener('message', workerEventHandler.bind(worker));
};
export { addWorker, check, constants, getAddress, getFullAddress, removeWorker, validateAddress };
import * as check from './check';
import { getFullAddress, validateAddress, getAddress } from './address';
import * as constants from './constants';
export { check, getFullAddress, validateAddress, constants, getAddress };
import { addWorker, removeWorker } from './connectWorkers';
export { check, getFullAddress, validateAddress, constants, getAddress, addWorker, removeWorker };

@@ -139,2 +139,55 @@ 'use strict';

var workersMap = {};
// @ts-ignore
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
console.warn("Don't use this on webworkers, only on the main thread");
}
else {
addEventListener('message', function (ev) {
if (ev && ev.data && !ev.data.workerId) {
if (ev.data.detail) {
ev.data.workerId = 1;
var propogateTo = workersMap[ev.data.detail.to] || workersMap[ev.data.detail.address]; // discoveryEvents || rsocketEvents
if (propogateTo) {
// console.log('window -> propogateTo', ev.data);
// @ts-ignore
propogateTo.postMessage(ev.data, ev.ports || undefined);
}
}
}
});
}
function workerEventHandler(ev) {
if (ev.data && ev.data.detail && ev.data.type) {
if (!ev.data.workerId) {
ev.data.workerId = 1;
if (ev.data.type === 'ConnectWorkerEvent') {
if (ev.data.detail.whoAmI) {
// @ts-ignore
workersMap[ev.data.detail.whoAmI] = this;
}
}
else {
var propogateTo = workersMap[ev.data.detail.to] || workersMap[ev.data.detail.address]; // discoveryEvents || rsocketEvents
// console.log('worker -> propogateTo', ev.data);
if (propogateTo) {
// @ts-ignore
propogateTo.postMessage(ev.data, ev.ports || undefined);
}
else {
// @ts-ignore
postMessage(ev.data, '*', ev.ports || undefined);
}
}
}
}
}
var addWorker = function (worker) {
worker.addEventListener('message', workerEventHandler.bind(worker));
};
var removeWorker = function (worker) {
worker.removeEventListener('message', workerEventHandler.bind(worker));
};
exports.addWorker = addWorker;
exports.check = check;

@@ -144,2 +197,3 @@ exports.constants = constants;

exports.getFullAddress = getFullAddress;
exports.removeWorker = removeWorker;
exports.validateAddress = validateAddress;
{
"name": "@scalecube/utils",
"version": "0.0.2-alpha.6",
"version": "0.0.2-alpha.7",
"private": false,

@@ -28,2 +28,3 @@ "main": "lib/index.js",

"rollup": "^1.14.6",
"rollup-plugin-filesize": "^6.1.1",
"rollup-plugin-typescript2": "^0.21.1",

@@ -37,5 +38,5 @@ "rollup-plugin-visualizer": "^2.2.0",

"dependencies": {
"@scalecube/api": "^0.0.2-alpha.6"
"@scalecube/api": "^0.0.2-alpha.7"
},
"gitHead": "940db2310ba183ac8a2d65fc7d22e261ce452231"
"gitHead": "ae962d62c4deb8016761bc7e0c9a1c6aac1648e2"
}
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