import { assert } from "../assert.js";

/**
 * Uint8 to hex (2 characters)
 *
 * @example uint82hex(10) => "0A"
 * @param {number} x
 * @return {string}
 */
export function uint82hex(x) {
    assert.isNonNegativeInteger(x, 'x');

    const hex = x.toString(16);
    return (hex.length === 1) ? "0" + hex : hex;
}