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

Function narrow

javascript/selenium-webdriver/project_bidi_schema.mjs:204–213  ·  view source on GitHub ↗
(node, { side, exclusive }, value)

Source from the content-addressed store, hash-verified

202
203// The tighter bound wins: `(0..10) .ge 5` raises the minimum, `(0..10) .ge -1` leaves it.
204function narrow(node, { side, exclusive }, value) {
205 const flag = side === 'min' ? 'exclusiveMin' : 'exclusiveMax'
206 const current = node[side]
207 if (current !== undefined && (side === 'min' ? current > value : current < value)) return node
208 if (current === value && node[flag]) return node
209 const narrowed = { ...node, [side]: value }
210 if (exclusive) narrowed[flag] = true
211 else delete narrowed[flag]
212 return narrowed
213}
214
215// The parser hangs a control operator on a type entry, a field, or a definition. A numeric one
216// bounds the projected node; any other (`.default` …) does not change the type.

Callers 1

withOperatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected