MCPcopy Create free account
hub / github.com/PSPDFKit/nutrient-document-engine-mcp-server / formatFileSize

Function formatFileSize

src/utils/Common.ts:6–13  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

4 * Format file size in a human-readable format
5 */
6export const formatFileSize = (bytes: number): string => {
7 if (bytes === 0) return '0 B';
8 const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
9 const i = Math.floor(Math.log(bytes) / Math.log(1024));
10 const value = bytes / Math.pow(1024, i);
11 const precision = value >= 10 ? 0 : 1;
12 return `${value.toFixed(precision)} ${sizes[i]}`;
13};
14
15/**
16 * Format annotation location for display. AnnotationBBox: [left, top, width, height]

Callers 2

listDocumentsFunction · 0.85
dashboardTemplateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected