Skip to content

Commit

Permalink
feat: use jedec
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelncui committed Oct 13, 2023
1 parent 3f8bc85 commit 814963d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export const hexEncode = (buf: string) => {
return str;
};

export const formatFilesize = (size: number | bigint): string => filesize(size as any as number, { standard: "iec" }) as string;
export const formatFilesize = (size: number | bigint): string =>
filesize(size as any as number, {
base: 2,
standard: "jedec",
}) as string;

export const download = (buf: Uint8Array, filename: string, contentType: string) => {
const blob = new Blob([buf], { type: contentType });
Expand All @@ -33,7 +37,10 @@ export const chonkyI18n: I18nConfig = {
...defaultFormatters,
formatFileSize: (_intl: IntlShape, file: Nullable<FileData>): Nullable<string> => {
if (!file || typeof file.size !== "number") return null;
return filesize(file.size, { standard: "iec" }) as string;
return filesize(file.size, {
base: 2,
standard: "jedec",
}) as string;
},
},
};

0 comments on commit 814963d

Please sign in to comment.