function compact(value: NumberType, options: RoundingConfigType = {}): string

Formats a number into a short, human-readable string with a suffix (e.g., K, M, B).

Params

  • value (NumberType): The value to be compacted. Can be a number, string, or bigint.
  • options (RoundingConfigType): Configuration for rounding the compacted value.

Returns

(string): The compacted number with a suffix as a string.

Example

value
mode
precision

compact(0, { precision: 0 });

Result: 0

COPYRIGHT © 2026