file-age
Version:
Get file age/timestamp information with human-readable formatting
45 lines (36 loc) • 1.21 kB
TypeScript
export interface FileAgeOptions {
human?: boolean;
type?: 'modified' | 'created' | 'birth' | 'accessed' | 'access' | 'mod';
format?: 'relative' | 'absolute';
precise?: boolean;
}
export interface ComparisonResult {
file1: { path: string; timestamp: number };
file2: { path: string; timestamp: number };
newer: string;
older: string;
difference: number;
differenceHuman: string;
}
export interface FindOptions {
olderThan?: number | string;
newerThan?: number | string;
recursive?: boolean;
}
declare function fileAge(filePath: string, options?: FileAgeOptions): Promise<number | string>;
export declare function fileAgeSync(filePath: string, options?: FileAgeOptions): number | string;
export declare function fileAgeMultiple(
filePaths: string[],
options?: FileAgeOptions
): Promise<Record<string, number | string | { error: string }>>;
export declare function compareFileAge(
file1: string,
file2: string,
options?: FileAgeOptions
): Promise<ComparisonResult>;
export declare function findFilesByAge(
dirPath: string,
options: FindOptions
): Promise<string[]>;
export declare function formatDuration(ms: number, future?: boolean): string;
export default fileAge;