@acrool/js-utils
Version:
Common javascript utils methods for project development
34 lines (33 loc) • 921 B
TypeScript
/**
* 安全保留小數位(無條件捨去、不產生浮點誤差)
* @param val 原始數值
* @param decimalPlaces 保留幾位小數,預設為 0
* @returns 字串格式的小數數值
*/
export declare function safeFormatDecimal(val?: number | string, decimalPlaces?: number): string;
/**
* 千分位格式化
* @param val 原數值
* @param decimalPlaces
*/
export declare function formatCurrency(val?: number, decimalPlaces?: number): string;
/**
* 取得數組中的交集最小範圍
* obj = [
* [1, 20],
* [5, 24]
* ]
*
* result = {min: 5, max: 20}
* @param arrayNumber
*/
export declare function intersectionMin(arrayNumber: Array<[number, number]>): {
min: number;
max: number;
};
/**
* 安全地移除数字字符串中的前导零
* @param str 要处理的字符串
* @returns 处理后的字符串
*/
export declare function removeLeadingZero(str: string): string;