Skip to content

Latest commit

 

History

History
372 lines (214 loc) · 8.08 KB

TreeController.Tree-1.md

File metadata and controls

372 lines (214 loc) · 8.08 KB

tree-controller / Exports / TreeController / Tree

Class: Tree<N>

TreeController.Tree

Tree holds a tree by its root and provides a flat array of nodes built when its contructor is called. To do so, it assumes that the provided nodes have a children property that is an array of its children.

If you're dealing with nodes shaped differently, the second paramenter can be provided to override default methods.

Type parameters

Name Type
N any

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Tree<N>(root, options?)

Type parameters

Name Type
N any

Parameters

Name Type
root N
options? Partial<MethodsFactories<N> & ConstructorFunctions<N>>

Defined in

tree/tree-manager.tree.ts:63

Properties

children

Readonly children: (node: N) => N[]

Type declaration

▸ (node): N[]

Method

children receives a node and returns its children

Parameters
Name Type
node N
Returns

N[]

Implementation of

Methods.children

Defined in

tree/tree-manager.tree.ts:61


node

Readonly node: (node: N) => N

Type declaration

▸ (node): N

Method

node simply receives a node and return that node

Parameters
Name Type
node N
Returns

N

Implementation of

Methods.node

Defined in

tree/tree-manager.tree.ts:59


nodes

Readonly nodes: N[]

Field

nodes is a flat array containing every tree's nodes: the root, each one of its childrens, and their children's and so on.

Implementation of

Interface.nodes

Defined in

tree/tree-manager.tree.ts:57


parent

Readonly parent: (node: N) => undefined | null | N

Type declaration

▸ (node): undefined | null | N

Method

parent receives a node and returns its parent

Parameters
Name Type
node N
Returns

undefined | null | N

Implementation of

Methods.parent

Defined in

tree/tree-manager.tree.ts:60


root

Readonly root: N

Field

root is the provided tree root

Implementation of

Interface.root

Defined in

tree/tree-manager.tree.ts:56


_defaultGeParentFactory

Static Private Readonly _defaultGeParentFactory: (instance: Tree<any>, ...args: any[]) => (node: any) => any

Type declaration

▸ (instance, ...args): (node: any) => any

Method

parent is a factory function that will be called in the Store constructor passing the Store instance as the first parameter. It will override that instance's default method for retrieving a node's parent

Parameters
Name Type Description
instance Tree<any> of Storage
...args any[] extra arguments you can provide as necessary
Returns

fn

▸ (node): any

Method

parent receives a node and returns its parent

Parameters
Name Type
node any
Returns

any

Defined in

tree/tree-manager.tree.ts:47


_defaultGetChildrenFactory

Static Private Readonly _defaultGetChildrenFactory: (instance: Tree<any>, ...args: any[]) => (node: any) => any[]

Type declaration

▸ (instance, ...args): (node: any) => any[]

Method

children is a factory function that will be called in the Store constructor passing the Store instance as the first parameter. It will override that instance's default method for retrieving a node's children

Parameters
Name Type Description
instance Tree<any> of Storage
...args any[] extra arguments you can provide as necessary
Returns

fn

▸ (node): any[]

Method

children receives a node and returns its children

Parameters
Name Type
node any
Returns

any[]

Defined in

tree/tree-manager.tree.ts:19


_defaultGetNodeFactory

Static Private Readonly _defaultGetNodeFactory: (instance: Tree<any>, ...args: any[]) => (node: any) => any

Type declaration

▸ (instance, ...args): (node: any) => any

Method

node is a factory function that will be called in the Store constructor passing the Store instance as the first parameter. It will override that instance's default method for retrieving a node

Parameters
Name Type Description
instance Tree<any> of Storage
...args any[] extra arguments you can provide as necessary
Returns

fn

▸ (node): any

Method

node simply receives a node and return that node

Parameters
Name Type
node any
Returns

any

Defined in

tree/tree-manager.tree.ts:15

Methods

_defaultFillNodesArray

Static Private Readonly _defaultFillNodesArray<N>(instance): N[]

Type parameters

Name Type
N any

Parameters

Name Type
instance Tree<N>

Returns

N[]

Defined in

tree/tree-manager.tree.ts:24