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

Function build

javascript/selenium-webdriver/bidi/serialization/union.js:64–77  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

62 // project_bidi_schema.mjs) — so recurse through that union's own dispatch
63 // rather than assuming every resolved ref is a record.
64 build(data) {
65 if (objectOnly && (typeof data !== 'object' || data === null || Array.isArray(data))) {
66 throw new ValidationError(`${name}: expected an object`)
67 }
68 const ref = selectVariant(selector, data, (d, key) => Object.hasOwn(d, key))
69 if (ref === undefined) {
70 throw new ValidationError(`${name}: value does not match any known variant`)
71 }
72 const variant = resolve(ref)
73 if (variant.kind === 'union') {
74 return variant.build(data)
75 }
76 return new variant.RecordClass(data)
77 },
78
79 // Inbound: resolve which variant `payload` matches. An unresolvable payload is a
80 // closed-vocabulary miss — always an error, never a warning, since there is no

Callers 1

Calls 3

selectVariantFunction · 0.85
resolveFunction · 0.70
buildMethod · 0.65

Tested by

no test coverage detected