2025-08-21 09:41:46 +09:00
|
|
|
import { clsx, type ClassValue } from "clsx";
|
|
|
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
|
|
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
|
|
|
return twMerge(clsx(inputs));
|
|
|
|
|
}
|
2025-09-26 13:11:34 +09:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 파일 크기를 사람이 읽기 쉬운 형태로 포맷팅
|
|
|
|
|
*/
|
|
|
|
|
export function formatFileSize(bytes: number): string {
|
2026-03-10 18:30:18 +09:00
|
|
|
if (bytes === 0) return "0 Bytes";
|
2025-09-26 13:11:34 +09:00
|
|
|
const k = 1024;
|
2026-03-10 18:30:18 +09:00
|
|
|
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
2025-09-26 13:11:34 +09:00
|
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
2026-03-10 18:30:18 +09:00
|
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
2025-09-26 13:11:34 +09:00
|
|
|
}
|