@ginden/blinkstick-v2
Version:
Improved Blickstick API for Node.js
21 lines • 701 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.decimalToHex = decimalToHex;
/**
* Converts decimal number to hex with zero padding
*
* @private
* @method decimalToHex
* @param {Number} d Decimal number to convert
* @param {Number} [padding = 2] How many zeros to use for padding
* @return {String} Decimal number converted to hex string (eg. decimalToHext(5) => '05')
*/
function decimalToHex(d, padding = 2) {
let hex = Number(d).toString(16);
padding = typeof padding === 'undefined' || padding === null ? 2 : padding;
while (hex.length < padding) {
hex = '0' + hex;
}
return hex;
}
//# sourceMappingURL=decimal-to-hex.js.map