MCPcopy
hub / github.com/prisma/prisma / timeout

Function timeout

packages/cli/src/utils/nps/survey.ts:199–210  ·  view source on GitHub ↗

* Wraps a promise with a timeout. If the provided promise does not resolve within the given * time, the returned promise resolves to `undefined`.

(promise: Promise<T>, ms: number)

Source from the content-addressed store, hash-verified

197 * time, the returned promise resolves to `undefined`.
198 */
199function timeout<T>(promise: Promise<T>, ms: number): Promise<T | undefined> {
200 return new Promise((resolve) => {
201 const timeoutId = setTimeout(() => {
202 resolve(undefined)
203 }, ms)
204
205 return promise.then((result) => {
206 clearTimeout(timeoutId)
207 resolve(result)
208 })
209 })
210}
211
212function isWithinTimeframe(date: Date, timeframe: Timeframe): boolean {
213 return new Date(timeframe.start) <= date && new Date(timeframe.end) >= date

Callers 1

collectFeedbackFunction · 0.85

Calls 2

thenMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected