| 202 | |
| 203 | // The tighter bound wins: `(0..10) .ge 5` raises the minimum, `(0..10) .ge -1` leaves it. |
| 204 | function 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. |