-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.d.ts
50 lines (44 loc) · 1.26 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace Receptacle {
export interface Options<T> {
id?: number|string;
max?: number;
items?: Items<T>[];
lastModified?: Date;
}
export interface Export<T, X> {
id: number|string;
max: number|undefined;
items: (Items<T> & InternalItemData<T>)[];
lastModified: Date;
}
export interface SetOptions<X> {
ttl?: number;
refresh?: boolean;
meta?: X;
}
export interface InternalItemData<X> {
meta: X|undefined;
refresh: number|undefined;
expires: number|undefined;
}
export interface Items<T> {
key: string;
value: T;
}
}
class Receptacle<T, X = undefined> {
constructor(options?: Receptacle.Options<T>);
public id: number|string;
public max: number;
public items: Receptacle.Items<T>[];
public size: number;
public has(key: string): boolean;
public get(key: string): T|null;
public meta(key: string): X|undefined;
public set(key: string, value: T, options?: Receptacle.SetOptions<X>): Receptacle;
public delete(key: string): void;
public expire(key: string, ms: number = 0): void;
public clear(): void;
public toJSON(): Receptacle.Export<T, X>;
}
export = Receptacle;