@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
26 lines (20 loc) • 506 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/intHex.ts
function intToHex(integer) {
if (integer < 0) {
throw new Error("Invalid integer as argument, must be unsigned!");
}
const hex = integer.toString(16);
return hex.length % 2 ? `0${hex}` : hex;
}
// src/intBuffer.ts
function intToBuffer(integer) {
const hex = intToHex(integer);
return Buffer.from(hex, "hex");
}
exports.intToBuffer = intToBuffer;
;