Skip to main content
Version: 1.3.0

Function: findNodeById()

Call Signature​

findNodeById<T>(root, id): T | undefined

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

Finds the first node with the requested id using depth-first traversal.

Type Parameters​

Type ParameterDescription
T extends StructuralNode<T>Tree node type (must extend { id: string; children?: readonly T[] } when helpers is omitted)

Parameters​

ParameterTypeDescription
rootTRoot node to search
idstringTarget node id

Returns​

T | undefined

The matching node, or undefined

Call Signature​

findNodeById<T>(root, id, helpers): T | undefined

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

Finds the first node with the requested id using depth-first traversal.

Type Parameters​

Type ParameterDescription
TTree node type

Parameters​

ParameterTypeDescription
rootTRoot node to search
idstringTarget node id
helpersStructuralTreeHelpers<T>Adapter for custom node shapes

Returns​

T | undefined

The matching node, or undefined