Function truncateNumber

  • Truncates a number such that is will at a max have 6 (customizable) characters including suffix, decimal point, or comma.

    Default suffixes are in defaultTruncationSuffixes:

    'k', // thousand
    'M', // million
    'B', // billion
    'T', // trillion
    'P', // peta-, quadrillion
    'E', // exa- quintillion
    'Z', // zetta- sextillion
    'Y', // yotta- septillion
    

    Parameters

    • originalValue: Readonly<unknown>
    • __namedParameters: Partial<{
          customSuffixes: undefined | readonly string[];
          maxLength: undefined | number;
      }> = {}

    Returns string

    import {truncateNumber} from '@augment-vir/common';

    // `result` will be `'1M'`
    const result = truncateNumber(1_000_000);

    @augment-vir/common