UNPKG

@trilitech-umami/umami-embed

Version:

[WIP - not ready for production use] A simple embeddable Umami wallet

12 lines (11 loc) 571 B
// allows to kill a promise if it takes more than the specified timeout export const withTimeout = (fn, timeout, errorMessage) => Promise.race([ fn(), // it's safe to use the same type parameter T here // because we're going to throw anyway which stops the execution new Promise((_, reject) => setTimeout(() => { reject(new Error(errorMessage || "The operation has timed out")); }, timeout)), ]); // eslint-disable-next-line @typescript-eslint/no-explicit-any export const isFailedResponse = (response) => typeof response?.error === "string";