matterbridge-zigbee2mqtt 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +10 -2
- package/dist/entity.js +1 -1
- package/dist/entity.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +21 -6
- package/dist/platform.js.map +1 -1
- package/dist/zigbee2mqtt.d.ts +2 -1
- package/dist/zigbee2mqtt.d.ts.map +1 -1
- package/dist/zigbee2mqtt.js +27 -12
- package/dist/zigbee2mqtt.js.map +1 -1
- package/dist/zigbee2mqttTypes.d.ts +7 -3
- package/dist/zigbee2mqttTypes.d.ts.map +1 -1
- package/dist/zigbee2mqttTypes.js +1 -1
- package/package.json +13 -8
- package/dist/utils.d.ts +0 -61
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -174
- package/dist/utils.js.map +0 -1
package/dist/utils.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the deepEqual function.
|
|
3
|
-
*
|
|
4
|
-
* @file utils.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2024-02-17
|
|
7
|
-
* @version 1.1.1
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2024 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
25
|
-
* This comparison includes primitive types, arrays, and objects, allowing for optional
|
|
26
|
-
* exclusion of specific properties from the comparison in objects.
|
|
27
|
-
*
|
|
28
|
-
* @param {any} a The first value to compare.
|
|
29
|
-
* @param {any} b The second value to compare.
|
|
30
|
-
* @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
|
|
31
|
-
* @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
|
|
32
|
-
*
|
|
33
|
-
* Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
|
|
34
|
-
* mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
|
|
35
|
-
* objects do not contain circular references when enabling debug logging to avoid infinite loops.
|
|
36
|
-
*
|
|
37
|
-
* Example usage:
|
|
38
|
-
* ```
|
|
39
|
-
* const obj1 = { a: 1, b: { c: 2 } };
|
|
40
|
-
* const obj2 = { a: 1, b: { c: 2 } };
|
|
41
|
-
* console.log(deepEqual(obj1, obj2)); // true
|
|
42
|
-
*
|
|
43
|
-
* const arr1 = [1, 2, [3, 4]];
|
|
44
|
-
* const arr2 = [1, 2, [3, 4]];
|
|
45
|
-
* console.log(deepEqual(arr1, arr2)); // true
|
|
46
|
-
*
|
|
47
|
-
* const obj3 = { a: 1, b: { c: 2, d: 3 } };
|
|
48
|
-
* const obj4 = { a: 1, b: { c: 2 } };
|
|
49
|
-
* console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
export function deepEqual(a, b, excludeProperties = []) {
|
|
54
|
-
// Toggle debugging on or off easily
|
|
55
|
-
const debug = false;
|
|
56
|
-
// Helper function for conditional logging
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
const debugLog = (...messages) => {
|
|
59
|
-
if (debug) {
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
|
-
console.log(...messages);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
// If both are the same instance, return true (handles primitives and same object references)
|
|
65
|
-
if (a === b) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
// If types are different, return false
|
|
69
|
-
if (typeof a !== typeof b) {
|
|
70
|
-
debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
// If one of them is null (and we know they are not equal from the first check), return false
|
|
74
|
-
// eslint-disable-next-line eqeqeq
|
|
75
|
-
if (a == null || b == null) {
|
|
76
|
-
debugLog('deepEqual false for ==null');
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
// Handle Arrays
|
|
80
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
81
|
-
if (a.length !== b.length) {
|
|
82
|
-
debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
for (let i = 0; i < a.length; i++) {
|
|
86
|
-
if (!deepEqual(a[i], b[i], excludeProperties)) {
|
|
87
|
-
debugLog('deepEqual false for array !deepEqual(a[i], b[i])');
|
|
88
|
-
debugLog(`- aProps.length(${a[i]}):`, a[i]);
|
|
89
|
-
debugLog(`- bProps.length(${b[i]}):`, b[i]);
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
// Handle Objects (and exclude null, functions, and arrays)
|
|
96
|
-
if (typeof a === 'object' && typeof b === 'object') {
|
|
97
|
-
const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
|
|
98
|
-
const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
|
|
99
|
-
// If their property lengths are different, they're different objects
|
|
100
|
-
if (aProps.length !== bProps.length) {
|
|
101
|
-
debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
|
|
102
|
-
debugLog(`- aProps.length(${aProps.length}):`, aProps);
|
|
103
|
-
debugLog(`- bProps.length(${bProps.length}):`, bProps);
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
// Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
|
|
107
|
-
for (const prop of aProps) {
|
|
108
|
-
if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
|
109
|
-
debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
if (!deepEqual(a[prop], b[prop], excludeProperties)) {
|
|
113
|
-
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /*, a[prop], b[prop]*/);
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
// If none of the above, the objects are not equal
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Creates a deep copy of the given value.
|
|
124
|
-
*
|
|
125
|
-
* @template T - The type of the value being copied.
|
|
126
|
-
* @param {T} value - The value to be copied.
|
|
127
|
-
* @returns {T} - The deep copy of the value.
|
|
128
|
-
*/
|
|
129
|
-
export function deepCopy(value) {
|
|
130
|
-
if (typeof value !== 'object' || value === null) {
|
|
131
|
-
// Primitive value (string, number, boolean, bigint, undefined, symbol) or null
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
else if (Array.isArray(value)) {
|
|
135
|
-
// Array: Recursively copy each element
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
-
return value.map((item) => deepCopy(item));
|
|
138
|
-
}
|
|
139
|
-
else if (value instanceof Date) {
|
|
140
|
-
// Date objects
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
return new Date(value.getTime());
|
|
143
|
-
}
|
|
144
|
-
else if (value instanceof Map) {
|
|
145
|
-
// Maps
|
|
146
|
-
const mapCopy = new Map();
|
|
147
|
-
value.forEach((val, key) => {
|
|
148
|
-
mapCopy.set(key, deepCopy(val));
|
|
149
|
-
});
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
-
return mapCopy;
|
|
152
|
-
}
|
|
153
|
-
else if (value instanceof Set) {
|
|
154
|
-
// Sets
|
|
155
|
-
const setCopy = new Set();
|
|
156
|
-
value.forEach((item) => {
|
|
157
|
-
setCopy.add(deepCopy(item));
|
|
158
|
-
});
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
-
return setCopy;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// Objects: Create a copy with the same prototype as the original
|
|
164
|
-
const proto = Object.getPrototypeOf(value);
|
|
165
|
-
const copy = Object.create(proto);
|
|
166
|
-
for (const key in value) {
|
|
167
|
-
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
168
|
-
copy[key] = deepCopy(value[key]);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return copy;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM,EAAE,oBAA8B,EAAE;IACxE,oCAAoC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC;IAEpB,0CAA0C;IAC1C,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAe,EAAE,EAAE;QACt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