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

Function unionLeaves

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

Source from the content-addressed store, hash-verified

389// Resolve a union member to its leaf record names, following nested unions and
390// single-ref aliases. Every BiDi union bottoms out in records, so this is total.
391function unionLeaves(ref, types, seen = new Set()) {
392 if (seen.has(ref)) return []
393 seen.add(ref)
394 const t = types[ref]
395 if (!t) return []
396 if (t.kind === 'record') return [ref]
397 if (t.kind === 'union') return t.variants.flatMap((v) => unionLeaves(v, types, seen))
398 if (t.kind === 'alias' && t.type?.ref) return unionLeaves(t.type.ref, types, seen)
399 return []
400}
401
402// Whether a union variant is an object (record) type — following aliases and nested
403// 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