diff --git a/abstract.js b/abstract.js index 99bb33a..db5406b 100644 --- a/abstract.js +++ b/abstract.js @@ -1,5 +1,5 @@ 'use strict' -var parent = require('aedes-persistence/abstract') +const parent = require('aedes-persistence/abstract') module.exports = parent diff --git a/index.js b/index.js index 0ed8119..0b1f3fb 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +/* eslint-disable no-var */ 'use strict' const QlobberSub = require('qlobber/aedes/qlobber-sub') @@ -36,10 +37,10 @@ function CachedPersistence (opts) { }) this._onMessage = function onSubMessage (packet, cb) { - var decoded = JSON.parse(packet.payload) - var clientId = decoded.clientId + const decoded = JSON.parse(packet.payload) + const clientId = decoded.clientId for (var i = 0; i < decoded.subs.length; i++) { - var sub = decoded.subs[i] + const sub = decoded.subs[i] sub.clientId = clientId if (packet.topic === newSubTopic) { if (sub.qos > 0) { @@ -51,12 +52,12 @@ function CachedPersistence (opts) { that._trie.remove(sub.topic, sub) } } - var action = packet.topic === newSubTopic ? 'sub_' : 'unsub_' + const action = packet.topic === newSubTopic ? 'sub_' : 'unsub_' var key = clientId + '-' + action if (decoded.subs.length > 0) { key = clientId + '-' + action + decoded.subs[0].topic } - var waiting = that._waiting[key] + const waiting = that._waiting[key] that._waiting[key] = undefined if (waiting) { process.nextTick(waiting) @@ -108,8 +109,8 @@ CachedPersistence.prototype._addedSubscriptions = function (client, subs, cb) { } function brokerPublish (subs, cb) { - var encoded = JSON.stringify({ clientId: this.client.id, subs: subs }) - var packet = new Packet({ + const encoded = JSON.stringify({ clientId: this.client.id, subs: subs }) + const packet = new Packet({ topic: this.topic, payload: encoded }) @@ -184,7 +185,7 @@ function outgoingEnqueue (sub, cb) { CachedPersistence.prototype.createRetainedStreamCombi = function (patterns) { const that = this - var streams = patterns.map(function (p) { + const streams = patterns.map(function (p) { return that.createRetainedStream(p) }) return MultiStream.obj(streams) diff --git a/package.json b/package.json index 5f3dc67..244198c 100644 --- a/package.json +++ b/package.json @@ -55,19 +55,19 @@ "concat-stream": "^2.0.0", "faucet": "0.0.1", "license-checker": "^25.0.1", - "mqemitter": "^4.2.0", - "nyc": "^15.0.1", + "mqemitter": "^4.4.0", + "nyc": "^15.1.0", "pump": "^3.0.0", - "release-it": "^14.0.3", + "release-it": "^14.2.2", "snazzy": "^9.0.0", - "standard": "^15.0.0", + "standard": "^16.0.3", "tape": "^4.13.2", - "through2": "^4.0.1" + "through2": "^4.0.2" }, "dependencies": { - "aedes-persistence": "^8.1.1", - "fastparallel": "^2.3.0", - "multistream": "^4.0.0", - "qlobber": "^5.0.0" + "aedes-persistence": "^8.1.2", + "fastparallel": "^2.4.0", + "multistream": "^4.0.1", + "qlobber": "^5.0.3" } } diff --git a/test.js b/test.js index 30b5992..af230c1 100644 --- a/test.js +++ b/test.js @@ -1,10 +1,10 @@ 'use strict' -var test = require('tape').test -var CachedPersistence = require('./') -var util = require('util') -var Memory = require('aedes-persistence') -var abs = require('./abstract') +const test = require('tape').test +const CachedPersistence = require('./') +const util = require('util') +const Memory = require('aedes-persistence') +const abs = require('./abstract') function MyPersistence () { if (!(this instanceof MyPersistence)) { @@ -36,7 +36,7 @@ util.inherits(MyPersistence, CachedPersistence) }) MyPersistence.prototype.addSubscriptions = function (client, subs, cb) { - var stored = this._subscriptions.get(client.id) + let stored = this._subscriptions.get(client.id) if (!stored) { stored = new Map() @@ -44,7 +44,7 @@ MyPersistence.prototype.addSubscriptions = function (client, subs, cb) { this._clientsCount++ } - var subsObjs = subs.map(function mapSub (sub) { + const subsObjs = subs.map(function mapSub (sub) { stored.set(sub.topic, sub.qos) return { clientId: client.id, @@ -57,13 +57,13 @@ MyPersistence.prototype.addSubscriptions = function (client, subs, cb) { } MyPersistence.prototype.removeSubscriptions = function (client, subs, cb) { - var stored = this._subscriptions.get(client.id) - var removed = [] + const stored = this._subscriptions.get(client.id) + const removed = [] if (stored) { - for (var i = 0; i < subs.length; i += 1) { - var topic = subs[i] - var qos = stored.get(topic) + for (let i = 0; i < subs.length; i += 1) { + const topic = subs[i] + const qos = stored.get(topic) if (qos !== undefined) { if (qos > 0) { removed.push({