init: 2.B

This commit is contained in:
AncTe committed 2026-02-28 20:23:34 +08:00
commit 6bf32174d8
610 files changed
+151444

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { createHash } from 'crypto';
export function uniqueSymbol() {
return Math.ceil(Math.random() * 0xefffffff + 0x10000000).toString(16);
}
export function fileHash(
content: string | Buffer | Uint8Array,
length: number = 8
) {
return createHash('sha256').update(content).digest('hex').slice(0, length);
}
export function formatSize(size: number) {
if (size < 1 << 10) {
return `${size.toFixed(2)}B`;
} else if (size < 1 << 20) {
return `${(size / (1 << 10)).toFixed(2)}KB`;
} else if (size < 1 << 30) {
return `${(size / (1 << 20)).toFixed(2)}MB`;
} else {
return `${(size / (1 << 30)).toFixed(2)}GB`;
}
}