Skip to content

Commit

Permalink
format: render 0.100KB as 100B (#6627)
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng authored May 22, 2024
1 parent 2a89eb4 commit 68a5e7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/format/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function truncateDecimalZeroes(numString: string): string {

export function bytes(bytes: number | Long) {
bytes = +bytes;
if (bytes < 100) {
if (bytes < 1e3) {
return bytes + "B";
}
if (bytes < 1e6) {
Expand Down
2 changes: 1 addition & 1 deletion app/format/format_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe("bytes", () => {
it("should abbreviate large numbers", () => {
expect(format.bytes(0)).toEqual("0B");
expect(format.bytes(99)).toEqual("99B");
expect(format.bytes(100)).toEqual("0.1KB");
expect(format.bytes(100)).toEqual("100B");
expect(format.bytes(1020)).toEqual("1.02KB");
expect(format.bytes(1023)).toEqual("1.023KB");
expect(format.bytes(1e6 - 1)).toEqual("1000KB");
Expand Down

0 comments on commit 68a5e7b

Please sign in to comment.