(lockPath: string, fn: () => Promise<T>, opts?: LockOptions)
| 73 | |
| 74 | /** Run `fn` while holding `lockPath`; always releases, even on throw. */ |
| 75 | export async function withLock<T>(lockPath: string, fn: () => Promise<T>, opts?: LockOptions): Promise<T> { |
| 76 | const lock = await acquireLock(lockPath, opts); |
| 77 | try { |
| 78 | return await fn(); |
| 79 | } finally { |
| 80 | await lock.release(); |
| 81 | } |
| 82 | } |
no test coverage detected