(pred, from, to)
| 833 | // `pred` and is closest to `from`. Assumes that at least `to` |
| 834 | // satisfies `pred`. Supports `from` being greater than `to`. |
| 835 | function findFirst(pred, from, to) { |
| 836 | // At any point we are certain `to` satisfies `pred`, don't know |
| 837 | // whether `from` does. |
| 838 | var dir = from > to ? -1 : 1 |
| 839 | for (;;) { |
| 840 | if (from == to) { |
| 841 | return from |
| 842 | } |
| 843 | var midF = (from + to) / 2, |
| 844 | mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF) |
| 845 | if (mid == from) { |
| 846 | return pred(mid) ? from : to |
| 847 | } |
| 848 | if (pred(mid)) { |
| 849 | to = mid |
| 850 | } else { |
| 851 | from = mid + dir |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | // The display handles the DOM integration, both for input reading |
| 857 | // and content drawing. It holds references to DOM nodes and |
no outgoing calls
no test coverage detected