number-string
Version:
Functions to format number to string
44 lines (43 loc) • 1.59 kB
TypeScript
export interface ToNumberOptions {
decimalMark?: string;
}
/**
* Convert value to number string
*/
export declare function toNumberString(value: string | number, { decimalMark, }?: ToNumberOptions): string;
/**
* Convert value to number
*/
export declare function toNumber(value: string | number, { decimalMark, }?: ToNumberOptions): number;
export interface ToCleanOptions {
decimalMark?: string;
/** @deprecated use thousandSeparator instead. */
thousandSeperator?: string | null;
thousandSeparator?: string;
maxPrecision?: number;
minPrecision?: number;
}
/**
* Like `toFixed` but removes trailing zeros
*/
export declare function toClean(value: string | number, { decimalMark, thousandSeperator, thousandSeparator, maxPrecision, minPrecision, }?: ToCleanOptions): string;
export interface ToMoneyOptions {
decimalMark?: string;
/** @deprecated use thousandSeparator instead. */
thousandSeperator?: string | null;
thousandSeparator?: string;
maxPrecision?: number;
minPrecision?: number;
symbol?: string;
symbolBehind?: boolean;
useParens?: boolean;
}
/**
* Convert string or number to currency string
* modified from http://stackoverflow.com/a/149099/806777\
*/
export declare function toMoney(value: string | number, { decimalMark, thousandSeperator, thousandSeparator, maxPrecision, minPrecision, symbol, symbolBehind, useParens, }?: ToMoneyOptions): string;
/**
* Round number to closest multiple of number
*/
export declare function toClosest(value: string | number, roundTo?: string | number): number;