Initial commit

This commit is contained in:
backuppc
2026-01-16 14:35:56 +09:00
commit 550b8263db
15 changed files with 1183 additions and 0 deletions

29
utils.ts Normal file
View File

@@ -0,0 +1,29 @@
export const generateId = (): string => {
return Math.random().toString(36).substring(2, 9);
};
export const formatTime = (date: Date): string => {
const h = date.getHours().toString().padStart(2, '0');
const m = date.getMinutes().toString().padStart(2, '0');
const s = date.getSeconds().toString().padStart(2, '0');
const ms = date.getMilliseconds().toString().padStart(3, '0');
return `${h}:${m}:${s}.${ms}`;
};
export const uInt8ArrayToHex = (arr: Uint8Array): string => {
return Array.from(arr)
.map(b => b.toString(16).padStart(2, '0').toUpperCase())
.join(' ');
};
export const uInt8ArrayToAscii = (arr: Uint8Array): string => {
// Replace non-printable characters with a dot or special symbol to avoid rendering issues
return Array.from(arr)
.map(b => {
if (b >= 32 && b <= 126) {
return String.fromCharCode(b);
}
return '.'; // Placeholder for non-printable chars
})
.join('');
};