UNPKG

@electric-sql/d2ts

Version:

D2TS is a TypeScript implementation of Differential Dataflow.

47 lines (46 loc) 1.63 kB
/** * A map that uses WeakRefs to store objects, and automatically removes them when * they are no longer referenced. */ export declare class WeakRefMap<K, V extends object> { private cacheMap; private finalizer; set(key: K, value: V): void; get(key: K): V | null; } /** * A map that returns a default value for keys that are not present. */ export declare class DefaultMap<K, V> extends Map<K, V> { private defaultValue; constructor(defaultValue: () => V, entries?: Iterable<[K, V]>); get(key: K): V; /** * Update the value for a key using a function. */ update(key: K, updater: (value: V) => V): V; } export declare function chunkedArrayPush(array: unknown[], other: unknown[]): void; /** * A hash method that caches the hash of a value in a week map */ export declare function hash(data: any): string | number; /** * This is a mock implementation of FinalizationRegistry which uses WeakRef to * track the target objects. It's used in environments where FinalizationRegistry * is not available but WeakRef is (e.g. React Native >=0.75 on New Architecture). * Based on https://gist.github.com/cray0000/abecb1ca71fd28a1d8efff2be9e0f6c5 * MIT License - Copyright Cray0000 */ export declare class WeakRefBasedFinalizationRegistry { private counter; private registrations; private sweepTimeout; private finalize; private sweepIntervalMs; constructor(finalize: (value: any) => void, sweepIntervalMs?: number); register(target: any, value: any, token: any): void; unregister(token: any): void; private sweep; private scheduleSweep; }