1 | import { Trie } from "@wry/trie";
|
2 | import { CommonCache } from "@wry/caches";
|
3 | import { Entry } from "./entry.js";
|
4 | import type { NoInfer } from "./helpers.js";
|
5 | export { bindContext, noContext, nonReactive, setTimeout, asyncFromGen, Slot, } from "./context.js";
|
6 | export { dep, OptimisticDependencyFunction } from "./dep.js";
|
7 | export declare function defaultMakeCacheKey(...args: any[]): object;
|
8 | export { Trie as KeyTrie };
|
9 | export type OptimisticWrapperFunction<TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any> = ((...args: TArgs) => TResult) & {
|
10 | readonly size: number;
|
11 | options: OptionsWithCacheInstance<TArgs, TKeyArgs, TCacheKey>;
|
12 | dirty: (...args: TKeyArgs) => void;
|
13 | dirtyKey: (key: TCacheKey | undefined) => void;
|
14 | peek: (...args: TKeyArgs) => TResult | undefined;
|
15 | peekKey: (key: TCacheKey | undefined) => TResult | undefined;
|
16 | forget: (...args: TKeyArgs) => boolean;
|
17 | forgetKey: (key: TCacheKey | undefined) => boolean;
|
18 | getKey: (...args: TArgs) => TCacheKey | undefined;
|
19 | makeCacheKey: (...args: TKeyArgs) => TCacheKey | undefined;
|
20 | };
|
21 | export { CommonCache };
|
22 | export interface CommonCacheConstructor<TCacheKey, TResult, TArgs extends any[]> extends Function {
|
23 | new <K extends TCacheKey, V extends Entry<TArgs, TResult>>(max?: number, dispose?: (value: V, key?: K) => void): CommonCache<K, V>;
|
24 | }
|
25 | export type OptimisticWrapOptions<TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any, TResult = any> = {
|
26 | max?: number;
|
27 | keyArgs?: (...args: TArgs) => TKeyArgs;
|
28 | makeCacheKey?: (...args: NoInfer<TKeyArgs>) => TCacheKey | undefined;
|
29 | normalizeResult?: (newer: TResult, older: TResult) => TResult;
|
30 | subscribe?: (...args: TArgs) => void | (() => any);
|
31 | cache?: CommonCache<NoInfer<TCacheKey>, Entry<NoInfer<TArgs>, NoInfer<TResult>>> | CommonCacheConstructor<NoInfer<TCacheKey>, NoInfer<TResult>, NoInfer<TArgs>>;
|
32 | };
|
33 | export interface OptionsWithCacheInstance<TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any, TResult = any> extends OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey, TResult> {
|
34 | cache: CommonCache<NoInfer<TCacheKey>, Entry<NoInfer<TArgs>, NoInfer<TResult>>>;
|
35 | }
|
36 | export declare function wrap<TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs, TCacheKey = any>(originalFunction: (...args: TArgs) => TResult, { max, keyArgs, makeCacheKey, normalizeResult, subscribe, cache: cacheOption, }?: OptimisticWrapOptions<TArgs, TKeyArgs, TCacheKey, TResult>): OptimisticWrapperFunction<TArgs, TResult, TKeyArgs, TCacheKey>;
|
37 |
|
\ | No newline at end of file |