From d98e689d3fe0264aacc90f1ba1e347df21209309 Mon Sep 17 00:00:00 2001 From: Arylo Date: Mon, 19 Mar 2018 15:13:43 +0800 Subject: [PATCH] Add Annotations --- types/keyv/index.d.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/types/keyv/index.d.ts b/types/keyv/index.d.ts index 4de9e75fff..11e1895c9a 100644 --- a/types/keyv/index.d.ts +++ b/types/keyv/index.d.ts @@ -6,24 +6,50 @@ /// -// import * as events from 'events'; - interface KeyvOptions { + /** Namespace for the current instance. */ namespace?: string; + /** A custom serialization function. */ serialize: (data: any) => string; + /** A custom deserialization function. */ deserialize: (data: string) => any; + /** The connection string URI. */ uri?: string; + /** The storage adapter instance to be used by Keyv. */ store?: any; + /** Default TTL. Can be overridden by specififying a TTL on `.set()`. */ ttl?: number; + /** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */ adapter?: string; } declare class Keyv extends NodeJS.EventEmitter { + /** + * @param uri The connection string URI. + * + * Merged into the options object as options.uri. + * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. + */ constructor(uri?: string, opts?: KeyvOptions); + /** + * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. + */ constructor(opts?: KeyvOptions); + /** Returns the value. */ get(key: string): Promise; + /** + * Set a value. + * + * By default keys are persistent. You can set an expiry TTL in milliseconds. + */ set(key: string, value: any, ttl?: number): Promise; + /** + * Deletes an entry. + * + * Returns `true` if the key existed, `false` if not. + */ delete(key: string): Promise; + /** Delete all entries in the current namespace. */ clear(): Promise; }