initial commit of meta-dup

This commit is contained in:
Pierre
2026-02-08 16:29:39 +01:00
parent b3a9adbf3c
commit 2baa9a6925
27 changed files with 6735 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
/**
* Formatting utilities
*/
export function formatNumber(num: number): string {
return num.toLocaleString();
}
export function formatBytes(bytes: number): string {
if (bytes === 0) return '0 B';
const k = 1024;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
export function formatDate(dateStr: string): string {
return new Date(dateStr).toLocaleString();
}
export function getFilename(path: string): string {
return path.split('/').pop() || path;
}
export function truncateHash(hash: string, length: number = 16): string {
if (hash.length <= length) return hash;
return `${hash.substring(0, length)}...`;
}