Class Runner<Node, Result>

Asynchronous graph runner

Type Parameters

  • Node
  • Result

Hierarchy (view full)

Constructors

Properties

abortController: AbortController

AbortController used internally to abort the process.

This is internal only, and triggering it at the wrong time may cause undefined and unsupported behavior. Do not use!

Instead, if you want to be able to abort the walk at any time, provide your own AbortSignal in the opions.

dependents: Map<Node, Set<Node>> = ...

Set of dependents (direct & transitive) on each node

directDependents: Map<Node, Set<Node>> = ...

Set of direct dependents on each node

errors: unknown[] = []

Rejections and Errors encountered in the traversal

failFast: boolean

True if we are in failFast mode

from: Callable

Function defining the callsite where the traversal was initiated, used for Error.captureStackTrace.

Options provided to constructor

results: Map<Node, Result> = ...

The map of traversal results

running: Map<Node, Promise<void>> = ...

Map of nodes currently awaiting completion

settled: SettledMap<Node, Result> = ...

The map of PromiseSettledResult objects

Methods

  • Internal

    If the dependency from n -> d at the specified path would cause a cycle, then call the onCycle method and return true. Oherwise, assign the appropriate entries in the dependency tracking sets, and return false.

    Parameters

    Returns boolean

  • Calls the options.onCycle() method when a cycle is detected.

    Parameters

    Returns Promise<void>

  • For a Node n that depends directly or transitively on Node d, find the shortest known dependency path from n to d. This is done by walking backwards breadth-first up the dependency relations from d until n is found.

    If no known path can be found, then undefined is returned. Otherwise, a path array is returned that starts with n and ends with d.

    Note that self-referential links are never considered, since they're by definition cyclical.

    Parameters

    Returns undefined | [n: Node, ...path: Node[]]

  • Initiate the graph traversal, resolving/returning when complete

    Returns Promise<void>