* @deprecated Legacy compatibility wrapper for RateLimitedQueue API. * Wraps a function so that when called, it's queued and returns an AbortablePromise. * Note: for legacy compatibility with RateLimitedQueue, the wrapped function * does not receive this queue's AbortSignal. Aborting the re
(
fn: T,
)
| 246 | * function unless that function is wired to an external AbortSignal. |
| 247 | */ |
| 248 | wrapPromiseFunction<T extends (...args: any[]) => Promise<any>>( |
| 249 | fn: T, |
| 250 | ): (...args: Parameters<T>) => AbortablePromise<Awaited<ReturnType<T>>> { |
| 251 | return (...args: Parameters<T>) => { |
| 252 | return this.add((signal) => { |
| 253 | // The wrapped function doesn't receive signal directly, |
| 254 | // caller is responsible for using signal if needed |
| 255 | void signal |
| 256 | return fn(...args) |
| 257 | }) |
| 258 | } |
| 259 | } |
| 260 | } |
no test coverage detected