Skip to main content
Version: 1.2.1-beta1.0

Interface: StructuralTreeHelpers<T>

Defined in: src/Mnemonic/structural-migrations.ts:14

Adapter functions for structural migration helpers.

These helpers assume tree-like data, but not a specific node shape. Supply a StructuralTreeHelpers<T> when your nodes use custom field names. When your nodes already look like { id, children }, the exported helpers work without any adapter configuration.

Type Parameters

Type ParameterDescription
TTree node type

Properties

getChildren()

getChildren: (node) => readonly T[] | undefined

Defined in: src/Mnemonic/structural-migrations.ts:23

Returns the node's child list, or undefined when it has no children.

Parameters

ParameterType
nodeT

Returns

readonly T[] | undefined


getId()

getId: (node) => string

Defined in: src/Mnemonic/structural-migrations.ts:18

Returns the stable identifier for a node.

Parameters

ParameterType
nodeT

Returns

string


withChildren()

withChildren: (node, children) => T

Defined in: src/Mnemonic/structural-migrations.ts:28

Returns a copy of the node with a new child list.

Parameters

ParameterType
nodeT
childrenT[]

Returns

T


withId()

withId: (node, id) => T

Defined in: src/Mnemonic/structural-migrations.ts:33

Returns a copy of the node with a new identifier.

Parameters

ParameterType
nodeT
idstring

Returns

T