/** Function path used by `argsKey` deps. Distinguished from object paths * via `typeof === 'function'`. */ export type KeyFn = (args: readonly any[]) => string | undefined; /** Maps a (ordered) list of dependencies to a value. * * Useful as a memoization cache for flat/normalized stores. * * Object dependencies are weakly referenced (via `WeakMap`), allowing * automatic garbage collection when the dependency is no longer used. * String-keyed dependencies (used by `argsKey`) sit on a `Map` keyed by the * value returned from `path(args)`, branching on a stable function reference. */ export default class WeakDependencyMap { private readonly next; private nextPath; /** Sticky: true once any function-typed (`argsKey`) dep has been stored. * Lets `get` pick the entity-only fast path when no schema in this map * uses `argsKey` — avoids a polymorphic `typeof` branch per walk step. */ private hasStr; get(entity: K, getDependency: GetDependency, args?: readonly any[]): readonly [ undefined, undefined ] | readonly [ V, Path[] ]; /** Slow path: dep chain may interleave entity and `argsKey`-style deps. */ private _getMixed; set(dependencies: Dep[], value: V, args?: readonly any[], /** Optional consumer-facing journey returned to `get()` callers verbatim. * Defaults to `dependencies.map(d => d.path)`. Pass an explicit array to * skip the per-write `.map(...)` and (more importantly) to skip per-hit * post-processing — see `GlobalCache.getResults` for the read-side * payoff. The array becomes a shared reference held by every subsequent * cache hit; callers MUST NOT mutate it. */ journey?: Path[]): void; /** True once any `argsKey`-style dep has been written. Consumers can use * this to skip function-stripping work on the hit path when false. */ get hasStringDeps(): boolean; } export type GetDependency = (lookup: Path) => K | undefined; export interface Dep { path: Path | KeyFn; entity: K | undefined; } //# sourceMappingURL=WeakDependencyMap.d.ts.map