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

Function minIndex

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

Source from the content-addressed store, hash-verified

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

Callers 3

minIndex-test.jsFile · 0.90
leastIndexFunction · 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…