@iot9x.com/ipc-utils
Version:
九星云、九星小程序、九星配置工具所共用的库方法
22 lines (21 loc) • 829 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Convert = void 0;
class Convert {
/**
* 将Uint8Array数据转换成十六进制字符串
* @param data Uint8Array数据
* @param upperCase 是否大写
* @param separator 十六进制分隔符
* @returns 转换后的十六进制字符串
*/
static uint8ArrayToHexStr(data, options) {
const buf = [];
for (const byte of data) {
const hexLowerCaseStr = byte.toString(16).padStart(2, '0');
buf.push((options === null || options === void 0 ? void 0 : options.upperCase) ? hexLowerCaseStr.toUpperCase() : hexLowerCaseStr);
}
return buf.join((options === null || options === void 0 ? void 0 : options.separator) || '');
}
}
exports.Convert = Convert;