switch from sessionStorage to localStorage

This commit is contained in:
Amruth Pillai
2023-11-15 06:34:17 +01:00
parent f7a21df042
commit 8171e90a6c
4 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,11 @@
export const delay = (time: number) => new Promise((resolve) => setTimeout(resolve, time));
export const withTimeout = async <T>(promise: Promise<T>, time: number): Promise<T> => {
const timeout = new Promise((_, reject) => setTimeout(() => reject, time));
const timeout = new Promise((_, reject) =>
setTimeout(() => {
return reject(new Error(`Operation timed out after ${time}ms`));
}, time),
);
return Promise.race([promise, timeout]) as T;
};