MCPcopy Create free account
hub / github.com/1Panel-dev/MaxKB / toThousands

Function toThousands

ui/src/utils/common.ts:7–11  ·  view source on GitHub ↗
(num: any)

Source from the content-addressed store, hash-verified

5 * 数字处理
6 */
7export function toThousands(num: any) {
8 return num?.toString().replace(/\d+/, function (n: any) {
9 return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
10 })
11}
12
13export function numberFormat(num: number) {
14 return num < 1000 ? toThousands(num): toThousands((num / 1000).toFixed(1)) + 'k'

Callers 1

numberFormatFunction · 0.85

Calls 2

replaceMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected