(input: number)
| 38 | } |
| 39 | |
| 40 | export function duration(input: number) { |
| 41 | if (input < 1000) { |
| 42 | return `${input}ms` |
| 43 | } |
| 44 | if (input < 60000) { |
| 45 | return `${(input / 1000).toFixed(1)}s` |
| 46 | } |
| 47 | if (input < 3600000) { |
| 48 | const minutes = Math.floor(input / 60000) |
| 49 | const seconds = Math.floor((input % 60000) / 1000) |
| 50 | return `${minutes}m ${seconds}s` |
| 51 | } |
| 52 | if (input < 86400000) { |
| 53 | const hours = Math.floor(input / 3600000) |
| 54 | const minutes = Math.floor((input % 3600000) / 60000) |
| 55 | return `${hours}h ${minutes}m` |
| 56 | } |
| 57 | const hours = Math.floor(input / 3600000) |
| 58 | const days = Math.floor((input % 3600000) / 86400000) |
| 59 | return `${days}d ${hours}h` |
| 60 | } |
| 61 | |
| 62 | export function truncate(str: string, len: number): string { |
| 63 | if (str.length <= len) return str |
no outgoing calls
no test coverage detected