everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
16 lines (15 loc) • 537 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toBase = void 0;
/**
* Converts a number to a string in the given base.
* For example, toBase(255, 16) returns 'FF'.
* @author @dailker
* @param {number} n - The number to convert.
* @param {number} base - The base to convert to (e.g., 2, 8, 10, 16).
* @returns {string} The string representation of the number in the given base.
*/
function toBase(n, base) {
return n.toString(base).toUpperCase();
}
exports.toBase = toBase;