MCPcopy Create free account
hub / github.com/callstack/agent-device / resolveRefLabel

Function resolveRefLabel

src/snapshot/snapshot-processing.ts:19–29  ·  view source on GitHub ↗
(
  node: SnapshotState['nodes'][number],
  nodes: SnapshotState['nodes'],
)

Source from the content-addressed store, hash-verified

17}
18
19export function resolveRefLabel(
20 node: SnapshotState['nodes'][number],
21 nodes: SnapshotState['nodes'],
22): string | undefined {
23 const primary = [node.label, node.value, node.identifier]
24 .map((value) => (typeof value === 'string' ? value.trim() : ''))
25 .find((value) => value && value.length > 0);
26 if (primary && isMeaningfulLabel(primary)) return primary;
27 const fallback = findNearestMeaningfulLabel(node, nodes);
28 return fallback ?? (primary && isMeaningfulLabel(primary) ? primary : undefined);
29}
30
31function isMeaningfulLabel(value: string): boolean {
32 const trimmed = value.trim();

Callers 4

waitCommandFunction · 0.90
resolveSnapshotScopeFunction · 0.90

Calls 2

isMeaningfulLabelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…