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

Function findExtrema

examples/annotations/main.ts:98–118  ·  view source on GitHub ↗
(data: ReadonlyArray<DataPoint>)

Source from the content-addressed store, hash-verified

96}>;
97
98const findExtrema = (data: ReadonlyArray<DataPoint>): Extrema => {
99 let maxIndex = 0;
100 let minIndex = 0;
101 let maxY = Number.NEGATIVE_INFINITY;
102 let minY = Number.POSITIVE_INFINITY;
103
104 for (let i = 0; i < data.length; i++) {
105 const p = data[i]!;
106 const y = isTuplePoint(p) ? p[1] : p.y;
107 if (y > maxY) {
108 maxY = y;
109 maxIndex = i;
110 }
111 if (y < minY) {
112 minY = y;
113 minIndex = i;
114 }
115 }
116
117 return { maxIndex, maxY, minIndex, minY };
118};
119
120const createTimeSeries = (count: number): ReadonlyArray<DataPoint> => {
121 const n = Math.max(2, Math.floor(count));

Callers 1

mainFunction · 0.85

Calls 1

isTuplePointFunction · 0.70

Tested by

no test coverage detected