(semaphore: Semaphore, fn: () => Promise<T>)
| 10 | * Ensures the semaphore permit is always released, even if the function throws. |
| 11 | */ |
| 12 | export async function withSemaphore<T>(semaphore: Semaphore, fn: () => Promise<T>): Promise<T> { |
| 13 | await semaphore.acquire(); |
| 14 | try { |
| 15 | return await fn(); |
| 16 | } finally { |
| 17 | semaphore.release(); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Recursively list all files in a GitHub directory. |
no outgoing calls
no test coverage detected
searching dependent graphs…