-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.ts
36 lines (29 loc) · 891 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
type TStorage = {
delete(key: string): void;
deleteAll(): void;
get<T = unknown>(key: string): T | string | null;
has(key: string): boolean;
listener: Subscribe;
};
export type Unsubscribe = () => void;
export type Subscribe = (storage: any) => Unsubscribe;
export type TypeStorage = TStorage & {
json<T>(parse?: boolean): T;
set<T = unknown>(key: string, object: T): void;
};
type CookieAge = number | string | Date;
export type SetCookiesParser = Array<{ name: keyof SetCookies; parse: (opts: SetCookies) => string }>;
export type SetCookies = Partial<{
domain: string;
expires: CookieAge;
maxAge: CookieAge;
multiDomain?: boolean;
partitioned: boolean;
path: string;
sameSite: "strict" | "lax" | "none" | "";
useSecure: boolean;
}>;
export type CookieStorage = TStorage & {
json<T>(): T;
set<T = unknown>(key: string, object: T, parameters?: SetCookies): void;
};