mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 18:21:28 +10:00
switch from sessionStorage to localStorage
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user