Spaces:
Running
Running
Download src/lib/format.ts from mrfakename/flow: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/spaces/mrfakename/flow/resolve/main/src/lib/format.ts
- Command line
-
hf download hf://spaces/mrfakename/flow/src/lib/format.ts
-
curl -L -o format.ts https://huggingface.co/spaces/mrfakename/flow/resolve/main/src/lib/format.ts
650 Bytes
| export const fmtDuration = (ms: number) => { | |
| if (ms < 1000) return `${Math.round(ms)}ms`; | |
| const s = ms / 1000; | |
| if (s < 60) return `${s.toFixed(1)}s`; | |
| const m = Math.floor(s / 60); | |
| return `${m}m ${Math.round(s - m * 60)}s`; | |
| }; | |
| export const timeAgo = (ts: number, now = Date.now()) => { | |
| const s = Math.max(0, Math.round((now - ts) / 1000)); | |
| if (s < 5) return "just now"; | |
| if (s < 60) return `${s}s ago`; | |
| const m = Math.floor(s / 60); | |
| if (m < 60) return `${m}m ago`; | |
| const h = Math.floor(m / 60); | |
| return `${h}h ago`; | |
| }; | |
| export const isMac = /Mac|iPhone|iPad/.test(navigator.platform); | |
| export const MOD = isMac ? "⌘" : "Ctrl"; | |