heos-api
Version:
🎵 A zero-dependency low level api-wrapper for communicating with HEOS devices 🎵
26 lines • 935 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var prefix = 'heos://';
var postfix = '\r\n';
function attributeString(attributes) {
if (!attributes || Object.entries(attributes).length < 1) {
return '';
}
else {
return ('?' +
Object.entries(attributes)
.map(function (_a) {
var key = _a[0], value = _a[1];
return key + "=" + value;
})
.reduce(function (previous, current) { return previous + "&" + current; }));
}
}
function generateHeosCommand(commandGroup, command, attributes) {
if (!commandGroup || !command) {
throw new Error('Missing arguments when creating HeosCommand');
}
return [prefix, commandGroup, '/', command, attributeString(attributes), postfix].join('');
}
exports.generateHeosCommand = generateHeosCommand;
//# sourceMappingURL=heosCommand.js.map