simple-task-master
Version:
A simple command-line task management tool
64 lines • 2.18 kB
TypeScript
/**
* Utility functions for Simple Task Master
*/
/**
* Validates that a path is safe and within allowed directories
*/
export declare function validatePath(filePath: string): string;
/**
* Ensures a directory exists, creating it if necessary
*/
export declare function ensureDirectory(dirPath: string): Promise<void>;
/**
* Safely reads a file with error handling
*/
export declare function safeReadFile(filePath: string): Promise<string>;
/**
* Checks if a file exists
*/
export declare function fileExists(filePath: string): Promise<boolean>;
/**
* Gets the size of a file in bytes
*/
export declare function getFileSize(filePath: string): Promise<number>;
/**
* Formats a timestamp to ISO string
*/
export declare function formatTimestamp(date?: Date): string;
/**
* Parses an ISO timestamp string
*/
export declare function parseTimestamp(timestamp: string): Date;
/**
* Sanitizes a string for use as a filename
*/
export declare function sanitizeFilename(input: string): string;
/**
* Truncates a string to a maximum length
*/
export declare function truncateString(str: string, maxLength: number): string;
/**
* Debounce function to limit how often a function can be called
*/
export declare function debounce<T extends (...args: unknown[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* Sleep for a specified number of milliseconds
*/
export declare function sleep(ms: number): Promise<void>;
/**
* Retry a function with exponential backoff
*/
export declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, baseDelay?: number): Promise<T>;
/**
* Reads input from stdin with optional timeout
*/
export declare function readStdin(timeoutMs?: number): Promise<string>;
/**
* Launches an external editor to get user input
*/
export declare function launchEditor(initialContent?: string): Promise<string>;
/**
* Reads input from either a direct value, stdin (if value is "-"), or editor fallback
*/
export declare function readInput(value: string | undefined, fallbackToEditor?: boolean, editorPrompt?: string, stdinTimeoutMs?: number): Promise<string | undefined>;
//# sourceMappingURL=utils.d.ts.map