MCPcopy Create free account
hub / github.com/lightdash/lightdash / formatFileSize

Function formatFileSize

packages/frontend/src/utils/formatters.ts:1–7  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

1export const formatFileSize = (bytes: number): string => {
2 if (bytes < 1024) return `${bytes} B`;
3 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
4 if (bytes < 1024 * 1024 * 1024)
5 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
6 return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
7};
8
9export const formatDuration = (ms: number): string => {
10 if (ms < 1000) return `${ms}ms`;

Calls

no outgoing calls

Tested by

no test coverage detected