Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,5 @@ | ||
## 2.1.0 (February 23, 2016) | ||
Internal API change: made `Socket.emit` synchronous. | ||
## 2.0.1 (February 14, 2016) | ||
@@ -2,0 +6,0 @@ |
@@ -150,3 +150,5 @@ "use strict"; | ||
value: function sub(name, params) { | ||
var id = (0, _utils.uniqueId)(); | ||
var id = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
id || (id = (0, _utils.uniqueId)()); | ||
this.messageQueue.push({ | ||
@@ -153,0 +155,0 @@ msg: "sub", |
{ | ||
"name": "ddp.js", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "ddp javascript client", | ||
@@ -5,0 +5,0 @@ "main": "lib/ddp.js", |
@@ -113,4 +113,4 @@ import EventEmitter from "wolfy87-eventemitter"; | ||
sub (name, params) { | ||
const id = uniqueId(); | ||
sub (name, params, id = null) { | ||
id || (id = uniqueId()); | ||
this.messageQueue.push({ | ||
@@ -117,0 +117,0 @@ msg: "sub", |
@@ -121,2 +121,18 @@ import chai, {expect} from "chai"; | ||
it("generates unique id when not specified", () => { | ||
const ddp = new DDP(options); | ||
var ids = []; | ||
ids.push(ddp.sub("echo", [ 0 ])); | ||
ids.push(ddp.sub("echo", [ 0 ])); | ||
expect(ids[0]).to.be.a("string"); | ||
expect(ids[1]).to.be.a("string"); | ||
expect(ids[0]).not.to.equal(ids[1]); | ||
}); | ||
it("allows manually specifying sub's id", () => { | ||
const ddp = new DDP(options); | ||
const subId = ddp.sub("echo", [ 0 ], "12345"); | ||
expect(subId).to.equal("12345"); | ||
}); | ||
}); | ||
@@ -123,0 +139,0 @@ |
77495
1560