Download node_modules/d3-array/src/leastIndex.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 467 Bytes
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-array/src/leastIndex.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-array/src/leastIndex.js
-
curl -L -o leastIndex.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-array/src/leastIndex.js
467 Bytes
| import ascending from "./ascending.js"; | |
| import minIndex from "./minIndex.js"; | |
| export default function leastIndex(values, compare = ascending) { | |
| if (compare.length === 1) return minIndex(values, compare); | |
| let minValue; | |
| let min = -1; | |
| let index = -1; | |
| for (const value of values) { | |
| ++index; | |
| if (min < 0 | |
| ? compare(value, value) === 0 | |
| : compare(value, minValue) < 0) { | |
| minValue = value; | |
| min = index; | |
| } | |
| } | |
| return min; | |
| } | |