(val, type, digit, defaultVal = '-')
| 2 | import { isFunction } from 'utils-lite' |
| 3 | |
| 4 | export const getFormated = (val, type, digit, defaultVal = '-') => { |
| 5 | if (isNaN(val)) return defaultVal |
| 6 | if (!type) return val |
| 7 | if (isFunction(type)) return type(val, numerify) |
| 8 | |
| 9 | digit = isNaN(digit) ? 0 : ++digit |
| 10 | const digitStr = `.[${new Array(digit).join(0)}]` |
| 11 | let formatter = type |
| 12 | switch (type) { |
| 13 | case 'KMB': |
| 14 | formatter = digit ? `0,0${digitStr}a` : '0,0a' |
| 15 | break |
| 16 | case 'normal': |
| 17 | formatter = digit ? `0,0${digitStr}` : '0,0' |
| 18 | break |
| 19 | case 'percent': |
| 20 | formatter = digit ? `0,0${digitStr}%` : '0,0.[00]%' |
| 21 | break |
| 22 | } |
| 23 | return numerify(val, formatter) |
| 24 | } |
| 25 | |
| 26 | export const getStackMap = (stack) => { |
| 27 | const stackMap = {} |
no outgoing calls
no test coverage detected