From 08ad762c42e5cebbad2d8ec5c27b0250f40e01fc Mon Sep 17 00:00:00 2001 From: Nalla Prakash <81852531+prakashNalla@users.noreply.github.com> Date: Fri, 30 Oct 2026 11:39:40 +0530 Subject: [PATCH] fix: show JSON and CSV formatter sizes just under 1 MB as MB --- app/(tools)/csv-formatter/components/StatsBar.tsx | 7 +------ app/(tools)/json-formatter/components/StatsBar.tsx | 13 ++++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/(tools)/csv-formatter/components/StatsBar.tsx b/app/(tools)/csv-formatter/components/StatsBar.tsx index 0f0bae7..8d67c22 100644 --- a/app/(tools)/csv-formatter/components/StatsBar.tsx +++ b/app/(tools)/csv-formatter/components/StatsBar.tsx @@ -1,5 +1,6 @@ "use client"; +import { formatBytes } from "@/lib/base64-utils"; import { byteLength, delimiterLabel, lineEndingLabel, DELIMITERS, type ParsedCsv } from "@/lib/csv-utils"; export function StatsBar({ parsed, input }: { parsed: ParsedCsv; input: string }) { @@ -43,9 +44,3 @@ function StatCell({ label, value, sub }: { label: string; value: string; sub?: s ); } - -function formatBytes(bytes: number): string { - if (bytes < 1024) return `${bytes} B`; - if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; - return `${(bytes / (1024 * 1024)).toFixed(2)} MB`; -} diff --git a/app/(tools)/json-formatter/components/StatsBar.tsx b/app/(tools)/json-formatter/components/StatsBar.tsx index 299adb8..cf8761a 100644 --- a/app/(tools)/json-formatter/components/StatsBar.tsx +++ b/app/(tools)/json-formatter/components/StatsBar.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useState } from "react"; +import { formatBytes } from "@/lib/base64-utils"; import { computeStats, gzipSize } from "@/lib/json-utils"; export function StatsBar({ input, output }: { input: string; output: string }) { @@ -26,9 +27,9 @@ export function StatsBar({ input, output }: { input: string; output: string }) { return (