UNPKG

cross-process-lock

Version:

Cross-process file locking solution with lock-queue

19 lines (18 loc) 671 B
export interface LockOptions { lockTimeout?: number; waitTimeout?: number; } export declare class LockError extends Error { } export type UnlockFunction = (file?: string) => Promise<void>; /** * Creates a cross-process lock for the given file, for the actual process. * * Note, that it will be only a soft-lock, the file will be locked for other * instances of cross-process-lock, or processes using the same API for locking. * * @param file The path of the file to lock. * @param options The lock options/timeout. * @returns The function to unlock the file. */ export declare function lock(file: string, options?: LockOptions): Promise<UnlockFunction>;