Download apps/readest-app/src/utils/progress.ts from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/progress.ts
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src/utils/progress.ts
-
curl -L -o progress.ts https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/progress.ts
1 kB
| import { localizeNumber } from './number'; | |
| export function formatProgress( | |
| current: number | undefined, | |
| total: number | undefined, | |
| template: string, | |
| localize: boolean = false, | |
| language: string = 'en', | |
| fractionDigits: number = 1, | |
| ): string { | |
| if (current !== undefined && total !== undefined && total > 0 && current >= 0) { | |
| const currentStr = localize ? localizeNumber(current + 1, language, true) : String(current + 1); | |
| const totalStr = localize ? localizeNumber(total, language, true) : String(total); | |
| return template | |
| .replace('{current}', currentStr) | |
| .replace('{total}', totalStr) | |
| .replace('{percent}', (((current + 1) / total) * 100).toFixed(fractionDigits)); | |
| } else { | |
| return ''; | |
| } | |
| } | |
| export function formatNumber( | |
| number: number | undefined, | |
| localize: boolean = false, | |
| language: string = 'en', | |
| ): string { | |
| if (number === undefined || number < 0) { | |
| return ''; | |
| } | |
| return localize ? localizeNumber(number, language) : String(number); | |
| } | |