9 lines
281 B
TypeScript
9 lines
281 B
TypeScript
|
|
function toThousands(num: any) {
|
||
|
|
return num.toString().replace(/\d+/, function (n: any) {
|
||
|
|
return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
|
||
|
|
})
|
||
|
|
}
|
||
|
|
export function numberFormat(num: number) {
|
||
|
|
return num < 1000 ? toThousands(num) : toThousands((num / 1000).toFixed(1)) + 'k'
|
||
|
|
}
|