@botonic/plugin-contentful
Version:
Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet
24 lines (23 loc) • 1.13 kB
TypeScript
import { Cache } from './cache';
export type MemoizerNormalizer = (...args: any) => string;
export declare const jsonNormalizer: MemoizerNormalizer;
export type MemoizedFunction<Args extends any[], Return> = (...args: Args) => Promise<Return>;
export type MemoizerStrategy = <Args extends any[], Return>(cache: Cache<Return>, normalizer: typeof jsonNormalizer, func: (...args: Args) => Promise<Return>, ...args: Args) => Promise<Return>;
export interface MemoizerOptions {
strategy: MemoizerStrategy;
cacheFactory?: () => Cache<any>;
normalizer?: MemoizerNormalizer;
}
export declare class Memoizer {
opts: Required<MemoizerOptions>;
constructor(opts: MemoizerOptions);
memoize<Args extends any[], Return, F extends (...args: Args) => Promise<Return>>(func: F): F;
}
/***
* Only re-invoke if not in cache
*/
export declare const cacheForeverStrategy: MemoizerStrategy;
/**
* Always invokes the function, but fallbacks to last invocation result if available
*/
export declare function fallbackStrategy(usingFallback: (functName: string, args: any[], error: any) => Promise<void>): MemoizerStrategy;