switched to new way :)

This commit is contained in:
Boki 2026-02-13 01:12:11 -05:00
parent b03a2a25f1
commit f22d182c8f
30 changed files with 0 additions and 0 deletions

13
src-old/util/clipboard.ts Normal file
View file

@ -0,0 +1,13 @@
import { execSync } from 'child_process';
export function readClipboard(): string {
try {
return execSync('powershell -command "Get-Clipboard"', { encoding: 'utf-8' }).trim();
} catch {
return '';
}
}
export function writeClipboard(text: string): void {
execSync(`powershell -command "Set-Clipboard -Value '${text.replace(/'/g, "''")}'"`);
}

12
src-old/util/logger.ts Normal file
View file

@ -0,0 +1,12 @@
import pino from 'pino';
export const logger = pino({
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'HH:MM:ss',
ignore: 'pid,hostname',
},
},
});

24
src-old/util/retry.ts Normal file
View file

@ -0,0 +1,24 @@
import { sleep } from './sleep.js';
import { logger } from './logger.js';
export async function retry<T>(
fn: () => Promise<T>,
options: { maxAttempts?: number; delayMs?: number; label?: string } = {},
): Promise<T> {
const { maxAttempts = 3, delayMs = 1000, label = 'operation' } = options;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
return await fn();
} catch (err) {
if (attempt === maxAttempts) {
logger.error({ err, attempt, label }, `${label} failed after ${maxAttempts} attempts`);
throw err;
}
logger.warn({ err, attempt, label }, `${label} failed, retrying in ${delayMs}ms...`);
await sleep(delayMs * attempt);
}
}
throw new Error('Unreachable');
}

8
src-old/util/sleep.ts Normal file
View file

@ -0,0 +1,8 @@
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function randomDelay(minMs: number, maxMs: number): Promise<void> {
const delay = minMs + Math.random() * (maxMs - minMs);
return sleep(delay);
}