UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

41 lines (40 loc) 1.29 kB
/** * The default truncation prefixes for {@link truncateNumber}. * * @category Number * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare const defaultTruncationSuffixes: readonly ["k", "M", "B", "T", "P", "E", "Z", "Y"]; /** * Truncates a number such that is will at a max have 6 (customizable) characters including suffix, * decimal point, or comma. * * Default suffixes are in {@link defaultTruncationSuffixes}: * * 'k', // thousand * 'M', // million * 'B', // billion * 'T', // trillion * 'P', // peta-, quadrillion * 'E', // exa- quintillion * 'Z', // zetta- sextillion * 'Y', // yotta- septillion * * @category Number * @category Package : @augment-vir/common * @example * * ```ts * import {truncateNumber} from '@augment-vir/common'; * * // `result` will be `'1M'` * const result = truncateNumber(1_000_000); * ``` * * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export declare function truncateNumber(originalValue: Readonly<unknown>, { customSuffixes, maxLength, }?: Partial<{ customSuffixes: ReadonlyArray<string> | undefined; maxLength: number | undefined; }>): string;