Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const observedMeanDistance = features.map((feature, index) => {
const otherFeatures = featureCollection(features.filter((f, i) => {
return i !== index;
}));
// Have to add the ! to make typescript validation pass
// see https://stackoverflow.com/a/40350534/1979085
return distance(feature, nearestPoint(feature, otherFeatures).geometry!.coordinates, {units});
}).reduce((sum, value) => { return sum + value; }, 0) / n;
var observedMeanDistance = features.map(function (feature, index) {
var otherFeatures = featureCollection(features.filter(function (f, i) {
return i !== index;
}));
return distance(feature, nearestPoint(feature, otherFeatures), {units: units});
}).reduce(function (sum, value) { return sum + value; }, 0) / n;