MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / unionLeaves

Function unionLeaves

javascript/selenium-webdriver/project_bidi_schema.mjs:323–332  ·  view source on GitHub ↗
(ref, types, seen = new Set())

Source from the content-addressed store, hash-verified

321// Resolve a union member to its leaf record names, following nested unions and
322// single-ref aliases. Every BiDi union bottoms out in records, so this is total.
323function unionLeaves(ref, types, seen = new Set()) {
324 if (seen.has(ref)) return []
325 seen.add(ref)
326 const t = types[ref]
327 if (!t) return []
328 if (t.kind === 'record') return [ref]
329 if (t.kind === 'union') return t.variants.flatMap((v) => unionLeaves(v, types, seen))
330 if (t.kind === 'alias' && t.type?.ref) return unionLeaves(t.type.ref, types, seen)
331 return []
332}
333
334// Whether a union variant is an object (record) type — following aliases and nested
335// unions to their leaves. An enum, or an alias to a primitive/list/map (or an inline

Callers 3

tagContributionFunction · 0.85
unionSelectorFunction · 0.85
requiresOfFunction · 0.85

Calls 2

addMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected