forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lscache.d.ts
49 lines (47 loc) · 1.48 KB
/
lscache.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Type definitions for lscache v1.0.5
// Project: https://github.com/pamelafox/lscache
// Definitions by: Chris Martinez <https://github.com/Chris-Martinezz>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface LSCache {
/**
* Stores the value in localStorage. Expires after specified number of minutes.
* @param {string} key
* @param {Object|string} value
* @param {number} time
*/
set(key: string, value: any, time?: number): void;
/**
* Retrieves specified value from localStorage, if not expired.
* @param {string} key
* @return {string|Object}
*/
get(key: string): any;
/**
* Removes a value from localStorage.
* Equivalent to 'delete' in memcache, but that's a keyword in JS.
* @param {string} key
*/
remove(key: string): void;
/**
* Flushes all lscache items and expiry markers without affecting rest of localStorage
*/
flush(): void;
/**
* Flushes expired lscache items and expiry markers without affecting rest of localStorage
*/
flushExpired(): void;
/**
* Appends CACHE_PREFIX so lscache will partition data in to different buckets.
* @param {string} bucket
*/
setBucket(bucket: string):void;
/**
* Resets the string being appended to CACHE_PREFIX so lscache will use the default storage behavior.
*/
resetBucket(): void;
}
declare var lscache:LSCache;
declare module 'lscache' {
var lscache: LSCache;
export = lscache;
}