Remove rest of the lodash iterators: map, reduce, forEach

(re: #6087)
This commit is contained in:
Bryan Housel
2019-03-29 15:14:21 -04:00
parent 0d79e3e616
commit d5abe468b9
14 changed files with 107 additions and 175 deletions
+8 -14
View File
@@ -1,15 +1,6 @@
import _map from 'lodash-es/map';
import {
event as d3_event,
select as d3_select
} from 'd3-selection';
import {
geoExtent,
geoPointInPolygon
} from '../geo';
import { event as d3_event, select as d3_select } from 'd3-selection';
import { geoExtent, geoPointInPolygon } from '../geo';
import { modeSelect } from '../modes';
import { uiLasso } from '../ui';
@@ -47,7 +38,8 @@ export function behaviorLasso(context) {
function normalize(a, b) {
return [
[Math.min(a[0], b[0]), Math.min(a[1], b[1])],
[Math.max(a[0], b[0]), Math.max(a[1], b[1])]];
[Math.max(a[0], b[0]), Math.max(a[1], b[1])]
];
}
@@ -58,11 +50,13 @@ export function behaviorLasso(context) {
var bounds = lasso.extent().map(context.projection.invert);
var extent = geoExtent(normalize(bounds[0], bounds[1]));
return _map(context.intersects(extent).filter(function(entity) {
var intersects = context.intersects(extent).filter(function(entity) {
return entity.type === 'node' &&
geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) &&
!context.features().isHidden(entity, graph, entity.geometry(graph));
}), 'id');
});
return intersects.map(function(entity) { return entity.id; });
}