UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

25 lines (21 loc) 510 B
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ "use strict"; (() => { // 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"); } })();