// Currently only used as a WeakMap key export default class UserContext {} export function ctxWeakMapMemoize(factory: () => T) { const cache: WeakMap = new WeakMap(); return function get(ctx: UserContext): T { if (!cache.has(ctx)) { cache.set(ctx, factory()); } // @ts-ignore We just put the value in there return cache.get(ctx); }; }