[@keyv/mongo] Add types (#31806)

This commit is contained in:
Dimitri Benin 2018-12-31 18:51:27 +00:00 committed by Sheetal Nandi
parent ae36dd3474
commit 6fd150e951
4 changed files with 74 additions and 0 deletions

33
types/keyv__mongo/index.d.ts vendored Normal file
View File

@ -0,0 +1,33 @@
// Type definitions for @keyv/mongo 1.0
// Project: https://github.com/lukechilds/keyv-mongo
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { Store } from 'keyv';
import { EventEmitter } from 'events';
export = KeyvMongo;
declare class KeyvMongo<TValue> extends EventEmitter implements Store<TValue> {
readonly ttlSupport: false;
namespace?: string;
constructor(uri?: string);
constructor(options?: KeyvMongo.Options); // tslint:disable-line:unified-signatures
get(key: string): Promise<TValue | undefined>;
set(key: string, value: TValue, ttl?: number): Promise<any>;
delete(key: string): Promise<boolean>;
clear(): Promise<void>;
}
declare namespace KeyvMongo {
interface Options {
uri?: string;
url?: string;
collection?: string;
}
}

View File

@ -0,0 +1,12 @@
import Keyv = require('keyv');
import KeyvMongo = require('@keyv/mongo');
new Keyv('mongodb://user:pass@localhost:27017/dbname', { collection: 'cache' });
new KeyvMongo({ uri: 'mongodb://user:pass@localhost:27017/dbname' });
new KeyvMongo({ url: 'mongodb://user:pass@localhost:27017/dbname' });
new KeyvMongo({ collection: 'cache' });
new KeyvMongo('mongodb://user:pass@localhost:27017/dbname');
const mongo = new KeyvMongo('mongodb://user:pass@localhost:27017/dbname');
new Keyv({ store: mongo });

View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@keyv/mongo": [
"keyv__mongo"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"keyv__mongo-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }