Skip to content

Commit

Permalink
Use object shorthand for properties (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU authored Apr 26, 2020
1 parent a69f079 commit 247bae4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function abstractPersistence (opts) {
const mq = buildEmitter()
const broker = {
id: 'broker-42',
mq: mq,
mq,
publish: mq.emit.bind(mq),
subscribe: mq.on.bind(mq),
unsubscribe: mq.removeListener.bind(mq),
Expand Down Expand Up @@ -505,8 +505,8 @@ function abstractPersistence (opts) {
testInstance('replace subscriptions', function (t, instance) {
const client = { id: 'abcde' }
const topic = 'hello'
const sub = { topic: topic }
const subByTopic = { clientId: client.id, topic: topic }
const sub = { topic }
const subByTopic = { clientId: client.id, topic }

function check (qos, cb) {
sub.qos = subByTopic.qos = qos
Expand Down Expand Up @@ -551,18 +551,18 @@ function abstractPersistence (opts) {
const client = { id: 'abcde' }
const topic = 'hello'
const subs = [
{ topic: topic, qos: 0 },
{ topic: topic, qos: 1 },
{ topic: topic, qos: 2 },
{ topic: topic, qos: 1 },
{ topic: topic, qos: 0 }
{ topic, qos: 0 },
{ topic, qos: 1 },
{ topic, qos: 2 },
{ topic, qos: 1 },
{ topic, qos: 0 }
]
instance.addSubscriptions(client, subs, function (err, reClient) {
t.equal(reClient, client, 'client must be the same')
t.error(err, 'no error')
instance.subscriptionsByClient(client, function (err, subsForClient, client) {
t.error(err, 'no error')
t.deepEqual(subsForClient, [{ topic: topic, qos: 0 }])
t.deepEqual(subsForClient, [{ topic, qos: 0 }])
instance.subscriptionsByTopic(topic, function (err, subsForTopic) {
t.error(err, 'no error')
t.deepEqual(subsForTopic, [])
Expand Down Expand Up @@ -706,7 +706,7 @@ function abstractPersistence (opts) {
const client = { id: 'abcde' }
const topic = 'hello'
const subs = [{
topic: topic,
topic,
qos: 1
}]

Expand All @@ -731,7 +731,7 @@ function abstractPersistence (opts) {
const client = { id: 'abcde' }
const topic = 'hello'
const subs = [{
topic: topic,
topic,
qos: 0
}]

Expand Down
4 changes: 2 additions & 2 deletions persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ MemoryPersistence.prototype.removeSubscriptions = function (client, subs, cb) {
const qos = stored.get(topic)
if (qos !== undefined) {
if (qos > 0) {
trie.remove(topic, { clientId: client.id, topic: topic })
trie.remove(topic, { clientId: client.id, topic })
}
stored.delete(topic)
}
Expand Down Expand Up @@ -156,7 +156,7 @@ MemoryPersistence.prototype.cleanSubscriptions = function (client, cb) {
for (const topicAndQos of stored) {
if (topicAndQos[1] > 0) {
const topic = topicAndQos[0]
trie.remove(topic, { clientId: client.id, topic: topic })
trie.remove(topic, { clientId: client.id, topic })
}
}

Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const memory = require('./')
const abs = require('./abstract')

abs({
test: test,
test,
persistence: memory
})

0 comments on commit 247bae4

Please sign in to comment.