MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / lowerBoundByTimestamp

Function lowerBoundByTimestamp

src/interaction/findCandlestick.ts:139–149  ·  view source on GitHub ↗
(data: ReadonlyArray<OHLCDataPoint>, xTarget: number)

Source from the content-addressed store, hash-verified

137};
138
139const lowerBoundByTimestamp = (data: ReadonlyArray<OHLCDataPoint>, xTarget: number): number => {
140 let lo = 0;
141 let hi = data.length;
142 while (lo < hi) {
143 const mid = (lo + hi) >>> 1;
144 const t = getTimestamp(data[mid]);
145 if (t < xTarget) lo = mid + 1;
146 else hi = mid;
147 }
148 return lo;
149};
150
151/**
152 * Finds the candlestick body under the given cursor position.

Callers 1

findCandlestickFunction · 0.85

Calls 1

getTimestampFunction · 0.70

Tested by

no test coverage detected