radar_client
Advanced tools
Comparing version 0.9.3 to 0.10.0
@@ -0,1 +1,4 @@ | ||
### 0.10.0 | ||
* emit message events in a new context to avoid errors | ||
### 0.9.3 | ||
@@ -2,0 +5,0 @@ * Perform a prepublish check for outdated dependencies and dirty working tree |
@@ -41,7 +41,9 @@ (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}; | ||
}, | ||
"lib/radar_client.js": function(module, exports, require){var log = require('minilog')('radar_client'), | ||
"lib/radar_client.js": function(module, exports, require){/* globals setImmediate */ | ||
var log = require('minilog')('radar_client'), | ||
MicroEE = require('microee'), | ||
eio = require('engine.io-client'), | ||
Scope = require('./scope.js'), | ||
StateMachine = require('./state.js'); | ||
StateMachine = require('./state.js'), | ||
immediate = typeof setImmediate != 'undefined' ? setImmediate : function(fn) { setTimeout(fn, 1); }; | ||
@@ -291,3 +293,3 @@ function Client(backend) { | ||
if (time > current) { | ||
this.emit(message.to, data); | ||
this.emitNext(message.to, data); | ||
} | ||
@@ -440,3 +442,3 @@ if (time > newest) { | ||
case 'get': | ||
this.emit(message.op, message); | ||
this.emitNext(message.op, message); | ||
break; | ||
@@ -447,6 +449,11 @@ case 'sync': | ||
default: | ||
this.emit(message.to, message); | ||
this.emitNext(message.to, message); | ||
} | ||
}; | ||
Client.prototype.emitNext = function() { | ||
var args = Array.prototype.slice.call(arguments), client = this; | ||
immediate(function(){ client.emit.apply(client, args); }); | ||
}; | ||
Client.setBackend = function(lib) { eio = lib; }; | ||
@@ -453,0 +460,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* globals setImmediate */ | ||
var log = require('minilog')('radar_client'), | ||
@@ -5,3 +6,4 @@ MicroEE = require('microee'), | ||
Scope = require('./scope.js'), | ||
StateMachine = require('./state.js'); | ||
StateMachine = require('./state.js'), | ||
immediate = typeof setImmediate != 'undefined' ? setImmediate : function(fn) { setTimeout(fn, 1); }; | ||
@@ -251,3 +253,3 @@ function Client(backend) { | ||
if (time > current) { | ||
this.emit(message.to, data); | ||
this.emitNext(message.to, data); | ||
} | ||
@@ -400,3 +402,3 @@ if (time > newest) { | ||
case 'get': | ||
this.emit(message.op, message); | ||
this.emitNext(message.op, message); | ||
break; | ||
@@ -407,8 +409,13 @@ case 'sync': | ||
default: | ||
this.emit(message.to, message); | ||
this.emitNext(message.to, message); | ||
} | ||
}; | ||
Client.prototype.emitNext = function() { | ||
var args = Array.prototype.slice.call(arguments), client = this; | ||
immediate(function(){ client.emit.apply(client, args); }); | ||
}; | ||
Client.setBackend = function(lib) { eio = lib; }; | ||
module.exports = Client; |
{ | ||
"name": "radar_client", | ||
"description": "Realtime apps with a high level API based on engine.io", | ||
"version": "0.9.3", | ||
"version": "0.10.0", | ||
"author": "Mikito Takada <mikito.takada@gmail.com>", | ||
@@ -45,16 +45,11 @@ "contributors": [ | ||
"check-modules": "if [ -z \"$SKIP_PACKAGE_CHECK\" ] && [ ./package.json -nt ./node_modules ]; then npm run warn-outdated && exit 1; else rm -rf ./node_modules/sfsm/demo; fi", | ||
"warn-outdated": "echo 'Your node_modules are out of date. Please run \"rm -rf node_modules && npm install\" in order to ensure you have the latest dependencies.'", | ||
"warn-dirty-tree": "echo 'Your repo tree is dirty.'", | ||
"pretest": "npm run build", | ||
"test": "ls ./tests/*.test.js | xargs -n 1 -t -I {} sh -c 'TEST=\"{}\" npm run test-one'", | ||
"test-one": "./node_modules/.bin/mocha --ui exports --reporter spec --slow 2000ms --bail \"$TEST\"", | ||
"prebuild": "npm run check-modules", | ||
"build": "./node_modules/gluejs/bin/gluejs --include ./lib --npm microee,sfsm --replace engine.io-client=eio,minilog=Minilog --global RadarClient --main lib/index.js --out dist/radar_client.js", | ||
"prepublish": "npm run build && npm run check-clean || echo 'You cannot publish with outdated dependecies or uncommitted build changes.'" | ||
} | ||
} |
@@ -334,3 +334,2 @@ var assert = require('assert'), | ||
}); | ||
assert.equal(3, received.length); | ||
client._batch({ | ||
@@ -348,5 +347,6 @@ to: 'foo', | ||
}); | ||
assert.equal(4, received.length); | ||
done(); | ||
setTimeout(function() { | ||
assert.equal(4, received.length); | ||
done(); | ||
}, 10); | ||
} | ||
@@ -353,0 +353,0 @@ }; |
@@ -664,3 +664,3 @@ var assert = require('assert'), | ||
client.emit = function(name, data) { | ||
client.emitNext = function(name, data) { | ||
called = true; | ||
@@ -901,3 +901,3 @@ assert.equal(name, message.to); | ||
client.emit = function(name, data) { | ||
client.emitNext = function(name, data) { | ||
if(name === 'message:in') return; | ||
@@ -920,3 +920,3 @@ called = true; | ||
client.emit = function(name, data) { | ||
client.emitNext = function(name, data) { | ||
if(name === 'message:in') return; | ||
@@ -939,3 +939,3 @@ called = true; | ||
client.emit = function(name, data) { | ||
client.emitNext = function(name, data) { | ||
if(name === 'message:in') return; | ||
@@ -975,3 +975,3 @@ called = true; | ||
client.emit = function(name, data) { | ||
client.emitNext = function(name, data) { | ||
if(name === 'message:in') return; | ||
@@ -978,0 +978,0 @@ |
101297
2723