Comparing version 1.3.0 to 1.4.0
@@ -16,46 +16,37 @@ /*jslint node: true */ | ||
{ | ||
var topicMap = new Map().set(val.topic, val.qos); | ||
return new Map().set(val.clientId, topicMap); | ||
return { | ||
topic: val.topic, | ||
clientMap: new Map().set(val.clientId, val.qos) | ||
}; | ||
}; | ||
QlobberSub.prototype._add_value = function (clientMap, val) | ||
QlobberSub.prototype._add_value = function (existing, val) | ||
{ | ||
var topicMap = clientMap.get(val.clientId); | ||
if (!topicMap) | ||
{ | ||
topicMap = new Map(); | ||
clientMap.set(val.clientId, topicMap); | ||
} | ||
topicMap.set(val.topic, val.qos); | ||
existing.clientMap.set(val.clientId, val.qos); | ||
}; | ||
QlobberSub.prototype._add_values = function (dest, clientMap, topic) | ||
QlobberSub.prototype._add_values = function (dest, existing, topic) | ||
{ | ||
for (var clientIdAndTopicMap of clientMap) | ||
var clientIdAndQos; | ||
if (topic === undefined) | ||
{ | ||
var clientId = clientIdAndTopicMap[0]; | ||
var topicMap = clientIdAndTopicMap[1]; | ||
if (topic === undefined) | ||
for (clientIdAndQos of existing.clientMap) | ||
{ | ||
for (var topicAndQos of topicMap) | ||
dest.push( | ||
{ | ||
dest.push( | ||
{ | ||
clientId: clientId, | ||
topic: topicAndQos[0], | ||
qos: topicAndQos[1] | ||
}); | ||
} | ||
clientId: clientIdAndQos[0], | ||
topic: existing.topic, | ||
qos: clientIdAndQos[1] | ||
}); | ||
} | ||
else | ||
} | ||
else if (existing.topic === topic) | ||
{ | ||
for (clientIdAndQos of existing.clientMap) | ||
{ | ||
var qos = topicMap.get(topic); | ||
if (qos !== undefined) | ||
dest.push( | ||
{ | ||
dest.push( | ||
{ | ||
clientId: clientId, | ||
qos: qos | ||
}); | ||
} | ||
clientId: clientIdAndQos[0], | ||
qos: clientIdAndQos[1] | ||
}); | ||
} | ||
@@ -65,20 +56,12 @@ } | ||
QlobberSub.prototype._remove_value = function (clientMap, val) | ||
QlobberSub.prototype._remove_value = function (existing, val) | ||
{ | ||
var topicMap = clientMap.get(val.clientId); | ||
if (topicMap) | ||
{ | ||
topicMap.delete(val.topic); | ||
if (topicMap.size === 0) | ||
{ | ||
clientMap.delete(val.clientId); | ||
} | ||
} | ||
return clientMap.size === 0; | ||
existing.clientMap.delete(val.clientId); | ||
return existing.clientMap.size === 0; | ||
}; | ||
QlobberSub.prototype.test_values = function (clientMap, val) | ||
QlobberSub.prototype.test_values = function (existing, val) | ||
{ | ||
var topicMap = clientMap.get(val.clientId); | ||
return topicMap && topicMap.has(val.topic); | ||
return (existing.topic === val.topic) && | ||
existing.clientMap.has(val.clientId); | ||
}; | ||
@@ -85,0 +68,0 @@ |
@@ -9,3 +9,3 @@ /*jslint node: true */ | ||
jshint: { | ||
all: [ 'Gruntfile.js', 'index.js', 'lib/*.js', 'aedes/*.js', 'test/*.js', 'bench/**/*.js' ], | ||
all: [ 'Gruntfile.js', 'index.js', 'lib/*.js', 'aedes/**/*.js', 'test/*.js', 'bench/**/*.js' ], | ||
options: { | ||
@@ -12,0 +12,0 @@ esversion: 6 |
{ | ||
"name": "qlobber", | ||
"description": "Node.js globbing for amqp-like topics", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"homepage": "https://github.com/davedoesdev/qlobber", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -246,3 +246,3 @@ /*jshint node: true, mocha: true */ | ||
it("removing value not added shouldn't affect match", function () | ||
it("removing value shouldn't care about topic", function () | ||
{ | ||
@@ -274,7 +274,2 @@ var matcher = new QlobberSub(); | ||
{ | ||
clientId: 'test1', | ||
topic: 'foo.bar', | ||
qos: 1 | ||
}, | ||
{ | ||
clientId: 'test2', | ||
@@ -288,3 +283,3 @@ topic: 'foo.bar', | ||
topic: 'foo.bar' | ||
})).to.equal(true); | ||
})).to.equal(false); | ||
expect(matcher.test('foo.bar', | ||
@@ -291,0 +286,0 @@ { |
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
230318
52
2737