@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
45 lines • 1.46 kB
TypeScript
//#region src/utils/runOnce.d.ts
type RunOnceOptions = {
/**
* The function to execute when the sentinel is not found or is older than the cache timeout.
*/
onIsCached?: () => void | Promise<void>;
/**
* The time window in milliseconds during which the sentinel is considered valid.
*
* @default 60000 = 1 minute
*/
cacheTimeoutMs?: number;
/**
* If true, the callback will always run. If undefined, the callback will run only if the sentinel is older than the cache timeout.
*
* @default false
*/
forceRun?: boolean;
};
/**
* Ensures a callback function runs only once within a specified time window across multiple processes.
* Uses a sentinel file to coordinate execution and prevent duplicate work.
*
* @param sentinelFilePath - Path to the sentinel file used for coordination
* @param callback - The function to execute (should be async)
* @param options - The options for the runOnce function
*
* @example
* ```typescript
* await runPrepareIntlayerOnce(
* '/tmp/intlayer-sentinel',
* async () => {
* // Your initialization logic here
* await prepareIntlayer();
* },
* 30 * 1000 // 30 seconds cache
* );
* ```
*
* @throws {Error} When there are unexpected filesystem errors
*/
declare const runOnce: (sentinelFilePath: string, callback: () => void | Promise<void>, options?: RunOnceOptions) => Promise<void>;
//#endregion
export { runOnce };
//# sourceMappingURL=runOnce.d.ts.map