MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / findFirst

Function findFirst

static/libs/codemirror.js:284–295  ·  view source on GitHub ↗
(pred, from, to)

Source from the content-addressed store, hash-verified

282// `pred` and is closest to `from`. Assumes that at least `to`
283// satisfies `pred`. Supports `from` being greater than `to`.
284function 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

Callers 4

wrappedLineExtentFunction · 0.85
coordsCharInnerFunction · 0.85
coordsBidiPartFunction · 0.85
endOfLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected