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

nexus

Package Overview
Dependencies
Maintainers
1
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

5

lib/constants/errors.js

@@ -33,7 +33,2 @@ 'use strict';

server_closed: {
message: 'You must open the Nexus server before you can listen to a transport.',
data: []
},
/**

@@ -40,0 +35,0 @@ * Messages.

422

lib/server/server.js

@@ -150,3 +150,3 @@ 'use strict';

var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var store, pubsub;
var closed, store, pubsub;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -158,11 +158,21 @@ while (1) {

store = this.store, pubsub = this.pubsub;
_context.next = 4;
return Promise.all([store.open && store.open(), pubsub.open && pubsub.open()]);
closed = this.closed, store = this.store, pubsub = this.pubsub;
if (closed) {
_context.next = 4;
break;
}
return _context.abrupt('return');
case 4:
_context.next = 6;
return Promise.all([store.open && store.open(), pubsub.open && pubsub.open()]);
case 6:
this.closed = false;
debug('opened');
case 5:
case 8:
case 'end':

@@ -190,3 +200,3 @@ return _context.stop();

var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var store, pubsub, connections, id, connection;
var closed, store, pubsub, connections, id, connection;
return regeneratorRuntime.wrap(function _callee2$(_context2) {

@@ -198,5 +208,13 @@ while (1) {

store = this.store, pubsub = this.pubsub, connections = this.connections;
closed = this.closed, store = this.store, pubsub = this.pubsub, connections = this.connections;
if (!closed) {
_context2.next = 4;
break;
}
return _context2.abrupt('return');
case 4:
for (id in connections) {

@@ -208,10 +226,11 @@ connection = connections[id];

_context2.next = 5;
_context2.next = 7;
return Promise.all([store.close && store.close(), pubsub.close && pubsub.close()]);
case 5:
case 7:
this.closed = true;
debug('closed');
case 6:
case 9:
case 'end':

@@ -240,60 +259,98 @@ return _context2.stop();

key: 'attach',
value: function attach(server) {
var _this2 = this;
value: function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(server) {
var _this2 = this;
server.on('listen', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context3.prev = _context3.next) {
switch (_context5.prev = _context5.next) {
case 0:
_context3.prev = 0;
_context3.next = 3;
return _this2.open();
server.on('listening', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
_context3.next = 3;
return _this2.open();
case 3:
_context3.next = 8;
break;
case 3:
_context3.next = 8;
break;
case 5:
_context3.prev = 5;
_context3.t0 = _context3['catch'](0);
case 5:
_context3.prev = 5;
_context3.t0 = _context3['catch'](0);
_this2.emit('error', _context3.t0);
_this2.emit('error', _context3.t0);
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this2, [[0, 5]]);
})));
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this2, [[0, 5]]);
})));
server.on('close', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.prev = 0;
_context4.next = 3;
return _this2.close();
server.on('close', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.prev = 0;
_context4.next = 3;
return _this2.close();
case 3:
_context4.next = 8;
case 3:
_context4.next = 8;
break;
case 5:
_context4.prev = 5;
_context4.t0 = _context4['catch'](0);
_this2.emit('error', _context4.t0);
case 8:
case 'end':
return _context4.stop();
}
}
}, _callee4, _this2, [[0, 5]]);
})));
if (!server.listening) {
_context5.next = 11;
break;
}
_context5.prev = 3;
_context5.next = 6;
return this.open();
case 6:
_context5.next = 11;
break;
case 5:
_context4.prev = 5;
_context4.t0 = _context4['catch'](0);
case 8:
_context5.prev = 8;
_context5.t0 = _context5['catch'](3);
_this2.emit('error', _context4.t0);
this.emit('error', _context5.t0);
case 8:
case 11:
case 'end':
return _context4.stop();
return _context5.stop();
}
}
}, _callee4, _this2, [[0, 5]]);
})));
}
}, _callee5, this, [[3, 8]]);
}));
function attach(_x2) {
return _ref3.apply(this, arguments);
}
return attach;
}()
/**

@@ -310,8 +367,8 @@ * Initialize a new connection for a `transport` stream with `context`.

value: function () {
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(transport) {
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(transport) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var closed, connections, server, connection, onError, id;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:

@@ -326,9 +383,10 @@ debug('listen');

if (!closed) {
_context5.next = 6;
_context6.next = 7;
break;
}
throw new _nexusError2.default('server_closed');
_context6.next = 7;
return this.open();
case 6:
case 7:
connection = new _connection2.default({ server: server, transport: transport, context: context });

@@ -347,12 +405,12 @@ onError = this.emit.bind(this, 'error');

case 12:
case 13:
case 'end':
return _context5.stop();
return _context6.stop();
}
}
}, _callee5, this);
}, _callee6, this);
}));
function connect(_x2) {
return _ref5.apply(this, arguments);
function connect(_x3) {
return _ref6.apply(this, arguments);
}

@@ -373,11 +431,11 @@

value: function () {
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(context) {
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(context) {
var types, transport, client;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context7.prev = _context7.next) {
case 0:
types = this.types;
transport = new _transport2.default();
_context6.next = 4;
_context7.next = 4;
return this.connect(transport.server, context);

@@ -387,14 +445,14 @@

client = new _client2.default({ types: types, transport: transport.client });
return _context6.abrupt('return', client);
return _context7.abrupt('return', client);
case 6:
case 'end':
return _context6.stop();
return _context7.stop();
}
}
}, _callee6, this);
}, _callee7, this);
}));
function client(_x4) {
return _ref6.apply(this, arguments);
function client(_x5) {
return _ref7.apply(this, arguments);
}

@@ -417,3 +475,3 @@

value: function () {
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(id, operation) {
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(id, operation) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -423,5 +481,5 @@

return regeneratorRuntime.wrap(function _callee7$(_context7) {
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context7.prev = _context7.next) {
switch (_context8.prev = _context8.next) {
case 0:

@@ -434,7 +492,7 @@ debug('submit', { id: id, operation: operation, options: options });

_options$retry = options.retry, retry = _options$retry === undefined ? 0 : _options$retry, context = options.context;
_context7.next = 6;
_context8.next = 6;
return this.findSnapshot(id, { context: context });
case 6:
snapshot = _context7.sent;
snapshot = _context8.sent;

@@ -453,3 +511,3 @@

if (!(operation.version > snapshot.version)) {
_context7.next = 12;
_context8.next = 12;
break;

@@ -462,15 +520,15 @@ }

if (!(operation.version < snapshot.version)) {
_context7.next = 48;
_context8.next = 48;
break;
}
_context7.next = 15;
_context8.next = 15;
return this.listOperations(id, operation.version, snapshot.version, { context: context });
case 15:
existing = _context7.sent;
existing = _context8.sent;
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context7.prev = 19;
_context8.prev = 19;
_iterator = existing[Symbol.iterator]();

@@ -480,3 +538,3 @@

if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
_context7.next = 34;
_context8.next = 34;
break;

@@ -488,3 +546,3 @@ }

if (!(operation.id === ex.id)) {
_context7.next = 25;
_context8.next = 25;
break;

@@ -497,3 +555,3 @@ }

if (!(operation.version !== ex.version)) {
_context7.next = 27;
_context8.next = 27;
break;

@@ -515,18 +573,18 @@ }

_iteratorNormalCompletion = true;
_context7.next = 21;
_context8.next = 21;
break;
case 34:
_context7.next = 40;
_context8.next = 40;
break;
case 36:
_context7.prev = 36;
_context7.t0 = _context7['catch'](19);
_context8.prev = 36;
_context8.t0 = _context8['catch'](19);
_didIteratorError = true;
_iteratorError = _context7.t0;
_iteratorError = _context8.t0;
case 40:
_context7.prev = 40;
_context7.prev = 41;
_context8.prev = 40;
_context8.prev = 41;

@@ -538,6 +596,6 @@ if (!_iteratorNormalCompletion && _iterator.return) {

case 43:
_context7.prev = 43;
_context8.prev = 43;
if (!_didIteratorError) {
_context7.next = 46;
_context8.next = 46;
break;

@@ -549,10 +607,10 @@ }

case 46:
return _context7.finish(43);
return _context8.finish(43);
case 47:
return _context7.finish(40);
return _context8.finish(40);
case 48:
if (!(operation.version !== snapshot.version)) {
_context7.next = 50;
_context8.next = 50;
break;

@@ -572,10 +630,10 @@ }

// Attempt to commit the resolve operation and snapshot.
_context7.next = 55;
_context8.next = 55;
return this.commit(id, operation, snapshot, { context: context });
case 55:
success = _context7.sent;
success = _context8.sent;
if (success) {
_context7.next = 63;
_context8.next = 63;
break;

@@ -585,3 +643,3 @@ }

if (!(retry <= maxRetries)) {
_context7.next = 62;
_context8.next = 62;
break;

@@ -591,7 +649,7 @@ }

debug('retry', { id: id, operation: operation, options: options });
_context7.next = 61;
_context8.next = 61;
return this.submit(id, operation, _extends({}, options, { retry: retry + 1 }));
case 61:
return _context7.abrupt('return', _context7.sent);
return _context8.abrupt('return', _context8.sent);

@@ -604,14 +662,14 @@ case 62:

this.publish(id, operation, { context: context });
return _context7.abrupt('return', operations);
return _context8.abrupt('return', operations);
case 65:
case 'end':
return _context7.stop();
return _context8.stop();
}
}
}, _callee7, this, [[19, 36, 40, 48], [41,, 43, 47]]);
}, _callee8, this, [[19, 36, 40, 48], [41,, 43, 47]]);
}));
function submit(_x5, _x6) {
return _ref7.apply(this, arguments);
function submit(_x6, _x7) {
return _ref8.apply(this, arguments);
}

@@ -636,8 +694,8 @@

value: function () {
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(id, operation, snapshot) {
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(id, operation, snapshot) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var context, success;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
return regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context9.prev = _context9.next) {
case 0:

@@ -650,10 +708,10 @@ debug('commit', { id: id, operation: operation, snapshot: snapshot, options: options });

context = options.context;
_context8.next = 6;
_context9.next = 6;
return this.store.commit(id, operation, snapshot, { context: context });
case 6:
success = _context8.sent;
success = _context9.sent;
if (!(typeof success !== 'boolean')) {
_context8.next = 9;
_context9.next = 9;
break;

@@ -665,14 +723,14 @@ }

case 9:
return _context8.abrupt('return', success);
return _context9.abrupt('return', success);
case 10:
case 'end':
return _context8.stop();
return _context9.stop();
}
}
}, _callee8, this);
}, _callee9, this);
}));
function commit(_x8, _x9, _x10) {
return _ref8.apply(this, arguments);
function commit(_x9, _x10, _x11) {
return _ref9.apply(this, arguments);
}

@@ -693,8 +751,8 @@

value: function () {
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(id) {
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(id) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var context, snapshot;
return regeneratorRuntime.wrap(function _callee9$(_context9) {
return regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {
switch (_context9.prev = _context9.next) {
switch (_context10.prev = _context10.next) {
case 0:

@@ -704,22 +762,22 @@ debug('findSnapshot', { id: id, options: options });

context = options.context;
_context9.next = 4;
_context10.next = 4;
return this.store.findSnapshot(id, { context: context });
case 4:
snapshot = _context9.sent;
snapshot = _context10.sent;
(0, _checkers.checkSnapshot)(snapshot);
return _context9.abrupt('return', snapshot);
return _context10.abrupt('return', snapshot);
case 7:
case 'end':
return _context9.stop();
return _context10.stop();
}
}
}, _callee9, this);
}, _callee10, this);
}));
function findSnapshot(_x12) {
return _ref9.apply(this, arguments);
function findSnapshot(_x13) {
return _ref10.apply(this, arguments);
}

@@ -744,9 +802,9 @@

value: function () {
var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(id, from) {
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(id, from) {
var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var context, ops;
return regeneratorRuntime.wrap(function _callee10$(_context10) {
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
switch (_context10.prev = _context10.next) {
switch (_context11.prev = _context11.next) {
case 0:

@@ -756,7 +814,7 @@ debug('listOperations', { id: id, from: from, to: to, options: options });

context = options.context;
_context10.next = 4;
_context11.next = 4;
return this.store.listOperations(id, from, to, { context: context });
case 4:
ops = _context10.sent;
ops = _context11.sent;

@@ -766,14 +824,14 @@ ops.forEach(function (op) {

});
return _context10.abrupt('return', ops);
return _context11.abrupt('return', ops);
case 7:
case 'end':
return _context10.stop();
return _context11.stop();
}
}
}, _callee10, this);
}, _callee11, this);
}));
function listOperations(_x14, _x15) {
return _ref10.apply(this, arguments);
function listOperations(_x15, _x16) {
return _ref11.apply(this, arguments);
}

@@ -797,3 +855,3 @@

value: function () {
var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(id, version) {
var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(id, version) {
var _this3 = this;

@@ -803,5 +861,5 @@

var context, subs, subscription, uid;
return regeneratorRuntime.wrap(function _callee12$(_context12) {
return regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {
switch (_context12.prev = _context12.next) {
switch (_context13.prev = _context13.next) {
case 0:

@@ -818,7 +876,7 @@ debug('subscribe', { id: id, version: version });

subscription._read = function () {};
subscription.once('close', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
subscription.once('close', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
var s;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
return regeneratorRuntime.wrap(function _callee12$(_context12) {
while (1) {
switch (_context11.prev = _context11.next) {
switch (_context12.prev = _context12.next) {
case 0:

@@ -828,7 +886,7 @@ s = _this3.subscriptions[id];

if (s) {
_context11.next = 3;
_context12.next = 3;
break;
}
return _context11.abrupt('return');
return _context12.abrupt('return');

@@ -839,7 +897,7 @@ case 3:

if (!(0, _isEmpty2.default)(s)) {
_context11.next = 7;
_context12.next = 7;
break;
}
_context11.next = 7;
_context12.next = 7;
return _this3.unsubscribe(id, { context: context });

@@ -849,14 +907,14 @@

case 'end':
return _context11.stop();
return _context12.stop();
}
}
}, _callee11, _this3);
}, _callee12, _this3);
})));
if (this.subscribed[id]) {
_context12.next = 12;
_context13.next = 12;
break;
}
_context12.next = 11;
_context13.next = 11;
return this.pubsub.subscribe(id, { context: context });

@@ -868,14 +926,14 @@

case 12:
return _context12.abrupt('return', subscription);
return _context13.abrupt('return', subscription);
case 13:
case 'end':
return _context12.stop();
return _context13.stop();
}
}
}, _callee12, this);
}, _callee13, this);
}));
function subscribe(_x18, _x19) {
return _ref11.apply(this, arguments);
function subscribe(_x19, _x20) {
return _ref12.apply(this, arguments);
}

@@ -896,8 +954,8 @@

value: function () {
var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(id) {
var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(id) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var context;
return regeneratorRuntime.wrap(function _callee13$(_context13) {
return regeneratorRuntime.wrap(function _callee14$(_context14) {
while (1) {
switch (_context13.prev = _context13.next) {
switch (_context14.prev = _context14.next) {
case 0:

@@ -910,3 +968,3 @@ debug('unsubscribe', { id: id });

delete this.subscribed[id];
_context13.next = 6;
_context14.next = 6;
return this.pubsub.unsubscribe(id, { context: context });

@@ -916,10 +974,10 @@

case 'end':
return _context13.stop();
return _context14.stop();
}
}
}, _callee13, this);
}, _callee14, this);
}));
function unsubscribe(_x21) {
return _ref13.apply(this, arguments);
function unsubscribe(_x22) {
return _ref14.apply(this, arguments);
}

@@ -941,8 +999,8 @@

value: function () {
var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(id, operation) {
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(id, operation) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var context;
return regeneratorRuntime.wrap(function _callee14$(_context14) {
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context14.prev = _context14.next) {
switch (_context15.prev = _context15.next) {
case 0:

@@ -952,3 +1010,3 @@ debug('publish', { id: id, operation: operation });

context = options.context;
_context14.next = 4;
_context15.next = 4;
return this.pubsub.publish(id, operation, { context: context });

@@ -958,10 +1016,10 @@

case 'end':
return _context14.stop();
return _context15.stop();
}
}
}, _callee14, this);
}, _callee15, this);
}));
function publish(_x23, _x24) {
return _ref14.apply(this, arguments);
function publish(_x24, _x25) {
return _ref15.apply(this, arguments);
}

@@ -982,7 +1040,7 @@

value: function () {
var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(id, operation) {
var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(id, operation) {
var subs, key, sub, copy;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
return regeneratorRuntime.wrap(function _callee16$(_context16) {
while (1) {
switch (_context15.prev = _context15.next) {
switch (_context16.prev = _context16.next) {
case 0:

@@ -994,7 +1052,7 @@ debug('broadcast', { id: id, operation: operation });

if (subs) {
_context15.next = 4;
_context16.next = 4;
break;
}
return _context15.abrupt('return');
return _context16.abrupt('return');

@@ -1012,10 +1070,10 @@ case 4:

case 'end':
return _context15.stop();
return _context16.stop();
}
}
}, _callee15, this);
}, _callee16, this);
}));
function broadcast(_x26, _x27) {
return _ref15.apply(this, arguments);
function broadcast(_x27, _x28) {
return _ref16.apply(this, arguments);
}

@@ -1022,0 +1080,0 @@

{
"name": "nexus",
"version": "0.3.0",
"version": "0.3.1",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "files": [

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