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
+9 -12
View File
@@ -1,11 +1,5 @@
import _map from 'lodash-es/map';
import { dispatch as d3_dispatch } from 'd3-dispatch';
import {
event as d3_event,
select as d3_select
} from 'd3-selection';
import { event as d3_event, select as d3_select } from 'd3-selection';
import { osmEntity } from '../../osm/entity';
import { t } from '../../util/locale';
@@ -204,7 +198,7 @@ export function uiFieldCombo(field, context) {
// hide the caret if there are no suggestions
container.classed('empty-combobox', data.length === 0);
_comboData = _map(data, function(d) {
_comboData = data.map(function(d) {
var k = d.value;
if (isMulti) k = k.replace(field.key, '');
var v = snake_case ? unsnake(k) : k;
@@ -221,14 +215,17 @@ export function uiFieldCombo(field, context) {
}
function setPlaceholder(d) {
function setPlaceholder(values) {
var ph;
if (isMulti || isSemi) {
ph = field.placeholder() || t('inspector.add');
} else {
var vals = _map(d, 'value').filter(function(s) { return s.length < 20; }),
placeholders = vals.length > 1 ? vals : _map(d, 'key');
var vals = values
.map(function(d) { return d.value; })
.filter(function(s) { return s.length < 20; });
var placeholders = vals.length > 1 ? vals : values.map(function(d) { return d.key; });
ph = field.placeholder() || placeholders.slice(0, 3).join(', ');
}
@@ -407,7 +404,7 @@ export function uiFieldCombo(field, context) {
}
// Set keys for form-field modified (needed for undo and reset buttons)..
field.keys = _map(_multiData, 'key');
field.keys = _multiData.map(function(d) { return d.key; });
} else if (isSemi) {
var arr = utilArrayUniq((tags[field.key] || '').split(';')).filter(Boolean);
+5 -20
View File
@@ -1,24 +1,9 @@
import { geoPath as d3_geoPath } from 'd3-geo';
import {
event as d3_event,
select as d3_select
} from 'd3-selection';
import {
zoom as d3_zoom,
zoomIdentity as d3_zoomIdentity
} from 'd3-zoom';
import { event as d3_event, select as d3_select } from 'd3-selection';
import { zoom as d3_zoom, zoomIdentity as d3_zoomIdentity } from 'd3-zoom';
import { t } from '../util/locale';
import {
geoRawMercator,
geoScaleToZoom,
geoVecSubtract,
geoVecScale,
geoZoomToScale,
} from '../geo';
import { geoRawMercator, geoScaleToZoom, geoVecSubtract, geoVecScale, geoZoomToScale } from '../geo';
import { rendererTileLayer } from '../renderer';
import { svgDebug, svgData } from '../svg';
import { utilSetTransform } from '../util';
@@ -27,7 +12,7 @@ import { utilGetDimensions } from '../util/dimensions';
export function uiMapInMap(context) {
function map_in_map(selection) {
function mapInMap(selection) {
var backgroundLayer = rendererTileLayer(context);
var overlayLayers = {};
var projection = geoRawMercator();
@@ -338,5 +323,5 @@ export function uiMapInMap(context) {
.on(t('background.minimap.key'), toggle);
}
return map_in_map;
return mapInMap;
}