Skip to content

Commit

Permalink
add typings
Browse files Browse the repository at this point in the history
  • Loading branch information
sod committed Jun 13, 2018
1 parent 78420c5 commit 14bfa6e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Receptacle {
export interface Options {
id?: string;
max?: number;
items?: any[];
}

export interface SetOptions<X> {
ttl?: number;
refresh?: boolean;
meta?: X;
}
}

class Receptacle<T, X = undefined> {
constructor(options?: Receptacle.Options);
public id: string;
public max: number;
public items: T[];
public size: number;
public has(key: string): boolean;
public get(key: string): T;
public meta(key: string): X;
public set(key: string, value: T, options?: Receptacle.SetOptions<X>): void;
public delete(key: string): void;
public expire(key: string, ms: number = 0): void;
public clear(): void;
}

export = Receptacle;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"test": "npm run lint && make test",
"test-ci": "npm run lint && make test-ci"
},
"typings": "./index.d.ts",
"standard": {
"globals": [
"GIT_COMMIT",
Expand Down

0 comments on commit 14bfa6e

Please sign in to comment.