This function helps you timeout your promises while keeping the TS types right.
Example
awaitrace(yourPromise, 1000); // resolves (or rejects) with the value of yourPromise or rejects with "Race: Timeout" message in a second
Example
typeData = { a: number }; constmyPromise = newPromise<Data>((resolve) =>setTimeout(() =>resolve({ a:1 }), 2000)); const { a } = awaitrace(myPromise, 1000); // You're allowed to destructure the result with TS
This function helps you timeout your promises while keeping the TS types right.
Example
Example