Skip to main content
Version: Next

Function: dedupeChildrenBy()

Call Signature

dedupeChildrenBy<T, K>(root, getKey): T

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

Deduplicates each node's immediate children while preserving the first child encountered for each key. The helper traverses the full tree and returns the original root when no duplicates are removed.

Type Parameters

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

Parameters

ParameterTypeDescription
rootTRoot node to normalize
getKey(node) => KFunction that computes a dedupe key for each child

Returns

T

Updated tree with duplicate siblings removed

Call Signature

dedupeChildrenBy<T, K>(root, getKey, helpers): T

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

Deduplicates each node's immediate children while preserving the first child encountered for each key. The helper traverses the full tree and returns the original root when no duplicates are removed.

Type Parameters

Type ParameterDescription
TTree node type
KDeduplication key type

Parameters

ParameterTypeDescription
rootTRoot node to normalize
getKey(node) => KFunction that computes a dedupe key for each child
helpersStructuralTreeHelpers<T>Adapter for custom node shapes

Returns

T

Updated tree with duplicate siblings removed