Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ResolvedIDMap<T, R>

ResolvedIDMap<T, R> is a mapping from ID to T, but with support for lazy, cached 'resolving' from that value of T to an R.

For more detail, see the README.

Type parameters

  • T

  • R

Hierarchy

  • ResolvedIDMap

Index

Constructors

constructor

Properties

Private inner

inner: IDMap<Stored<T, R>> = new IDMap()

Private resolver

resolver: Resolver<T, R>

Private Optional resolving

resolving: ID

Static isResolved

isResolved: isResolved = isResolved

Methods

__@iterator

  • __@iterator(): IterableIterator<[ID, T]>

Private collectDeps

delete

  • delete(id: ID): boolean
  • Remove the mapping from id to a value.

    Parameters

    Returns boolean

    whether the map contained a value for id

Private forEachDep

  • forEachDep(id: ID, func: function): void

get

  • Get the value for id.

    throws

    if this is called from within the resolver and a loop is met.

    Parameters

    Returns Resolved<T, R> | undefined

getCycle

  • Get the value for id, handling loops. This should only be called within the resolver. If it is currently being resolved, this returns Resolving, otherwise acts as get does.

    This can be tested for using ResolvedIDMap::isResolved

    Parameters

    Returns MaybeResolving<T, R> | undefined

getRaw

  • getRaw(id: ID): T | undefined
  • Get the raw, unresolved T value for id

    Parameters

    Returns T | undefined

has

  • has(id: ID): boolean

Private reset

  • reset(id: ID): void

Private resolve

  • resolve(id: ID): ResolvingOrRequested<T, R> | undefined

resolveDeps

  • resolveDeps(id: ID): void
  • Call the resolver for all of the dependents of id.

    This is useful for the error-reporting use case mentioned in the README.

    Parameters

    Returns void

set

  • set(id: ID, raw: T): void
  • Create a new mapping from id=>raw

    Parameters

    • id: ID
    • raw: T

    Returns void

Static Private cleanUp

  • cleanUp(value: any): any

Generated using TypeDoc