generated from wayfair-incubator/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
27 lines (24 loc) · 872 Bytes
/
index.d.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
export type ExpirableStorage = {
getItem: (key: string) => unknown | null;
setItem: (key: string, value: unknown, ttl: number) => boolean;
removeItem: (key: string) => void;
clear: () => void;
flush: () => void;
};
export type ExpirableStorageOptions = {
autoFlushInterval?: number;
storage: Storage;
};
export const expirableLocalStorage: ExpirableStorage;
export const expirableSessionStorage: ExpirableStorage;
/**
* Creates an instance of expirable data storage.
* @param options.autoFlushInterval An interval in seconds to flush expired
* values. Default 900 (15 minutes).
* @param options.storage n instance of Storage class. Default `localStorage`.
* @return An instance of expirable data storage.
*/
export function createExpirableStorage({
autoFlushInterval: number,
storage: Storage,
}: ExpirableStorageOptions): ExpirableStorage;