Browse Source

Fix reduce warning for empty arrays

tags/1.3.0
ajv 6 years ago
committed by GitHub
parent
commit
91bdab2765
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      src/js/utils/intervals.js

+ 1
- 1
src/js/utils/intervals.js View File

@@ -212,7 +212,7 @@ export function isInRange2D(coord, minCoord, maxCoord) {
export function getClosestInArray(goal, arr, index = false) {
let closest = arr.reduce(function(prev, curr) {
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);
});
}, []);

return index ? arr.indexOf(closest) : closest;
}


Loading…
Cancel
Save