Skip to main content

Function: toTreeNode()

Call Signature​

function toTreeNode<TType, V>(type, value): V;

Turns an object (array, plain object) into a tree node, which then can accept calls to getParent, getSnapshot, etc. If a tree node is passed it will return the passed argument directly. Additionally this method will use the type passed to check the value conforms to the type when model auto type checking is enabled.

Type Parameters​

Type Parameter
TType extends AnyStandardType
V extends any

Parameters​

ParameterTypeDescription
typeTTypeType checker.
valueVObject to turn into a tree node.

Returns​

V

The object as a tree node.

Call Signature​

function toTreeNode<T>(value): T;

Turns an object (array, plain object) into a tree node, which then can accept calls to getParent, getSnapshot, etc. If a tree node is passed it will return the passed argument directly.

Type Parameters​

Type Parameter
T extends object

Parameters​

ParameterTypeDescription
valueTObject to turn into a tree node.

Returns​

T

The object as a tree node.