mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add types for promise-memoize * fixup! Add types for promise-memoize * Add clear to promise-memoize tests
15 lines
270 B
TypeScript
15 lines
270 B
TypeScript
import promiseMemoize = require('promise-memoize');
|
|
|
|
async function lastPosts(n: number) {
|
|
return n + 1;
|
|
}
|
|
|
|
const cachedLastPosts = promiseMemoize(lastPosts, {maxAge: 60000});
|
|
|
|
// Later...
|
|
cachedLastPosts(10).then(posts => {
|
|
posts;
|
|
});
|
|
|
|
cachedLastPosts.clear();
|