- 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:
2026-08-30 17:35:20 +02:00
parent 4776232377
commit 8e054a220d
5 changed files with 243 additions and 108 deletions
+11
View File
@@ -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]}`;
}