Merge pull request #32649 from MutterPedro/master

Added mem-cache module types definitions
This commit is contained in:
Pranav Senthilnathan
2019-01-31 15:56:05 -08:00
committed by GitHub
4 changed files with 62 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for mem-cache 1.0
// Project: https://github.com/silviom/node-mem-cache
// Definitions by: Pedro Mutter <https://github.com/MutterPedro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { EventEmitter } from 'events';
interface CacheOptions {
timeout?: number;
doesNotRenewTimeout?: boolean;
timeoutDisabled?: boolean;
}
declare class Cache extends EventEmitter {
keys: string[];
length: number;
constructor(options?: number | CacheOptions);
set(key: string, value: any, timeout?: number): void;
get(key: string): any;
remove(key: string): void;
clean(): void;
}
export = Cache;
+10
View File
@@ -0,0 +1,10 @@
import Cache = require('mem-cache');
const cache = new Cache(); // $ExpectType Cache
cache.set('foo', 'bar'); // $ExpectType void
cache.get('foo'); // $ExpectType any
cache.remove('foo'); // $ExpectType void
cache.clean(); // $ExpectType void
cache.length; // $ExpectType number
cache.keys; // $ExpectType string[]
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mem-cache-tests.ts"
],
"baseUrl": "types",
"typeRoots": ["types"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }