code: function findFirst(pred,from,to){// At any point we are certain `to` satisfies `pred`, don't know
  // whether `from` does.
  var dir=from>to?-1:1;for(;;){if(from==to){return from;}var midF=(from+to)/2,mid=dir<0?Math.ceil(midF):Math.floor(midF);if(mid==from){return pred(mid)?from:to;}if(pred(mid)){to=mid;}else{from=mid+dir;}}}
docs: Returns the value from the range [`from`; `to`] that satisfies `pred` and is closest to `from`. Assumes that at least `to` satisfies `pred`. Supports `from` being greater than `to`.