dejarun
Version:
A file system operation cache for Node.js, using a hash of the file or folder contents as the cache key.
23 lines (22 loc) • 1.24 kB
TypeScript
/**
* Caches the result of a callback function based on the hashes of input and output files or directories and additional dependencies.
* If the hashes of the inputs, outputs and other dependencies have not changed since the last run, the callback will not be executed.
*
* @param name - A unique name for the cache entry. Example: "build".
* @param callback - The function to execute if the cache is missed.
* @param options - An object containing the following optional properties:
* - inputs: An array of file or directory paths to hash for cache validation.
* - outputs: An array of file or directory paths to hash for cache validation.
* - dependencies: An array of arbitrary values to hash for cache validation.
* - clean: A boolean indicating whether to clean the cache (default: false).
* - debug: A boolean indicating whether to log debug information (default: false).
* - logo: A string or false to customize the logo in the logs (default: '[déjàrun]').
*/
export default function dejarun(name: string, callback: () => Promise<any>, options?: {
inputs?: string[];
outputs?: string[];
dependencies?: any[];
clean?: boolean;
debug?: boolean;
logo?: string | false;
}): Promise<void>;