Comparing version 1.7.0 to 1.8.0
@@ -10,3 +10,3 @@ /*jslint node: true */ | ||
Qlobber.call(this, options); | ||
this.sub_count = 0; | ||
this.subscriptionsCount = 0; | ||
} | ||
@@ -18,3 +18,4 @@ | ||
{ | ||
this.sub_count += 1; | ||
this.subscriptionsCount += 1; | ||
return { | ||
@@ -29,3 +30,3 @@ topic: val.topic, | ||
var clientMap = existing.clientMap, | ||
size = existing.clientMap.size; | ||
size = clientMap.size; | ||
@@ -36,3 +37,3 @@ clientMap.set(val.clientId, val.qos); | ||
{ | ||
this.sub_count += 1; | ||
this.subscriptionsCount += 1; | ||
} | ||
@@ -80,3 +81,3 @@ }; | ||
{ | ||
this.sub_count -= 1; | ||
this.subscriptionsCount -= 1; | ||
} | ||
@@ -90,5 +91,7 @@ | ||
{ | ||
return (existing.topic === val.topic) && | ||
(existing.clientMap.size === 1) && | ||
existing.clientMap.has(val.clientId); | ||
var clientMap = existing.clientMap; | ||
return (existing.topic === val.topic) && | ||
(clientMap.size === 1) && | ||
clientMap.has(val.clientId); | ||
}; | ||
@@ -98,3 +101,3 @@ | ||
{ | ||
return this._match([], 0, topic.split(this._separator), this._trie, ctx); | ||
return this._match([], 0, topic.split(this._separator), this._trie, ctx); | ||
}; | ||
@@ -104,3 +107,3 @@ | ||
{ | ||
this.sub_count = 0; | ||
this.subscriptionsCount = 0; | ||
return Qlobber.prototype.clear.call(this); | ||
@@ -107,0 +110,0 @@ }; |
@@ -494,6 +494,6 @@ /** | ||
{ | ||
this._trie = new Map(); | ||
this._trie.clear(); | ||
if (this._shortcuts) | ||
{ | ||
this._shortcuts = new Map(); | ||
this._shortcuts.clear(); | ||
} | ||
@@ -500,0 +500,0 @@ return this; |
{ | ||
"name": "qlobber", | ||
"description": "Node.js globbing for amqp-like topics", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"homepage": "https://github.com/davedoesdev/qlobber", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -12,3 +12,3 @@ /*jshint node: true, mocha: true */ | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -20,3 +20,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -43,3 +43,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -51,3 +51,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.bar', | ||
@@ -59,3 +59,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -82,3 +82,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -90,3 +90,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.bar', | ||
@@ -98,3 +98,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(2); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -126,3 +126,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -134,3 +134,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.*', | ||
@@ -142,3 +142,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(2); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -180,3 +180,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -188,3 +188,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.bar', | ||
@@ -196,3 +196,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(2); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
matcher.remove('foo.bar', | ||
@@ -203,3 +203,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -226,3 +226,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -234,3 +234,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.*', | ||
@@ -242,3 +242,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(2); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
matcher.add('foo.bar', | ||
@@ -250,3 +250,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(3); | ||
expect(matcher.subscriptionsCount).to.equal(3); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -287,3 +287,3 @@ { | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -295,3 +295,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.bar', | ||
@@ -303,3 +303,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(2); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
matcher.remove('foo.bar', | ||
@@ -310,3 +310,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.remove('foo.bar', | ||
@@ -317,3 +317,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -340,3 +340,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.remove('foo.bar', | ||
@@ -347,3 +347,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
}); | ||
@@ -354,3 +354,3 @@ | ||
var matcher = new QlobberSub(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
@@ -362,3 +362,3 @@ { | ||
}); | ||
expect(matcher.sub_count).to.equal(1); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
expect(matcher.match('foo.bar')).to.eql([ | ||
@@ -381,3 +381,3 @@ { | ||
matcher.clear(); | ||
expect(matcher.sub_count).to.equal(0); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
expect(matcher.match('foo.bar')).to.eql([]); | ||
@@ -395,2 +395,35 @@ expect(matcher.test('foo.bar', | ||
}); | ||
it('should count client subscription if has an existing subscription and is then added to a topic which already has a subscription for another client', function () | ||
{ | ||
var matcher = new QlobberSub(); | ||
expect(matcher.subscriptionsCount).to.equal(0); | ||
matcher.add('foo.bar', | ||
{ | ||
clientId: 'test1', | ||
topic: 'foo.bar', | ||
qos: 1 | ||
}); | ||
expect(matcher.subscriptionsCount).to.equal(1); | ||
matcher.add('foo.*', | ||
{ | ||
clientId: 'test2', | ||
topic: 'foo.bar', | ||
qos: 1 | ||
}); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
matcher.add('foo.*', | ||
{ | ||
clientId: 'test1', | ||
topic: 'foo.bar', | ||
qos: 1 | ||
}); | ||
expect(matcher.subscriptionsCount).to.equal(3); | ||
matcher.remove('foo.*', | ||
{ | ||
clientId: 'test1', | ||
topic: 'foo.bar', | ||
}); | ||
expect(matcher.subscriptionsCount).to.equal(2); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242276
3028