Source

number/formatLargeNumber.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var shortenNumberWithUnit_1 = __importDefault(require("./shortenNumberWithUnit"));
var UNIT_INTERVAL = 1000;
var NUMBER_SHORT_UNIT_MAP = [
    // No unit
    '',
    // Kilo
    'K',
    // Million
    'M',
    // Billion
    'B',
    // Trillion
    'T',
];
/**
 * Shorten normal number in appropriate format (e.g. 1K, 10M)
 *
 * @param size The size in bytes
 * @returns A tuple type of [<Displayed number>, <Displayed units>] format. E.g. [1, 'K']
 * @category number
 * @module formatLargeNumber
 */
function formatLargeNumber(num) {
    return (0, shortenNumberWithUnit_1.default)(num, UNIT_INTERVAL, NUMBER_SHORT_UNIT_MAP);
}
exports.default = formatLargeNumber;