UNPKG

1.49 kBTypeScriptView Raw
1import { Trie } from "@wry/trie";
2export { bindContext, noContext, nonReactive, setTimeout, asyncFromGen, } from "./context.js";
3export { dep, OptimisticDependencyFunction } from "./dep.js";
4export declare function defaultMakeCacheKey(...args: any[]): object;
5export { Trie as KeyTrie };
6export type OptimisticWrapperFunction<TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any> = ((...args: TArgs) => TResult) & {
7 readonly size: number;
8 options: OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey>;
9 dirty: (...args: TKeyArgs) => void;
10 dirtyKey: (key: TCacheKey) => void;
11 peek: (...args: TKeyArgs) => TResult | undefined;
12 peekKey: (key: TCacheKey) => TResult | undefined;
13 forget: (...args: TKeyArgs) => boolean;
14 forgetKey: (key: TCacheKey) => boolean;
15 getKey: (...args: TArgs) => TCacheKey;
16 makeCacheKey: (...args: TKeyArgs) => TCacheKey;
17};
18export type OptimisticWrapOptions<TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any> = {
19 max?: number;
20 keyArgs?: (...args: TArgs) => TKeyArgs;
21 makeCacheKey?: (...args: TKeyArgs) => TCacheKey;
22 subscribe?: (...args: TArgs) => void | (() => any);
23};
24export declare function wrap<TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any>(originalFunction: (...args: TArgs) => TResult, { max, makeCacheKey, keyArgs, subscribe, }?: OptimisticWrapOptions<TArgs, TKeyArgs>): OptimisticWrapperFunction<TArgs, TResult, TKeyArgs, TCacheKey>;
25
\No newline at end of file