@feugene/mu
Version:
Helpful TS utilities without dependencies
26 lines • 1.16 kB
TypeScript
import type { TextNumber } from '../internal/types';
export type NumberFormatOptions = Readonly<{
decimals?: number;
decPoint?: string;
thousandsSeparator?: string;
clearDecimals?: boolean;
}>;
/**
* Format a number with thousand separators and a decimal point.
*
* Overloads supported:
* - Positional: `number(value, decimals?, decPoint?, thousandsSeparator?, clearDecimals?)`
* - Options object: `number(value, { decimals, decPoint, thousandsSeparator, clearDecimals })`
*
* Notes:
* - Returns `'NaN'` for `NaN` inputs; `Infinity`/`-Infinity` are stringified as-is.
* - Preserves the sign for negative zero when `decimals = 0` (e.g. `-0`).
* - When `clearDecimals = true`, fractional part is omitted for integer absolute values.
*
* @param value
* @param options
*/
export default function number(value: TextNumber, options?: NumberFormatOptions): string;
export default function number(value: TextNumber, decimals?: number, decPoint?: string, thousandsSeparator?: string, clearDecimals?: boolean): string;
export declare function numberRus(value: TextNumber, decimals?: number): string;
//# sourceMappingURL=number.d.ts.map