This commit is contained in:
Sam Verschueren
2016-11-22 09:38:41 +01:00
parent ae49f93fed
commit b0b45350bc
4 changed files with 48 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for mem 1.1.0
// Project: https://github.com/sindresorhus/mem
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Options {
maxAge?: number;
cacheKey?: (...args: any[]) => string;
cache?: any;
}
declare const mem: {
<F extends (...args: any[]) => any>(fn: F, options?: Options): F;
clear<F extends (...args: any[]) => any>(fn: F): void;
};
declare namespace mem { }
export = mem;
+10
View File
@@ -0,0 +1,10 @@
import * as mem from 'mem';
let i = 0;
const memoized = mem((arg: string) => ++i);
const ret1: number = memoized('foo');
// Clear the memoized data
mem.clear(memoized);
const ret2: Promise<string> = mem(() => Promise.resolve('foo'))();
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mem-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }