forked from sindresorhus/memoize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test-d.ts
20 lines (17 loc) · 682 Bytes
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import {expectType} from 'tsd';
import mem = require('.');
const fn = (string: string) => true;
expectType<(string: string) => boolean>(mem(fn));
expectType<(string: string) => boolean>(mem(fn, {maxAge: 1}));
expectType<(string: string) => boolean>(mem(fn, {cacheKey: (...arguments_) => arguments_}));
expectType<(string: string) => boolean>(
mem(
fn,
{cacheKey: (...arguments_) => arguments_,
cache: new Map<[string], {data: boolean; maxAge: number}>()})
);
expectType<(string: string) => boolean>(
mem(fn, {cache: new Map<[string], {data: boolean; maxAge: number}>()})
);
expectType<(string: string) => boolean>(mem(fn, {cachePromiseRejection: false}));
mem.clear(fn);