Skip to content

Commit

Permalink
Add large SI units
Browse files Browse the repository at this point in the history
Issue #259
  • Loading branch information
qu1ck committed Mar 1, 2025
1 parent 4812978 commit d04efc5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/trutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import type { ProgressBarVariant } from "./components/progressbar";
import { Status } from "rpc/transmission";
import type { Torrent } from "rpc/torrent";

const SISuffixes = ["B", "KB", "MB", "GB", "TB"];
const SIUnits = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"];

export function bytesToHumanReadableStr(value: number): string {
let unit = "";
let divisor = 1.0;

for (unit of SISuffixes) {
for (unit of SIUnits) {
if (value < 1024 * divisor) break;
divisor *= 1024;
}
Expand Down

0 comments on commit d04efc5

Please sign in to comment.