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

radar_client

Package Overview
Dependencies
Maintainers
6
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radar_client - npm Package Compare versions

Comparing version 0.13.0 to 0.13.1

5

Changelog.md

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

### 0.13.1
* Code cleanup
- comment capitalization, comment line length, code line length
- minor code standardization
### 0.13.0

@@ -2,0 +7,0 @@ * server version bump

57

dist/radar_client.js

@@ -47,3 +47,4 @@ (function(){function require(e,t){for(var n=[],r=e.split("/"),i,s,o=0;s=r[o++];)".."==s?n.pop():"."!=s&&n.push(s);n=n.join("/"),o=require,s=o.m[t||0],i=s[n+".js"]||s[n+"/index.js"]||s[n];if(s=i.c)i=o.m[t=s][e=i.m];return i.exports||i(i,i.exports={},function(n){return o("."!=n.charAt(0)?n:e+"/../"+n,t)}),i.exports};

StateMachine = require('./state.js'),
immediate = typeof setImmediate != 'undefined' ? setImmediate : function(fn) { setTimeout(fn, 1); };
immediate = typeof setImmediate != 'undefined' ? setImmediate :
function(fn) { setTimeout(fn, 1); };

@@ -61,3 +62,3 @@ function Client(backend) {

// allow backend substitution for tests
// Allow backend substitution for tests
this.backend = backend || eio;

@@ -69,3 +70,3 @@

this.on('authenticateMessage', function(message) {
if(this._configuration) {
if (this._configuration) {
message.userData = this._configuration.userData;

@@ -96,3 +97,3 @@ if (this._configuration.auth) {

var self = this;
if(!this._users[name]) {
if (!this._users[name]) {
this.logger().info('alloc: ', name);

@@ -105,3 +106,3 @@ this.once('ready', function() {

callback && this.once('ready', function() {
if(self._users.hasOwnProperty(name)) {
if (self._users.hasOwnProperty(name)) {
callback();

@@ -233,3 +234,3 @@ }

var message = { op: name, to: scope };
// options is a optional argument
// options is an optional argument
if (typeof options == 'function') {

@@ -240,4 +241,4 @@ callback = options;

}
// sync v1 for presence scopes acts inconsistently. The result should be a "get" message,
// but it is actually a "online" message.
// Sync v1 for presence scopes acts inconsistently. The result should be a
// "get" message, but it is actually a "online" message.
// So force v2 and translate the result to v1 format.

@@ -254,2 +255,4 @@ if (name == 'sync' && !message.options && scope.match(/^presence.+/)) {

if (message.value.hasOwnProperty(userId)) {
// Skip when not defined; causes exception in FF for 'Work Offline'
if (!message.value[userId]) { continue; }
value[userId] = message.value[userId].userType;

@@ -260,3 +263,3 @@ }

message.op = 'online';
if(callback) {
if (callback) {
callback(message);

@@ -277,3 +280,4 @@ }

}
// sync/get never register or retuin acks (since they always send back a data message)
// sync/get never register or return acks (since they always send back a
// data message)
return this._write(message);

@@ -291,8 +295,8 @@ };

if(callback) {
if (callback) {
message.ack = this._ackCounter++;
// wait ack
// Wait ack
this.when('ack', function(m) {
client.logger().debug('ack', m);
if(!m || !m.value || m.value != message.ack) {
if (!m || !m.value || m.value != message.ack) {
return false;

@@ -356,6 +360,7 @@ }

// Patch for polling-xhr continuing to poll after socket close (HTTP:POST failure).
// socket.transport is in error but not closed, so if a subsequent poll succeeds,
// the transport remains open and polling until server closes the socket.
if(socket.transport) {
// Patch for polling-xhr continuing to poll after socket close (HTTP:POST
// failure). socket.transport is in error but not closed, so if a subsequent
// poll succeeds, the transport remains open and polling until server closes
// the socket.
if (socket.transport) {
socket.transport.close();

@@ -385,3 +390,3 @@ }

manager.on('authenticate', function() {
// can be overridden in order to establish an authentication protocol
// Can be overridden in order to establish an authentication protocol
manager.activate();

@@ -395,9 +400,8 @@ });

// Memorize subscriptions and presence states
// returns true for a message that adds to the
// memorized subscriptions or presences
// Memorize subscriptions and presence states; return "true" for a message that
// adds to the memorized subscriptions or presences
Client.prototype._memorize = function(message) {
switch(message.op) {
case 'unsubscribe':
// remove from queue
// Remove from queue
if (this._subscriptions[message.to]) {

@@ -545,3 +549,4 @@ delete this._subscriptions[message.to];

onevent: function(event, from, to) {
log.debug('before-' + event + ', from: ' + from + ', to: ' + to, Array.prototype.slice.call(arguments));
log.debug('before-' + event + ', from: ' + from + ', to: ' + to,
Array.prototype.slice.call(arguments));

@@ -553,3 +558,4 @@ this.emit('event', event);

onstate: function(event, from, to) {
log.debug('event-state-' + event + ', from: ' + from + ', to: ' + to, Array.prototype.slice.call(arguments));
log.debug('event-state-' + event + ', from: ' + from + ', to: ' + to,
Array.prototype.slice.call(arguments));

@@ -599,3 +605,4 @@ this.emit('enterState', to);

machine._backoff = backoff; // for testing
// For testing
machine._backoff = backoff;
machine._connectTimeout = 10000;

@@ -602,0 +609,0 @@

@@ -7,3 +7,4 @@ /* globals setImmediate */

StateMachine = require('./state.js'),
immediate = typeof setImmediate != 'undefined' ? setImmediate : function(fn) { setTimeout(fn, 1); };
immediate = typeof setImmediate != 'undefined' ? setImmediate :
function(fn) { setTimeout(fn, 1); };

@@ -21,3 +22,3 @@ function Client(backend) {

// allow backend substitution for tests
// Allow backend substitution for tests
this.backend = backend || eio;

@@ -29,3 +30,3 @@

this.on('authenticateMessage', function(message) {
if(this._configuration) {
if (this._configuration) {
message.userData = this._configuration.userData;

@@ -56,3 +57,3 @@ if (this._configuration.auth) {

var self = this;
if(!this._users[name]) {
if (!this._users[name]) {
this.logger().info('alloc: ', name);

@@ -65,3 +66,3 @@ this.once('ready', function() {

callback && this.once('ready', function() {
if(self._users.hasOwnProperty(name)) {
if (self._users.hasOwnProperty(name)) {
callback();

@@ -193,3 +194,3 @@ }

var message = { op: name, to: scope };
// options is a optional argument
// options is an optional argument
if (typeof options == 'function') {

@@ -200,4 +201,4 @@ callback = options;

}
// sync v1 for presence scopes acts inconsistently. The result should be a "get" message,
// but it is actually a "online" message.
// Sync v1 for presence scopes acts inconsistently. The result should be a
// "get" message, but it is actually a "online" message.
// So force v2 and translate the result to v1 format.

@@ -221,3 +222,3 @@ if (name == 'sync' && !message.options && scope.match(/^presence.+/)) {

message.op = 'online';
if(callback) {
if (callback) {
callback(message);

@@ -238,3 +239,4 @@ }

}
// sync/get never register or retuin acks (since they always send back a data message)
// sync/get never register or return acks (since they always send back a
// data message)
return this._write(message);

@@ -252,8 +254,8 @@ };

if(callback) {
if (callback) {
message.ack = this._ackCounter++;
// wait ack
// Wait ack
this.when('ack', function(m) {
client.logger().debug('ack', m);
if(!m || !m.value || m.value != message.ack) {
if (!m || !m.value || m.value != message.ack) {
return false;

@@ -317,6 +319,7 @@ }

// Patch for polling-xhr continuing to poll after socket close (HTTP:POST failure).
// socket.transport is in error but not closed, so if a subsequent poll succeeds,
// the transport remains open and polling until server closes the socket.
if(socket.transport) {
// Patch for polling-xhr continuing to poll after socket close (HTTP:POST
// failure). socket.transport is in error but not closed, so if a subsequent
// poll succeeds, the transport remains open and polling until server closes
// the socket.
if (socket.transport) {
socket.transport.close();

@@ -346,3 +349,3 @@ }

manager.on('authenticate', function() {
// can be overridden in order to establish an authentication protocol
// Can be overridden in order to establish an authentication protocol
manager.activate();

@@ -356,9 +359,8 @@ });

// Memorize subscriptions and presence states
// returns true for a message that adds to the
// memorized subscriptions or presences
// Memorize subscriptions and presence states; return "true" for a message that
// adds to the memorized subscriptions or presences
Client.prototype._memorize = function(message) {
switch(message.op) {
case 'unsubscribe':
// remove from queue
// Remove from queue
if (this._subscriptions[message.to]) {

@@ -365,0 +367,0 @@ delete this._subscriptions[message.to];

@@ -30,3 +30,4 @@ var log = require('minilog')('radar_state'),

onevent: function(event, from, to) {
log.debug('before-' + event + ', from: ' + from + ', to: ' + to, Array.prototype.slice.call(arguments));
log.debug('before-' + event + ', from: ' + from + ', to: ' + to,
Array.prototype.slice.call(arguments));

@@ -38,3 +39,4 @@ this.emit('event', event);

onstate: function(event, from, to) {
log.debug('event-state-' + event + ', from: ' + from + ', to: ' + to, Array.prototype.slice.call(arguments));
log.debug('event-state-' + event + ', from: ' + from + ', to: ' + to,
Array.prototype.slice.call(arguments));

@@ -84,3 +86,4 @@ this.emit('enterState', to);

machine._backoff = backoff; // for testing
// For testing
machine._backoff = backoff;
machine._connectTimeout = 10000;

@@ -87,0 +90,0 @@

{
"name": "radar_client",
"description": "Realtime apps with a high level API based on engine.io",
"version": "0.13.0",
"version": "0.13.1",
"author": "Mikito Takada <mikito.takada@gmail.com>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -55,3 +55,3 @@ var assert = require('assert'),

// if this module is the script being run, then run the tests:
// When this module is the script being run, run the tests:
if (module == require.main) {

@@ -58,0 +58,0 @@ var mocha = require('child_process').spawn('mocha', [ '--colors', '--ui', 'exports', '--reporter', 'spec', __filename ]);

@@ -16,7 +16,7 @@ var MicroEE = require('microee'),

log(message);
if(message.op == 'get' || message.op == 'sync') {
if (message.op == 'get' || message.op == 'sync') {
current.emit('message', data);
}
// ACKs should be returned immediately
if(message.ack) {
if (message.ack) {
current.emit('message', JSON.stringify({"op":"ack","value": message.ack}));

@@ -23,0 +23,0 @@ }

@@ -36,3 +36,3 @@ var assert = require('assert'),

setTimeout(function() {
// we use a setTimeout, because connecting with the fake backend
// We use a setTimeout, because connecting with the fake backend
// is also async, it just takes 5 ms rather than a real connect duration

@@ -49,3 +49,3 @@ assert.ok(client.manager.is('opened'));

setTimeout(function() {
// we use a setTimeout, because connecting with the fake backend
// We use a setTimeout, because connecting with the fake backend
// is also async, it just takes 5 ms rather than a real connect duration

@@ -60,3 +60,3 @@ assert.ok(client.manager.is('activated'));

setTimeout(function() {
// we use a setTimeout, because connecting with the fake backend
// We use a setTimeout, because connecting with the fake backend
// is also async, it just takes 5 ms rather than a real connect duration

@@ -80,3 +80,3 @@ assert.ok(client.manager.is('opened'));

client.configure({ userId: 123, accountName: 'dev' });
// also test that the callback param works
// Test that the callback param works
function onAlloc() {

@@ -87,9 +87,9 @@ allocDoneCount++;

setTimeout(function() {
assert.ok(client.manager.is('activated')); // = Ready state
// Ready state == 'activated'
assert.ok(client.manager.is('activated'));
assert.equal(readyCount, 1);
assert.equal(allocDoneCount, 1);
// if the connect code would trigger, then these would
// not run the on('ready') action immediately.
// If the action is run immediately, we know that the
// connection code was skipped.
// If the connect code would trigger, then these would not run the
// on('ready') action immediately. If the action is run immediately, we
// know that the connection code was skipped.
// Might rewrite this to be more explicit later.

@@ -128,3 +128,3 @@ client.alloc('foo');

// if this module is the script being run, then run the tests:
// When this module is the script being run, run the tests:
if (module == require.main) {

@@ -131,0 +131,0 @@ var mocha = require('child_process').spawn('mocha', [ '--colors', '--ui', 'exports', '--reporter', 'spec', __filename ]);

@@ -13,3 +13,2 @@ var assert = require('assert'),

client.once('presence:tickets:21', function(changes) {
// test.equal('presence:tickets:21', scope);
assert.deepEqual([1], changes.online);

@@ -19,3 +18,3 @@ assert.deepEqual([], changes.offline);

// send an online message
// Send an online message
client.emit('presence:tickets:21', { online: [1], offline: []});

@@ -25,3 +24,2 @@

client.once('presence:tickets:21', function(changes) {
// test.equal('presence:tickets:21', scope);
assert.deepEqual([], changes.online);

@@ -33,3 +31,2 @@ assert.deepEqual([1], changes.offline);

client.emit('presence:tickets:21', { online: [], offline: [1]});
},

@@ -66,3 +63,3 @@

// if this module is the script being run, then run the tests:
// When this module is the script being run, run the tests:
if (module == require.main) {

@@ -69,0 +66,0 @@ var mocha = require('child_process').spawn('mocha', [ '--colors', '--ui', 'exports', '--reporter', 'spec', __filename ]);

@@ -39,3 +39,3 @@ var assert = require('assert'),

client.alloc('test', function() {
// this should never be called because of the dealloc
// This should never be called because of the dealloc
assert.ok(false);

@@ -354,3 +354,3 @@ });

// if this module is the script being run, then run the tests:
// When this module is the script being run, run the tests:
if (module == require.main) {

@@ -357,0 +357,0 @@ var mocha = require('child_process').spawn('mocha', [ '--colors', '--ui', 'exports', '--reporter', 'spec', __filename ]);

@@ -426,3 +426,3 @@ var assert = require('assert'),

//previous online emits should not affect the callback
// Previous online emits should not affect the callback
client.emit(scope, { op: 'online', to: scope, value: { 100: 2 } });

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

client._memorize({ op: 'get', to: 'bar' });
// should be a no-op
// Should be a no-op
assert.equal(2, Object.keys(client._subscriptions).length);

@@ -465,3 +465,3 @@

assert.equal(1, Object.keys(client._presences).length);
// duplicate should be ignored
// Duplicate should be ignored
client._memorize({ op: 'set', to: 'presence:/foo/bar', value: 'online' });

@@ -477,7 +477,7 @@ assert.equal(1, Object.keys(client._presences).length);

'memorizing a unsubscribe should remove any sync/subscribe': function(done) {
// set up
// Set up
client._memorize({ op: 'subscribe', to: 'foo'});
client._memorize({ op: 'sync', to: 'bar'});
assert.equal(2, Object.keys(client._subscriptions).length);
// unsubscribe
// Unsubscribe
client._memorize({ op: 'unsubscribe', to: 'foo'});

@@ -491,3 +491,3 @@ assert.equal(1, Object.keys(client._subscriptions).length);

'duplicated subscribes and syncs should only be stored once and sync is more important than subscribe': function(done) {
// simple duplicates
// Simple duplicates
client._memorize({ op: 'subscribe', to: 'foo'});

@@ -500,3 +500,3 @@ assert.equal(1, Object.keys(client._subscriptions).length);

client._subscriptions = {};
// simple duplicates
// Simple duplicates
client._memorize({ op: 'sync', to: 'abc'});

@@ -508,3 +508,3 @@ assert.equal(1, Object.keys(client._subscriptions).length);

client._subscriptions = {};
// sync after subscribe
// Sync after subscribe
client._memorize({ op: 'sync', to: 'bar'});

@@ -517,7 +517,7 @@ assert.equal(1, Object.keys(client._subscriptions).length);

client._subscriptions = {};
// subscribe after sync
// Subscribe after sync
client._memorize({ op: 'sync', to: 'baz'});
assert.equal(1, Object.keys(client._subscriptions).length);
assert.equal('sync', client._subscriptions.baz);
// if we sync and subscribe, it means just sync
// When we sync and subscribe, it means just sync
client._memorize({ op: 'subscribe', to: 'baz'});

@@ -909,3 +909,3 @@ assert.equal(1, Object.keys(client._subscriptions).length);

client.emitNext = function(name, data) {
if(name === 'message:in') return;
if (name === 'message:in') return;
called = true;

@@ -928,3 +928,3 @@ assert.equal(name, message.op);

client.emitNext = function(name, data) {
if(name === 'message:in') return;
if (name === 'message:in') return;
called = true;

@@ -947,3 +947,3 @@ assert.equal(name, message.op);

client.emitNext = function(name, data) {
if(name === 'message:in') return;
if (name === 'message:in') return;
called = true;

@@ -983,3 +983,3 @@ assert.equal(name, message.op);

client.emitNext = function(name, data) {
if(name === 'message:in') return;
if (name === 'message:in') return;

@@ -986,0 +986,0 @@ called = true;

@@ -5,11 +5,3 @@ var assert = require('assert'),

machine;
/*
Minilog = require('minilog'),
stdoutPipe = Minilog.pipe(Minilog.backends.nodeConsole);
// configure log output
stdoutPipe
.filter(Minilog.backends.nodeConsole.filterEnv("*"))
.format(Minilog.backends.nodeConsole.formatWithStack);
*/
exports['given a state machine'] = {

@@ -91,3 +83,4 @@ beforeEach: function() {

setTimeout(function() {
assert.equal(disconnects, 1); // only 1 disconnect due to manager.disconnect()
// Only 1 disconnect due to manager.disconnect()
assert.equal(disconnects, 1);
done();

@@ -97,3 +90,3 @@ }, 15000);

machine.on('connect', function() {
if(once) {
if (once) {
machine.disconnect();

@@ -140,3 +133,3 @@ once = false;

// if this module is the script being run, then run the tests:
// When this module is the script being run, run the tests:
if (module == require.main) {

@@ -143,0 +136,0 @@ var mocha = require('child_process').spawn('mocha', [ '--colors', '--ui', 'exports', '--reporter', 'spec', __filename ]);

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