mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
add mem
This commit is contained in:
Vendored
+18
@@ -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;
|
||||
@@ -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'))();
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user