@technobuddha/library
Version:
A large library of useful functions
35 lines (34 loc) • 1.04 kB
TypeScript
export declare type Options = {
/**
* format specification to pass to @link{formatNumber}
*/
format?: string;
/**
* left padding to apply to numeric value
*/
pad?: number;
/**
* Array of suffixes to use for large values (default: ['K', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y'])
*/
macro?: ArrayLike<string>;
/**
* Array of suffixed to use for small values (default: ['m', 'µ', 'n', 'p', 'f', 'a', 'z', 'y'])
*/
micro?: ArrayLike<string>;
/**
* Multiplier for each level of suffixes (default: 1000)
*/
unit?: number;
/**
* Number of digits after the decimal point to display
*/
precision?: number;
};
/**
* Abbreviate a number by adding a suffix for metric units (i.e. 1000 => 1K, .0001 = 1m)
*
* @param input The number to abbreviate
* @param __namedParameters {@link MetricUnitOptions}
*/
export declare function metricUnits(input: number, { format, pad, macro, micro, unit, precision, }?: Options): string;
export default metricUnits;