/
grigoriygrisha
/
excel-loader
Обзор
Документация
Войти
/
grigoriygrisha
/
excel-loader
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/utils/format.ts
11 строк
328 B
grigoriy-grisha
first_commit
26 июл 2026, 21:46
26 июл 2026, 21:46
6cc93a5
Код
Авторство
О чём код?
export function formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B` const units = ['KB', 'MB', 'GB', 'TB'] let value = bytes / 1024 let unit = 0 while (value >= 1024 && unit < units.length - 1) { value /= 1024 unit++ } return `${value.toFixed(value >= 10 ? 0 : 1)} ${units[unit]}` }