MCPcopy Index your code
hub / github.com/testing-library/react-hooks-testing-library / wrap

Function wrap

src/helpers/createTimeoutController.ts:11–29  ·  view source on GitHub ↗
(promise: Promise<void>)

Source from the content-addressed store, hash-verified

9 timeoutCallbacks.push(callback)
10 },
11 wrap(promise: Promise<void>) {
12 return new Promise<void>((resolve, reject) => {
13 timeoutController.timedOut = false
14 timeoutController.onTimeout(resolve)
15
16 if (timeout) {
17 timeoutId = setTimeout(() => {
18 timeoutController.timedOut = true
19 timeoutCallbacks.forEach((callback) => callback())
20 resolve()
21 }, timeout)
22 }
23
24 promise
25 .then(resolve)
26 .catch(reject)
27 .finally(() => timeoutController.cancel())
28 })
29 },
30 cancel() {
31 clearTimeout(timeoutId)
32 },

Callers

nothing calls this directly

Calls 1

callbackFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…