-): Promise<T> => {
- // Create a timeout promise that rejects in timeout milliseconds
- const timeoutPromise = new Promise<never>((_, reject) => {
- setTimeout(() => {
- if (isPromisePending(promise)) {
- timeoutCallback();
- // FIXME: The original promise shall be canceled
- }
- reject(timeoutError);
- }, timeoutMs);
- });
-
- // Returns a race between timeout promise and the passed promise
- return Promise.race<T>([promise, timeoutPromise]);
-};
-
-// export const compose = <T>(...fns: ((arg: T) => T)[]): ((x: T) => T) => {
-// return (x: T) => fns.reduceRight((y, fn) => fn(y), x);
-// };
+ return changedValue
+}
+
+export const getFromLocalStorage = <T>(key: string, defaultValue: T): T => {
+ const item = localStorage.getItem(key)
+ return item != null ? (JSON.parse(item) as T) : defaultValue
+}
+
+export const setToLocalStorage = <T>(key: string, value: T): void => {
+ localStorage.setItem(key, JSON.stringify(value))
+}
+
+export const deleteFromLocalStorage = (key: string): void => {
+ localStorage.removeItem(key)
+}
+
+export const getLocalStorage = (): Storage => {
+ return localStorage
+}
+
+export const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => {
+ return crypto.randomUUID()
+}
+
+export const validateUUID = (
+ uuid: `${string}-${string}-${string}-${string}-${string}`
+): uuid is `${string}-${string}-${string}-${string}-${string}` => {
+ return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(uuid)
+}
+
+export const useUIClient = (): UIClient => {
+ return UIClient.getInstance()
+}