(values, valueof = ascending$3)
| 1099 | } |
| 1100 | |
| 1101 | function rank(values, valueof = ascending$3) { |
| 1102 | if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); |
| 1103 | let V = Array.from(values); |
| 1104 | const R = new Float64Array(V.length); |
| 1105 | if (valueof.length !== 2) V = V.map(valueof), valueof = ascending$3; |
| 1106 | const compareIndex = (i, j) => valueof(V[i], V[j]); |
| 1107 | let k, r; |
| 1108 | values = Uint32Array.from(V, (_, i) => i); |
| 1109 | // Risky chaining due to Safari 14 https://github.com/d3/d3-array/issues/123 |
| 1110 | values.sort(valueof === ascending$3 ? (i, j) => ascendingDefined(V[i], V[j]) : compareDefined(compareIndex)); |
| 1111 | values.forEach((j, i) => { |
| 1112 | const c = compareIndex(j, k === undefined ? j : k); |
| 1113 | if (c >= 0) { |
| 1114 | if (k === undefined || c > 0) k = j, r = i; |
| 1115 | R[j] = r; |
| 1116 | } else { |
| 1117 | R[j] = NaN; |
| 1118 | } |
| 1119 | }); |
| 1120 | return R; |
| 1121 | } |
| 1122 | |
| 1123 | function least(values, compare = ascending$3) { |
| 1124 | let min; |
nothing calls this directly
no test coverage detected