- implemented the rest of long-format compatible ls flags
- split path_resolver functions to 3 separate functions that prioritize different points of relativity - added a `convertToUnit`function to convert from bytes to higher units of messurement - revert change: excluded inode 0 from tree traversal results
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export function convertToUnit(bytes: number, decimalPoint?: number, pow: 1024 | 1000 = 1024): string {
|
||||
if (!+bytes) return "0";
|
||||
|
||||
const k: number = pow;
|
||||
const dp: number = decimalPoint ? (decimalPoint < 0 ? 0 : decimalPoint) : 1;
|
||||
const units: string[] = ["", "K", "M", "G", "T", "P"];
|
||||
|
||||
const i: number = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return `${(bytes / Math.pow(k, i)).toFixed(dp)}${units[i]}`;
|
||||
}
|
||||
Reference in New Issue
Block a user