soundtouch-api
Version:
SoundTouch API using TypeScript
52 lines • 2.12 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorFromElement = exports.APIErrors = void 0;
var utils_1 = require("./utils");
var APIErrors = /** @class */ (function (_super) {
__extends(APIErrors, _super);
function APIErrors(errors, deviceId) {
var _this = _super.call(this, "Occured on device ".concat(deviceId, ": ").concat(JSON.stringify(errors))) || this;
_this.deviceId = deviceId;
_this.errors = errors;
return _this;
}
APIErrors.fromElement = function (element) {
return new APIErrors((0, utils_1.compactMap)(element.getList('error'), errorFromElement), element.getAttribute('deviceID'));
};
return APIErrors;
}(Error));
exports.APIErrors = APIErrors;
function errorFromElement(element) {
if (!element.hasAttributes(['value', 'name', 'severity'])) {
return undefined;
}
var valueString = element.getAttribute('value');
var name = element.getAttribute('name');
var severity = element.getAttribute('severity');
if (!valueString || !name || !severity) {
return undefined;
}
return {
value: parseInt(valueString) || 0,
name: name,
severity: severity,
message: element.getText()
};
}
exports.errorFromElement = errorFromElement;
//# sourceMappingURL=error.js.map