chenyc
2025-12-09 65e034683b28d799e73c7d7e5e4769fab5b9bc9c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MQTTJS_VERSION = exports.nextTick = exports.ErrorWithSubackPacket = exports.ErrorWithReasonCode = void 0;
exports.applyMixin = applyMixin;
class ErrorWithReasonCode extends Error {
    code;
    constructor(message, code) {
        super(message);
        this.code = code;
        Object.setPrototypeOf(this, ErrorWithReasonCode.prototype);
        Object.getPrototypeOf(this).name = 'ErrorWithReasonCode';
    }
}
exports.ErrorWithReasonCode = ErrorWithReasonCode;
class ErrorWithSubackPacket extends Error {
    packet;
    constructor(message, packet) {
        super(message);
        this.packet = packet;
        Object.setPrototypeOf(this, ErrorWithSubackPacket.prototype);
        Object.getPrototypeOf(this).name = 'ErrorWithSubackPacket';
    }
}
exports.ErrorWithSubackPacket = ErrorWithSubackPacket;
function applyMixin(target, mixin, includeConstructor = false) {
    const inheritanceChain = [mixin];
    while (true) {
        const current = inheritanceChain[0];
        const base = Object.getPrototypeOf(current);
        if (base?.prototype) {
            inheritanceChain.unshift(base);
        }
        else {
            break;
        }
    }
    for (const ctor of inheritanceChain) {
        for (const prop of Object.getOwnPropertyNames(ctor.prototype)) {
            if (includeConstructor || prop !== 'constructor') {
                Object.defineProperty(target.prototype, prop, Object.getOwnPropertyDescriptor(ctor.prototype, prop) ??
                    Object.create(null));
            }
        }
    }
}
exports.nextTick = typeof process?.nextTick === 'function'
    ? process.nextTick
    : (callback) => {
        setTimeout(callback, 0);
    };
exports.MQTTJS_VERSION = require('../../package.json').version;
//# sourceMappingURL=shared.js.map