osrs-number-formatter
Version:
Formats numbers into a style similar to OSRS
18 lines (17 loc) • 452 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = void 0;
const format = (num) => {
const decimal = num.toString().length;
if (decimal < 6) {
return num + "";
}
if (decimal < 8) {
return Math.round(num / 1000) + "K";
}
if (decimal < 11) {
return Math.round(num / 1000000) + "M";
}
return Math.round(num / 1000000000) + "B";
};
exports.format = format;