MCPcopy
hub / github.com/transloadit/uppy / wrapPromiseFunction

Method wrapPromiseFunction

packages/@uppy/utils/src/TaskQueue.ts:248–259  ·  view source on GitHub ↗

* @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,
  )

Source from the content-addressed store, hash-verified

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}

Callers 8

TaskQueue.test.tsFile · 0.45
uploadRemoteFileMethod · 0.45
createWebsocketMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
prepareUploadMethod · 0.45
setOptionsMethod · 0.45

Calls 2

addMethod · 0.95
fnFunction · 0.85

Tested by

no test coverage detected