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

Function unionLeaves

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

Source from the content-addressed store, hash-verified

223// Resolve a union member to its leaf record names, following nested unions and
224// single-ref aliases. Every BiDi union bottoms out in records, so this is total.
225function unionLeaves(ref, types, seen = new Set()) {
226 if (seen.has(ref)) return []
227 seen.add(ref)
228 const t = types[ref]
229 if (!t) return []
230 if (t.kind === 'record') return [ref]
231 if (t.kind === 'union') return t.variants.flatMap((v) => unionLeaves(v, types, seen))
232 if (t.kind === 'alias' && t.type?.ref) return unionLeaves(t.type.ref, types, seen)
233 return []
234}
235
236// The constant value a record pins on wire key `k`, as `{ value }` (a string or
237// `null`), or `{ open: true }` when the field exists but is not constant (a base

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