Skip to content

Commit 31dd357

Browse files
authored
chore(deps): bump all deps and fix breaking changes (#1631)
1 parent ae4c11e commit 31dd357

17 files changed

+3397
-3362
lines changed

examples/ws/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const host = 'ws://localhost:8080'
1515

1616
const options = {
1717
keepalive: 30,
18-
clientId: clientId,
18+
clientId,
1919
protocolId: 'MQTT',
2020
protocolVersion: 4,
2121
clean: true,

examples/wss/client_with_proxy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const proxyOpts = url.parse(proxy)
2121
proxyOpts.secureEndpoint = parsed.protocol ? parsed.protocol === 'wss:' : true
2222
const agent = new HttpsProxyAgent(proxyOpts)
2323
const wsOptions = {
24-
agent: agent
24+
agent
2525
// other wsOptions
2626
// foo:'bar'
2727
}
@@ -34,7 +34,7 @@ const mqttOptions = {
3434
connectTimeout: 30 * 1000,
3535
clean: true,
3636
clientId: 'testClient',
37-
wsOptions: wsOptions
37+
wsOptions
3838
}
3939

4040
const client = mqtt.connect(parsed, mqttOptions)

lib/client.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,11 @@ MqttClient.prototype.publish = function (topic, message, opts, callback) {
638638
}
639639
const packet = {
640640
cmd: 'publish',
641-
topic: topic,
641+
topic,
642642
payload: message,
643643
qos: opts.qos,
644644
retain: opts.retain,
645-
messageId: messageId,
645+
messageId,
646646
dup: opts.dup
647647
}
648648

@@ -675,7 +675,7 @@ MqttClient.prototype.publish = function (topic, message, opts, callback) {
675675
{
676676
invoke: publishProc,
677677
cbStorePut: opts.cbStorePut,
678-
callback: callback
678+
callback
679679
}
680680
)
681681
}
@@ -750,7 +750,7 @@ MqttClient.prototype.subscribe = function () {
750750
that._resubscribeTopics[topic].qos < opts.qos ||
751751
resubscribe) {
752752
const currentOpts = {
753-
topic: topic,
753+
topic,
754754
qos: opts.qos
755755
}
756756
if (version === 5) {
@@ -805,7 +805,7 @@ MqttClient.prototype.subscribe = function () {
805805
qos: 1,
806806
retain: false,
807807
dup: false,
808-
messageId: messageId
808+
messageId
809809
}
810810

811811
if (opts.properties) {
@@ -854,7 +854,7 @@ MqttClient.prototype.subscribe = function () {
854854
this._storeProcessingQueue.push(
855855
{
856856
invoke: subscribeProc,
857-
callback: callback
857+
callback
858858
}
859859
)
860860
}
@@ -911,7 +911,7 @@ MqttClient.prototype.unsubscribe = function () {
911911
const packet = {
912912
cmd: 'unsubscribe',
913913
qos: 1,
914-
messageId: messageId
914+
messageId
915915
}
916916

917917
if (typeof topic === 'string') {
@@ -945,7 +945,7 @@ MqttClient.prototype.unsubscribe = function () {
945945
this._storeProcessingQueue.push(
946946
{
947947
invoke: unsubscribeProc,
948-
callback: callback
948+
callback
949949
}
950950
)
951951
}
@@ -1054,7 +1054,7 @@ MqttClient.prototype.end = function (force, opts, cb) {
10541054
MqttClient.prototype.removeOutgoingMessage = function (messageId) {
10551055
const cb = this.outgoing[messageId] ? this.outgoing[messageId].cb : null
10561056
delete this.outgoing[messageId]
1057-
this.outgoingStore.del({ messageId: messageId }, function () {
1057+
this.outgoingStore.del({ messageId }, function () {
10581058
cb(new Error('Message removed'))
10591059
})
10601060
return this
@@ -1297,7 +1297,7 @@ MqttClient.prototype._storePacket = function (packet, cb, cbStorePut) {
12971297
}
12981298
// check that the packet is not a qos of 0, or that the command is not a publish
12991299
if (((storePacket.qos || 0) === 0 && this.queueQoSZero) || storePacket.cmd !== 'publish') {
1300-
this.queue.push({ packet: storePacket, cb: cb })
1300+
this.queue.push({ packet: storePacket, cb })
13011301
} else if (storePacket.qos > 0) {
13021302
cb = this.outgoing[storePacket.messageId] ? this.outgoing[storePacket.messageId].cb : null
13031303
this.outgoingStore.put(storePacket, function (err) {
@@ -1533,10 +1533,10 @@ MqttClient.prototype._handlePublish = function (packet, done) {
15331533
if (error) { return that.emit('error', error) }
15341534
if (validReasonCodes.indexOf(code) === -1) { return that.emit('error', new Error('Wrong reason code for pubrec')) }
15351535
if (code) {
1536-
that._sendPacket({ cmd: 'pubrec', messageId: messageId, reasonCode: code }, done)
1536+
that._sendPacket({ cmd: 'pubrec', messageId, reasonCode: code }, done)
15371537
} else {
15381538
that.incomingStore.put(packet, function () {
1539-
that._sendPacket({ cmd: 'pubrec', messageId: messageId }, done)
1539+
that._sendPacket({ cmd: 'pubrec', messageId }, done)
15401540
})
15411541
}
15421542
})
@@ -1556,7 +1556,7 @@ MqttClient.prototype._handlePublish = function (packet, done) {
15561556
if (err) {
15571557
return done && done(err)
15581558
}
1559-
that._sendPacket({ cmd: 'puback', messageId: messageId, reasonCode: code }, done)
1559+
that._sendPacket({ cmd: 'puback', messageId, reasonCode: code }, done)
15601560
})
15611561
})
15621562
break
@@ -1642,7 +1642,7 @@ MqttClient.prototype._handleAck = function (packet) {
16421642
response = {
16431643
cmd: 'pubrel',
16441644
qos: 2,
1645-
messageId: messageId
1645+
messageId
16461646
}
16471647
const pubrecRC = packet.reasonCode
16481648

@@ -1703,7 +1703,7 @@ MqttClient.prototype._handlePubrel = function (packet, callback) {
17031703
const messageId = packet.messageId
17041704
const that = this
17051705

1706-
const comp = { cmd: 'pubcomp', messageId: messageId }
1706+
const comp = { cmd: 'pubcomp', messageId }
17071707

17081708
that.incomingStore.get(packet, function (err, pub) {
17091709
if (!err) {

lib/connect/ali.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function buildStream (client, opts) {
114114
const url = buildUrl(opts, client)
115115
my = opts.my
116116
my.connectSocket({
117-
url: url,
117+
url,
118118
protocols: websocketSubProtocol
119119
})
120120

lib/connect/wx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function buildStream (client, opts) {
9797

9898
const url = buildUrl(opts, client)
9999
socketTask = wx.connectSocket({
100-
url: url,
100+
url,
101101
protocols: [websocketSubProtocol]
102102
})
103103

lib/topic-alias-send.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Module dependencies
55
*/
6-
const LruMap = require('lru-cache')
6+
const LRUCache = require('lru-cache')
77
const NumberAllocator = require('number-allocator').NumberAllocator
88

99
/**
@@ -17,7 +17,7 @@ function TopicAliasSend (max) {
1717
}
1818

1919
if (max > 0) {
20-
this.aliasToTopic = new LruMap({ max: max })
20+
this.aliasToTopic = new LRUCache({ max })
2121
this.topicToAlias = {}
2222
this.numberAllocator = new NumberAllocator(1, max)
2323
this.max = max
@@ -42,7 +42,7 @@ TopicAliasSend.prototype.put = function (topic, alias) {
4242
this.aliasToTopic.set(alias, topic)
4343
this.topicToAlias[topic] = alias
4444
this.numberAllocator.use(alias)
45-
this.length = this.aliasToTopic.length
45+
this.length = this.aliasToTopic.size
4646
return true
4747
}
4848

@@ -72,7 +72,7 @@ TopicAliasSend.prototype.getAliasByTopic = function (topic) {
7272
* Clear all entries
7373
*/
7474
TopicAliasSend.prototype.clear = function () {
75-
this.aliasToTopic.reset()
75+
this.aliasToTopic.clear()
7676
this.topicToAlias = {}
7777
this.numberAllocator.clear()
7878
this.length = 0
@@ -85,7 +85,8 @@ TopicAliasSend.prototype.clear = function () {
8585
TopicAliasSend.prototype.getLruAlias = function () {
8686
const alias = this.numberAllocator.firstVacant()
8787
if (alias) return alias
88-
return this.aliasToTopic.keys()[this.aliasToTopic.length - 1]
88+
// get last alias (key) from LRU cache
89+
return [...this.aliasToTopic.keys()][this.aliasToTopic.size - 1]
8990
}
9091

9192
module.exports = TopicAliasSend

lib/validations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ function validateTopics (topics) {
4848
}
4949

5050
module.exports = {
51-
validateTopics: validateTopics
51+
validateTopics
5252
}

0 commit comments

Comments
 (0)