Skip to main content
Version: v1

NodeIdConverter Interface

An object which can convert node IDs between compressed and stable variants

Signature

export interface NodeIdConverter

Methods

Method Return Type Description
convertToNodeId(id) NodeId Given a stable ID, return the corresponding NodeId or throws if the supplied stable ID was never generated with this tree, either as a UUID corresponding to a NodeId or as an override passed to generateNodeId. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by an instance of this SharedTree.
convertToStableNodeId(id) StableNodeId Given a NodeId, returns the corresponding stable ID or throws if the supplied node ID was not generated with this tree (NodeIds may not be used across SharedTree instances, see generateNodeId for more). The returned value will be a UUID, unless the creation of id used an override string (see generateNodeId for more). The result is safe to persist and re-use across SharedTree instances, unlike NodeId.
tryConvertToNodeId(id) NodeId | undefined Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree, either as a UUID corresponding to a NodeId or as an override passed to generateNodeId. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by an instance of this SharedTree.
tryConvertToStableNodeId(id) StableNodeId | undefined Given a NodeId, attempt to return the corresponding stable ID. The returned value will be a UUID, unless the creation of id used an override string (see generateNodeId for more). The returned stable ID is undefined if id was never created with this SharedTree. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by some instance of this tree.

Method Details

convertToNodeId

Given a stable ID, return the corresponding NodeId or throws if the supplied stable ID was never generated with this tree, either as a UUID corresponding to a NodeId or as an override passed to generateNodeId. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by an instance of this SharedTree.

Signature

convertToNodeId(id: StableNodeId): NodeId;

Parameters

Parameter Type Description
id StableNodeId

Returns

Return type: NodeId

convertToStableNodeId

Given a NodeId, returns the corresponding stable ID or throws if the supplied node ID was not generated with this tree (NodeIds may not be used across SharedTree instances, see generateNodeId for more). The returned value will be a UUID, unless the creation of id used an override string (see generateNodeId for more). The result is safe to persist and re-use across SharedTree instances, unlike NodeId.

Signature

convertToStableNodeId(id: NodeId): StableNodeId;

Parameters

Parameter Type Description
id NodeId

Returns

Return type: StableNodeId

tryConvertToNodeId

Given a stable ID, return the corresponding NodeId or return undefined if the supplied stable ID was never generated with this tree, either as a UUID corresponding to a NodeId or as an override passed to generateNodeId. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by an instance of this SharedTree.

Signature

tryConvertToNodeId(id: StableNodeId): NodeId | undefined;

Parameters

Parameter Type Description
id StableNodeId

Returns

Return type: NodeId | undefined

tryConvertToStableNodeId

Given a NodeId, attempt to return the corresponding stable ID. The returned value will be a UUID, unless the creation of id used an override string (see generateNodeId for more). The returned stable ID is undefined if id was never created with this SharedTree. If a stable ID is returned, this does not imply that there is a node with id in the current revision of the tree, only that id was at some point generated by some instance of this tree.

Signature

tryConvertToStableNodeId(id: NodeId): StableNodeId | undefined;

Parameters

Parameter Type Description
id NodeId

Returns

Return type: StableNodeId | undefined