Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
export type StorageType = 'localStorage' | 'sessionStorage';
export interface UseStorageOptions<T> {
/** Storage key */
key: string;
/** Default value that will be set if value is not found in storage */
defaultValue?: T;
/** If set to true, value will be updated in useEffect after mount. Default value is true. */
getInitialValueInEffect?: boolean;
/** Determines whether the value must be synced between browser tabs, `true` by default */
sync?: boolean;
/** Function to serialize value into string to be save in storage */
serialize?: (value: T) => string;
/** Function to deserialize string value from storage to value */
deserialize?: (value: string | undefined) => T;
}
export type UseStorageReturnValue<T> = [
T,
(val: T | ((prevState: T) => T)) => void,
() => void
];
export declare function createStorage<T>(type: StorageType, hookName: string): ({ key, defaultValue, getInitialValueInEffect, sync, deserialize, serialize, }: UseStorageOptions<T>) => UseStorageReturnValue<T>;
export declare function readValue(type: StorageType): <T>({ key, defaultValue, deserialize, }: UseStorageOptions<T>) => T;