UNPKG

p-lock

Version:

Simple promise lock

12 lines (11 loc) 424 B
export type ReleaseFn = () => void; export type Lock = (key?: string) => Promise<ReleaseFn>; export type LockOptions = { /** * When aquiring a lock for some key, replace first promise in line rather than adding to queue. * Replaced promise will be rejected. * Default: `false` */ replace?: boolean; }; export declare function getLock(options?: LockOptions): (key?: string) => Promise<ReleaseFn>;