Share the one HTTP envelope and the one byte formatter
Both stores carried their own ~28-line request<T>, and formatBytes existed twice – the second copy had lost the "B" branch, so a small sprite would have read as 0 KB had its caller ever passed one under a kilobyte. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
787a19d525
commit
b13b130da7
11 files changed
+80
-78
No files matched your search
@@ -42,3 +42,9 @@ export function snapToStep(value: number, stepSize: number): number {
|
||||
export function zoomFactor(deltaY: number): number {
|
||||
return Math.exp(-deltaY * 0.0015);
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes >= 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
||||
// A small sprite is a few hundred bytes, and "0 KB" reads like a broken file.
|
||||
return bytes >= 1024 ? `${Math.round(bytes / 1024)} KB` : `${bytes} B`;
|
||||
}
|
||||
Reference in new issue
Block a user