(pred, from, to)
| 282 | // `pred` and is closest to `from`. Assumes that at least `to` |
| 283 | // satisfies `pred`. Supports `from` being greater than `to`. |
| 284 | function findFirst(pred, from, to) { |
| 285 | // At any point we are certain `to` satisfies `pred`, don't know |
| 286 | // whether `from` does. |
| 287 | var dir = from > to ? -1 : 1; |
| 288 | for (;;) { |
| 289 | if (from == to) { return from } |
| 290 | var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF); |
| 291 | if (mid == from) { return pred(mid) ? from : to } |
| 292 | if (pred(mid)) { to = mid; } |
| 293 | else { from = mid + dir; } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | // The display handles the DOM integration, both for input reading |
| 298 | // and content drawing. It holds references to DOM nodes and |
no outgoing calls
no test coverage detected