Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqtt

Package Overview
Dependencies
Maintainers
7
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqtt - npm Package Compare versions

Comparing version 5.3.6 to 5.4.0

build/lib/timers.d.ts

9

build/lib/client.js

@@ -41,2 +41,3 @@ "use strict";

const PingTimer_1 = __importDefault(require("./PingTimer"));
const is_browser_1 = __importStar(require("./is-browser"));
const setImmediate = globalThis.setImmediate ||

@@ -77,2 +78,9 @@ ((...args) => {

this.noop = this._noop.bind(this);
this.log('MqttClient :: version:', process.env.npm_package_version);
if (is_browser_1.isWebWorker) {
this.log('MqttClient :: environment', 'webworker');
}
else {
this.log('MqttClient :: environment', is_browser_1.default ? 'browser' : 'node');
}
this.log('MqttClient :: options.protocol', options.protocol);

@@ -1036,2 +1044,3 @@ this.log('MqttClient :: options.protocolVersion', options.protocolVersion);

else {
this.emit('error', new Error('Keepalive timeout'));
this.log('_checkPing :: calling _cleanUp with force true');

@@ -1038,0 +1047,0 @@ this._cleanUp(true);

2

build/lib/PingTimer.d.ts

@@ -5,4 +5,2 @@ export default class PingTimer {

private checkPing;
private _setTimeout;
private _clearTimeout;
constructor(keepalive: number, checkPing: () => void);

@@ -9,0 +7,0 @@ clear(): void;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const worker_timers_1 = require("worker-timers");
const is_browser_1 = __importStar(require("./is-browser"));
const timers_1 = __importDefault(require("./timers"));
class PingTimer {
constructor(keepalive, checkPing) {
this._setTimeout = is_browser_1.default && !is_browser_1.isWebWorker
? worker_timers_1.setTimeout
: (func, time) => setTimeout(func, time);
this._clearTimeout = is_browser_1.default && !is_browser_1.isWebWorker ? worker_timers_1.clearTimeout : (timer) => clearTimeout(timer);
this.keepalive = keepalive * 1000;

@@ -40,3 +15,3 @@ this.checkPing = checkPing;

if (this.timer) {
this._clearTimeout(this.timer);
timers_1.default.clear(this.timer);
this.timer = null;

@@ -47,3 +22,3 @@ }

this.clear();
this.timer = this._setTimeout(() => {
this.timer = timers_1.default.set(() => {
this.checkPing();

@@ -50,0 +25,0 @@ if (this.timer) {

@@ -6,6 +6,7 @@ import MqttClient from './lib/client';

import connect, { connectAsync } from './lib/connect';
import PingTimer from './lib/PingTimer';
export declare const Client: typeof MqttClient;
export { connect, connectAsync, MqttClient, Store, DefaultMessageIdProvider, UniqueMessageIdProvider, IStore, };
export { connect, connectAsync, MqttClient, Store, DefaultMessageIdProvider, UniqueMessageIdProvider, IStore, PingTimer, };
export * from './lib/client';
export * from './lib/shared';
export { ReasonCodes } from './lib/handlers/ack';

@@ -32,3 +32,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ReasonCodes = exports.UniqueMessageIdProvider = exports.DefaultMessageIdProvider = exports.Store = exports.MqttClient = exports.connectAsync = exports.connect = exports.Client = void 0;
exports.ReasonCodes = exports.PingTimer = exports.UniqueMessageIdProvider = exports.DefaultMessageIdProvider = exports.Store = exports.MqttClient = exports.connectAsync = exports.connect = exports.Client = void 0;
const client_1 = __importDefault(require("./lib/client"));

@@ -45,2 +45,4 @@ exports.MqttClient = client_1.default;

Object.defineProperty(exports, "connectAsync", { enumerable: true, get: function () { return connect_1.connectAsync; } });
const PingTimer_1 = __importDefault(require("./lib/PingTimer"));
exports.PingTimer = PingTimer_1.default;
exports.Client = client_1.default;

@@ -47,0 +49,0 @@ __exportStar(require("./lib/client"), exports);

{
"name": "mqtt",
"description": "A library for the MQTT protocol",
"version": "5.3.6",
"version": "5.4.0",
"contributors": [

@@ -42,3 +42,3 @@ "Adam Rudd <adamvrr@gmail.com>",

"import": "./dist/mqtt.esm.js",
"default": "./dist/index.js"
"default": "./dist/mqtt.min.js"
},

@@ -127,3 +127,3 @@ "default": "./build/index.js"

"split2": "^4.2.0",
"worker-timers": "^7.0.78",
"worker-timers": "^7.1.4",
"ws": "^8.14.2"

@@ -130,0 +130,0 @@ },

@@ -137,3 +137,3 @@ # ![mqtt.js](https://raw.githubusercontent.com/mqttjs/MQTT.js/137ee0e3940c1f01049a30248c70f24dc6e6f829/MQTT.js.png)

const mqtt = require("mqtt") // require mqtt
const client = mqtt.connect("test.mosquitto.org") // create a client
const client = mqtt.connect("mqtt://test.mosquitto.org") // create a client
```

@@ -140,0 +140,0 @@

@@ -41,2 +41,3 @@ /**

import PingTimer from './PingTimer'
import isBrowser, { isWebWorker } from './is-browser'

@@ -492,2 +493,13 @@ const setImmediate =

this.log('MqttClient :: version:', process.env.npm_package_version)
if (isWebWorker) {
this.log('MqttClient :: environment', 'webworker')
} else {
this.log(
'MqttClient :: environment',
isBrowser ? 'browser' : 'node',
)
}
this.log('MqttClient :: options.protocol', options.protocol)

@@ -2105,2 +2117,3 @@ this.log(

// do a forced cleanup since socket will be in bad shape
this.emit('error', new Error('Keepalive timeout'))
this.log('_checkPing :: calling _cleanUp with force true')

@@ -2107,0 +2120,0 @@ this._cleanUp(true)

@@ -1,3 +0,2 @@

import { clearTimeout as clearT, setTimeout as setT } from 'worker-timers'
import isBrowser, { isWebWorker } from './is-browser'
import timers from './timers'

@@ -11,12 +10,2 @@ export default class PingTimer {

// dont directly assign globals to class props otherwise this throws in web workers: Uncaught TypeError: Illegal invocation
// See: https://stackoverflow.com/questions/9677985/uncaught-typeerror-illegal-invocation-in-chrome
private _setTimeout: typeof setT =
isBrowser && !isWebWorker
? setT
: (func, time) => setTimeout(func, time)
private _clearTimeout: typeof clearT =
isBrowser && !isWebWorker ? clearT : (timer) => clearTimeout(timer)
constructor(keepalive: number, checkPing: () => void) {

@@ -30,3 +19,3 @@ this.keepalive = keepalive * 1000

if (this.timer) {
this._clearTimeout(this.timer)
timers.clear(this.timer)
this.timer = null

@@ -38,3 +27,3 @@ }

this.clear()
this.timer = this._setTimeout(() => {
this.timer = timers.set(() => {
this.checkPing()

@@ -41,0 +30,0 @@ // prevent possible race condition where the timer is destroyed on _cleauUp

@@ -12,2 +12,3 @@ /*

import connect, { connectAsync } from './lib/connect'
import PingTimer from './lib/PingTimer'

@@ -23,2 +24,3 @@ export const Client = MqttClient

IStore,
PingTimer,
}

@@ -25,0 +27,0 @@ export * from './lib/client'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc