homebridge-apc-ups-alert
Version:
Provide information (and alerts) for apcupsd connected Uninterruptible Power Supplies
38 lines • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.objectsEqual = exports.getOrAddCharacteristic = exports.errorToString = void 0;
function errorToString(e) {
if (typeof e === 'string') {
return e;
}
if (e instanceof Error) {
e.message; // works, `e` narrowed to Error
}
return JSON.stringify(e);
}
exports.errorToString = errorToString;
function getOrAddCharacteristic(service, characteristic) {
return service.getCharacteristic(characteristic) || service.addCharacteristic(characteristic);
}
exports.getOrAddCharacteristic = getOrAddCharacteristic;
function objectsEqual(a, b) {
if (a === b) {
return true;
}
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
for (const i in a) {
if (i in b) {
if (a[i] !== b[i]) {
return false;
}
}
else {
return false;
}
}
return false;
}
exports.objectsEqual = objectsEqual;
//# sourceMappingURL=helpers.js.map