UNPKG

with-simple-caching

Version:

A wrapper that makes it simple to add caching to any function

21 lines (20 loc) 837 B
import { SimpleCache } from '../../domain/SimpleCache'; /** * a method which specifies where how to extract a simple-cache from input args */ export type SimpleCacheExtractionMethod<LI extends any[], C extends SimpleCache<any>> = (args: { fromInput: LI; }) => C; /** * how the cache can be specified for use with simple caching * - either directly * - or through a cache extraction method, which grabs the cache from input args */ export type WithSimpleCachingCacheOption<LI extends any[], C extends SimpleCache<any>> = C | SimpleCacheExtractionMethod<LI, C>; /** * how to extract the with simple caching cache option */ export declare const getCacheFromCacheOption: <LI extends any[], C extends SimpleCache<any>>({ forInput, cacheOption, }: { forInput: LI; cacheOption: WithSimpleCachingCacheOption<LI, C>; }) => C;