@adonisjs/require-ts
Version:
In memory typescript compiler
68 lines (67 loc) • 1.82 kB
TypeScript
/**
* Exposes the API to write file parsed contents to disk as cache. Handles
* all the complexity of generate correct paths and creating contents
* hash
*/
export declare class Cache {
private appRoot;
private cacheRoot;
constructor(appRoot: string, cacheRoot: string);
/**
* Generates hash from file contents
*/
generateHash(contents: string): string;
/**
* Makes cache path from a given file path and its contents
*/
makeCachePath(filePath: string, contents: string, extname: '.js' | '.json'): string;
/**
* Returns the file contents from the cache (if exists), otherwise
* returns null
*/
get(cachePath: string): string | null;
/**
* Writes file contents to the disk
*/
set(cachePath: string, contents: string): void;
/**
* Clears all the generate cache for a given file
*/
clearForFile(filePath: string): void;
/**
* Clears the cache root folder
*/
clearAll(): void;
}
/**
* A parallel fake implementation of cache that results in noop. Used
* when caching is disabled.
*/
export declare class FakeCache {
constructor();
/**
* Generates hash from file contents
*/
generateHash(_: string): string;
/**
* Makes cache path from a given file path and its contents
*/
makeCachePath(_: string, __: string, ___: '.js' | '.json'): string;
/**
* Returns the file contents from the cache (if exists), otherwise
* returns null
*/
get(_: string): string | null;
/**
* Writes file contents to the disk
*/
set(_: string, __: string): void;
/**
* Clears all the generate cache for a given file
*/
clearForFile(_: string): void;
/**
* Clears the cache root folder
*/
clearAll(): void;
}