Options
All
  • Public
  • Public/Protected
  • All
Menu

TreeResolver is a single-parent dependency resolution algorithm, made to resolve dependencies optimally whilst detecting unresolvable or circular dependencies.

Hierarchy

  • TreeResolver

Index

Properties

Methods

Properties

Protected nodes

nodes: TreeNode[] = []

Methods

addInstance

  • addInstance(instanceName: string, instanceParent?: string | null, instance?: any): void
  • Add an instance to the resolution tree.

    example
    import { TreeResolver } from 'treeresolver'
    const tree = new TreeResolver()
    
    // add nodes to use when building the dependency tree with individual TreeResolver.addInstance() calls
    tree.addInstance('node 1')
    tree.addInstance('node 2', 'node 1')
    
    // ...

    Parameters

    • instanceName: string

      The name of this instance.

    • Default value instanceParent: string | null = null

      The name of the parent of this instance.

    • Optional instance: any

      An object instance to tie directly to the node, if desired.

    Returns void

build

  • Build the dependency tree.

    example
    import { TreeResolver } from 'treeresolver'
    const tree = new TreeResolver()
    
    tree.addInstance('node 1')
    tree.addInstance('node 2', 'node 1')
    
    (async () => {
      // build the tree, and then
      const res = await tree.build()
      console.dir(res)
    })()

    Returns Promise<TreeResolverResult>

clear

  • clear(): void
  • Clears out all added instances, to allow the resolver to start fresh.

    example
    import { TreeResolver } from 'treeresolver'
    const tree = new TreeResolver()
    
    tree.addInstance('node 1')
    tree.addInstance('node 2', 'node 1')
    
    // ...
    
    // actually, we changed our mind, clear out all the nodes to process.
    tree.clear()

    Returns void

Legend

  • Property
  • Method
  • Protected property

Generated using TypeDoc