MCPcopy Create free account
hub / github.com/d3/d3-array / maxIndex

Function maxIndex

src/maxIndex.js:1–22  ·  view source on GitHub ↗
(values, valueof)

Source from the content-addressed store, hash-verified

1export default function maxIndex(values, valueof) {
2 let max;
3 let maxIndex = -1;
4 let index = -1;
5 if (valueof === undefined) {
6 for (const value of values) {
7 ++index;
8 if (value != null
9 && (max < value || (max === undefined && value >= value))) {
10 max = value, maxIndex = index;
11 }
12 }
13 } else {
14 for (let value of values) {
15 if ((value = valueof(value, ++index, values)) != null
16 && (max < value || (max === undefined && value >= value))) {
17 max = value, maxIndex = index;
18 }
19 }
20 }
21 return maxIndex;
22}

Callers 3

maxIndex-test.jsFile · 0.90
greatestIndexFunction · 0.85
quantileIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…