UNPKG

homebridge-hatch-baby-rest-volume

Version:
18 lines (17 loc) 611 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatRestCommand = void 0; function zeroPaddedHex(value) { let hex = value.toString(16); while (hex.length < 2) { hex = '0' + hex; } return hex.toUpperCase(); } function formatRestCommand(command, value) { if (typeof value === 'number') { return Buffer.from(`${command}${zeroPaddedHex(value)}`); } return Buffer.from(`${command}${zeroPaddedHex(value.r)}${zeroPaddedHex(value.g)}${zeroPaddedHex(value.b)}${zeroPaddedHex(value.a)}`); } exports.formatRestCommand = formatRestCommand;