Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mqttjs/MQTT.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.3.3
Choose a base ref
...
head repository: mqttjs/MQTT.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.3.4
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 6, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5c67037 View commit details
  2. release(1.6.2022): 4.3.4 (#1397)

    Yoseph Maguire authored Jan 6, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0a8e3b2 View commit details
Showing with 13 additions and 11 deletions.
  1. +4 −0 CHANGELOG.md
  2. +7 −9 lib/topic-alias-send.js
  3. +2 −2 package.json
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 4.3.4

fix(dependency): migrate LruMap from collections to lru-cache (#1396)

## 4.3.3

fix(publish): call callback when messageId available (#1393)
16 changes: 7 additions & 9 deletions lib/topic-alias-send.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
/**
* Module dependencies
*/
const LruMap = require('collections/lru-map')
const LruMap = require('lru-cache')
const NumberAllocator = require('number-allocator').NumberAllocator

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

if (max > 0) {
this.aliasToTopic = new LruMap()
this.aliasToTopic = new LruMap({ max: max })
this.topicToAlias = {}
this.numberAllocator = new NumberAllocator(1, max)
this.max = max
@@ -37,9 +37,9 @@ TopicAliasSend.prototype.put = function (topic, alias) {
}
const entry = this.aliasToTopic.get(alias)
if (entry) {
delete this.topicToAlias[entry.topic]
delete this.topicToAlias[entry]
}
this.aliasToTopic.set(alias, { topic: topic, alias: alias })
this.aliasToTopic.set(alias, topic)
this.topicToAlias[topic] = alias
this.numberAllocator.use(alias)
this.length = this.aliasToTopic.length
@@ -52,9 +52,7 @@ TopicAliasSend.prototype.put = function (topic, alias) {
* @returns {String} - if mapped topic exists return topic, otherwise return undefined
*/
TopicAliasSend.prototype.getTopicByAlias = function (alias) {
const entry = this.aliasToTopic.get(alias)
if (typeof entry === 'undefined') return entry
return entry.topic
return this.aliasToTopic.get(alias)
}

/**
@@ -74,7 +72,7 @@ TopicAliasSend.prototype.getAliasByTopic = function (topic) {
* Clear all entries
*/
TopicAliasSend.prototype.clear = function () {
this.aliasToTopic.clear()
this.aliasToTopic.reset()
this.topicToAlias = {}
this.numberAllocator.clear()
this.length = 0
@@ -87,7 +85,7 @@ TopicAliasSend.prototype.clear = function () {
TopicAliasSend.prototype.getLruAlias = function () {
const alias = this.numberAllocator.firstVacant()
if (alias) return alias
return this.aliasToTopic.min().alias
return this.aliasToTopic.keys()[this.aliasToTopic.length - 1]
}

module.exports = TopicAliasSend
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mqtt",
"description": "A library for the MQTT protocol",
"version": "4.3.3",
"version": "4.3.4",
"contributors": [
"Adam Rudd <adamvrr@gmail.com>",
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
@@ -62,13 +62,13 @@
"net": false
},
"dependencies": {
"collections": "^5.1.13",
"commist": "^1.0.0",
"concat-stream": "^2.0.0",
"debug": "^4.1.1",
"duplexify": "^4.1.1",
"help-me": "^3.0.0",
"inherits": "^2.0.3",
"lru-cache": "^6.0.0",
"minimist": "^1.2.5",
"mqtt-packet": "^6.8.0",
"number-allocator": "^1.0.9",