UNPKG

@data-client/normalizr

Version:

Normalizes and denormalizes JSON according to schema for Redux and Flux applications

19 lines 790 B
/** Maps a (ordered) list of dependencies to a value. * * Useful as a memoization cache for flat/normalized stores. * * All dependencies are only weakly referenced, allowing automatic garbage collection * when any dependencies are no longer used. */ export default class WeakDependencyMap<Path, K extends object = object, V = any> { private readonly next; private nextPath; get(entity: K, getDependency: GetDependency<Path, K | symbol>): readonly [undefined, undefined] | readonly [V, Path[]]; set(dependencies: Dep<Path, K>[], value: V): void; } export type GetDependency<Path, K = object | symbol> = (lookup: Path) => K | undefined; export interface Dep<Path, K = object> { path: Path; entity: K | undefined; } //# sourceMappingURL=WeakDependencyMap.d.ts.map