mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-11 11:55:38 +00:00
Fixes table sort for file size (#86)
* Fixed algorithm to de-humanize size string to bytes * Resolved linting issues
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
export const sortableSize = (string: string): number => {
|
||||
const UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
const UNITS = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
const [numStr, unit] = string.split(" ");
|
||||
|
||||
if (UNITS.indexOf(unit) === -1) return null;
|
||||
|
||||
const exponent = UNITS.indexOf(unit) * 3;
|
||||
return Number(numStr) * exponent ** 10;
|
||||
const exponent = UNITS.indexOf(unit) * 3 + 4;
|
||||
return Math.floor(Number(numStr) * 10 ** exponent);
|
||||
};
|
||||
|
||||
export const parseJwt = (token: string) => {
|
||||
|
||||
Reference in New Issue
Block a user