From bb79b093f1cad5b9ce8ac4442fc27e2499ddaecb Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 7 Jun 2021 15:15:01 +0200 Subject: [PATCH] Updated standard@16 (#114) --- package.json | 2 +- parser.js | 15 +++++++++------ testRandom.js | 6 +++--- writeToStream.js | 7 +++++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 9b3e7d0..93846c4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "devDependencies": { "pre-commit": "^1.2.2", "readable-stream": "^3.6.0", - "standard": "^14.3.4", + "standard": "^16.0.0", "tap-spec": "^5.0.0", "tape": "^5.0.1" }, diff --git a/parser.js b/parser.js index 9af1ec5..f3461f3 100644 --- a/parser.js +++ b/parser.js @@ -666,12 +666,15 @@ class Parser extends EventEmitter { this._pos += bytes } - result = result - ? fullInfoFlag ? { - bytes, - value - } : value - : false + if (result) { + if (fullInfoFlag) { + result = { bytes, value } + } else { + result = value + } + } else { + result = false + } debug('_parseVarByteNum: result: %o', result) return result diff --git a/testRandom.js b/testRandom.js index 9beff90..84195bd 100644 --- a/testRandom.js +++ b/testRandom.js @@ -2,9 +2,9 @@ const mqtt = require('./') const crypto = require('crypto') const max = 1E5 const start = Date.now() / 1000 -var errors = 0 -var packets = 0 -var randomPacket +let errors = 0 +let packets = 0 +let randomPacket const firstBytes = [ 16 * 1, // CONNECT 16 * 2, // CONNACK diff --git a/writeToStream.js b/writeToStream.js index e7b6d18..1892fdb 100644 --- a/writeToStream.js +++ b/writeToStream.js @@ -137,9 +137,12 @@ function connect (packet, stream, opts) { // Connect flags length += 1 + let propertiesData + let willProperties + // Properties if (protocolVersion === 5) { - var propertiesData = getProperties(stream, properties) + propertiesData = getProperties(stream, properties) if (!propertiesData) { return false } length += propertiesData.length } @@ -174,7 +177,7 @@ function connect (packet, stream, opts) { } } // will properties - var willProperties = {} + willProperties = {} if (protocolVersion === 5) { willProperties = getProperties(stream, will.properties) if (!willProperties) { return false }