Spaces:
Running
Running
Download cost.js from noodcon/Training-Process: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/spaces/noodcon/Training-Process/resolve/main/cost.js
- Command line
-
hf download hf://spaces/noodcon/Training-Process/cost.js
-
curl -L -o cost.js https://huggingface.co/spaces/noodcon/Training-Process/resolve/main/cost.js
673 Bytes
| const UNIT_SECONDS = { | |
| second: 1, | |
| minute: 60, | |
| hour: 3600, | |
| day: 86400, | |
| month: 30.44 * 86400, | |
| year: 365.25 * 86400, | |
| }; | |
| export function unitSeconds(unit) { | |
| return UNIT_SECONDS[unit] ?? 3600; | |
| } | |
| // displayed = base + increment * elapsed / (every * unitSeconds) | |
| export function costAt(cost, nowMs) { | |
| const t0 = Date.parse(cost.baseTime); | |
| const elapsedSec = (nowMs - t0) / 1000; | |
| return cost.base + (cost.increment * elapsedSec) / (cost.every * unitSeconds(cost.unit)); | |
| } | |
| export function rateText(cost) { | |
| const unit = cost.every === 1 ? cost.unit : `${cost.every} ${cost.unit}s`; | |
| return `+$${Number(cost.increment).toLocaleString("en-US")} / ${unit}`; | |
| } | |