UNPKG

@shipengine/connect-loader

Version:

Internal library for loading ShipEngine Connect apps

32 lines (31 loc) 1.05 kB
/** * Caches parsed file contents so the same file doesn't get read and parsed multiple times. * This also ensures that multiple references to the same file resolve to the same parsed obect instance. */ declare class FileCache { private readonly _cache; private _loadsInProgress; /** * Adds the given value to the cache */ add<T>(filePath: string, promise: Promise<T>): Promise<T>; /** * Gets the specified value from the cache, if it exists */ get<T>(filePath: string): Promise<T> | undefined; /** * Lets the cache know that a ShipEngine Connect app is currently being loaded. * Be sure to call `finishedLoading()` afterward so the cache can be cleared to free-up memory. */ startedLoading(): void; /** * Lets the cache know that a ShipEngine Connect app has finished loading. * The cache will be cleared to free-up memory. */ finishedLoading(): void; } /** * The singleton instance of the FileCache */ export declare const fileCache: FileCache; export {};