MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / formatFileSize

Function formatFileSize

webui/src/lib/utils.ts:8–14  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

6}
7
8export function formatFileSize(bytes: number): string {
9 if (bytes === 0) return '0 B'
10 const k = 1024
11 const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
12 const i = Math.floor(Math.log(bytes) / Math.log(k))
13 return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
14}
15
16export function formatDateTime(date: string | Date | number): string {
17 const d = typeof date === 'string' ? new Date(date) : typeof date === 'number' ? new Date(date * 1000) : date

Callers 1

FileCardFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected