Skip to main content
Version: 1.2.0-beta1

Function: renameNode()

Call Signature

renameNode<T>(root, currentId, nextId): T

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

Renames every node with the source id while preserving tree structure. Returns the original tree when the source id is missing or the target id already exists elsewhere.

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 update
currentIdstringExisting id to rename
nextIdstringReplacement id

Returns

T

Updated tree with matching node ids renamed

Call Signature

renameNode<T>(root, currentId, nextId, helpers): T

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

Renames every node with the source id while preserving tree structure. Returns the original tree when the source id is missing or the target id already exists elsewhere.

Type Parameters

Type ParameterDescription
TTree node type

Parameters

ParameterTypeDescription
rootTRoot node to update
currentIdstringExisting id to rename
nextIdstringReplacement id
helpersStructuralTreeHelpers<T>Adapter for custom node shapes

Returns

T

Updated tree with matching node ids renamed