MCPcopy Create free account
hub / github.com/error311/FileRise / parseSizeToBytes

Function parseSizeToBytes

public/js/fileListView.js:4638–4651  ·  view source on GitHub ↗

* Convert a file size string (e.g. "456.9KB", "1.2 MB", "1024") into bytes.

(sizeStr)

Source from the content-addressed store, hash-verified

4636 * Convert a file size string (e.g. "456.9KB", "1.2 MB", "1024") into bytes.
4637 */
4638function parseSizeToBytes(sizeStr) {
4639 if (!sizeStr) return 0;
4640 let s = sizeStr.trim();
4641 let value = parseFloat(s);
4642 let upper = s.toUpperCase();
4643 if (upper.includes("KB")) {
4644 value *= 1024;
4645 } else if (upper.includes("MB")) {
4646 value *= 1024 * 1024;
4647 } else if (upper.includes("GB")) {
4648 value *= 1024 * 1024 * 1024;
4649 }
4650 return value;
4651}
4652
4653/**
4654 * Format the total bytes as a human-readable string.

Callers 2

getLocalSummaryStatsFunction · 0.85
loadFileListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected