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 Parameter | Description |
|---|---|
T extends StructuralNode<T> | Tree node type (must extend { id: string; children?: readonly T[] } when helpers is omitted) |
K | Deduplication key type |
Parameters
| Parameter | Type | Description |
|---|---|---|
root | T | Root node to normalize |
getKey | (node) => K | Function 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 Parameter | Description |
|---|---|
T | Tree node type |
K | Deduplication key type |
Parameters
| Parameter | Type | Description |
|---|---|---|
root | T | Root node to normalize |
getKey | (node) => K | Function that computes a dedupe key for each child |
helpers | StructuralTreeHelpers<T> | Adapter for custom node shapes |
Returns
T
Updated tree with duplicate siblings removed