MCPcopy
hub / github.com/Crosstalk-Solutions/project-nomad / formatBytes

Function formatBytes

admin/inertia/lib/util.ts:15–22  ·  view source on GitHub ↗
(bytes: number, decimals = 2)

Source from the content-addressed store, hash-verified

13}
14
15export function formatBytes(bytes: number, decimals = 2): string {
16 if (bytes === 0) return '0 Bytes'
17 const k = 1024
18 const dm = decimals < 0 ? 0 : decimals
19 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
20 const i = Math.floor(Math.log(bytes) / Math.log(k))
21 return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
22}
23
24export function generateRandomString(length: number): string {
25 const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'

Callers 15

ActiveDownloadsFunction · 0.90
StorageProjectionBarFunction · 0.90
CuratedCollectionCardFunction · 0.90
CategoryCardFunction · 0.90
WikipediaSelectorFunction · 0.90
ActiveModelDownloadsFunction · 0.90
PreflightStatusFunction · 0.90
ServiceStatsModalFunction · 0.90
KbGuardrailModalFunction · 0.90
TierSelectionModalFunction · 0.90
ContentUpdatesSectionFunction · 0.90
ContentAutoUpdateSectionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected