mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 07:46:58 +02:00
Remove lodash reject (re: #6087)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import _isEqual from 'lodash-es/isEqual';
|
||||
import _isFunction from 'lodash-es/isFunction';
|
||||
import _map from 'lodash-es/map';
|
||||
import _reject from 'lodash-es/reject';
|
||||
import _union from 'lodash-es/union';
|
||||
import _uniq from 'lodash-es/uniq';
|
||||
import _without from 'lodash-es/without';
|
||||
@@ -158,10 +157,6 @@ export function actionMergeRemoteChanges(id, localGraph, remoteGraph, formatUser
|
||||
|
||||
|
||||
function mergeTags(base, remote, target) {
|
||||
function ignoreKey(k) {
|
||||
return dataDiscarded[k];
|
||||
}
|
||||
|
||||
if (_option === 'force_local' || _isEqual(target.tags, remote.tags)) {
|
||||
return target;
|
||||
}
|
||||
@@ -173,7 +168,8 @@ export function actionMergeRemoteChanges(id, localGraph, remoteGraph, formatUser
|
||||
var o = base.tags || {};
|
||||
var a = target.tags || {};
|
||||
var b = remote.tags || {};
|
||||
var keys = _reject(_union(Object.keys(o), Object.keys(a), Object.keys(b)), ignoreKey);
|
||||
var keys = _union(Object.keys(o), Object.keys(a), Object.keys(b))
|
||||
.filter(function(k) { return !dataDiscarded[k]; });
|
||||
var tags = Object.assign({}, a); // shallow copy
|
||||
var changed = false;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import _isEmpty from 'lodash-es/isEmpty';
|
||||
import _forEach from 'lodash-es/forEach';
|
||||
import _map from 'lodash-es/map';
|
||||
import _omit from 'lodash-es/omit';
|
||||
import _reject from 'lodash-es/reject';
|
||||
import _without from 'lodash-es/without';
|
||||
import _uniq from 'lodash-es/uniq';
|
||||
|
||||
@@ -503,7 +502,7 @@ export function coreHistory(context) {
|
||||
var osm = context.connection();
|
||||
var baseWays = baseEntities.filter(function(e) { return e.type === 'way'; });
|
||||
var nodes = _flatten(_uniq(_map(baseWays, 'nodes')));
|
||||
var missing = _reject(nodes, function(n) { return _stack[0].graph.hasEntity(n); });
|
||||
var missing = nodes.filter(function(n) { return !_stack[0].graph.hasEntity(n); });
|
||||
|
||||
if (!_isEmpty(missing) && osm) {
|
||||
loadComplete = false;
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
import _map from 'lodash-es/map';
|
||||
import _reject from 'lodash-es/reject';
|
||||
|
||||
import { geoArea as d3_geoArea } from 'd3-geo';
|
||||
|
||||
import { osmEntity } from './entity';
|
||||
import { osmJoinWays } from './multipolygon';
|
||||
import {
|
||||
geoExtent,
|
||||
geoPolygonContainsPolygon,
|
||||
geoPolygonIntersectsPolygon
|
||||
} from '../geo';
|
||||
import { geoExtent, geoPolygonContainsPolygon, geoPolygonIntersectsPolygon } from '../geo';
|
||||
|
||||
|
||||
export function osmRelation() {
|
||||
@@ -162,7 +157,7 @@ Object.assign(osmRelation.prototype, {
|
||||
|
||||
|
||||
removeMembersWithID: function(id) {
|
||||
var members = _reject(this.members, function(m) { return m.id === id; });
|
||||
var members = this.members.filter(function(m) { return m.id !== id; });
|
||||
return this.update({members: members});
|
||||
},
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import _bind from 'lodash-es/bind';
|
||||
import _forEach from 'lodash-es/forEach';
|
||||
import _isEmpty from 'lodash-es/isEmpty';
|
||||
import _reject from 'lodash-es/reject';
|
||||
import _uniq from 'lodash-es/uniq';
|
||||
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
@@ -127,8 +126,11 @@ export function presetIndex(context) {
|
||||
all.areaKeys = function() {
|
||||
var areaKeys = {};
|
||||
var ignore = ['barrier', 'highway', 'footway', 'railway', 'type']; // probably a line..
|
||||
|
||||
// ignore name-suggestion-index and deprecated presets
|
||||
var presets = _reject(_reject(all.collection, 'suggestion'), 'replacement');
|
||||
var presets = all.collection.filter(function(p) {
|
||||
return !p.suggestion && !p.replacement;
|
||||
});
|
||||
|
||||
// whitelist
|
||||
presets.forEach(function(d) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import _difference from 'lodash-es/difference';
|
||||
import _map from 'lodash-es/map';
|
||||
import _reject from 'lodash-es/reject';
|
||||
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
@@ -91,7 +90,7 @@ export function svgLayers(projection, context) {
|
||||
drawLayers.remove = function(what) {
|
||||
var arr = [].concat(what);
|
||||
arr.forEach(function(id) {
|
||||
layers = _reject(layers, function(o) {return o.id === id;});
|
||||
layers = layers.filter(function(o) { return o.id !== id; });
|
||||
});
|
||||
dispatch.call('change');
|
||||
return this;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import _map from 'lodash-es/map';
|
||||
import _reject from 'lodash-es/reject';
|
||||
import _remove from 'lodash-es/remove';
|
||||
import _uniq from 'lodash-es/uniq';
|
||||
|
||||
@@ -110,9 +109,14 @@ export function uiFieldCombo(field, context) {
|
||||
}
|
||||
|
||||
|
||||
// Compute the difference between arrays of objects by `value` property
|
||||
//
|
||||
// objectDifference([{value:1}, {value:2}, {value:3}], [{value:2}])
|
||||
// > [{value:1}, {value:3}]
|
||||
//
|
||||
function objectDifference(a, b) {
|
||||
return _reject(a, function(d1) {
|
||||
return b.some(function(d2) { return d1.value === d2.value; });
|
||||
return a.filter(function(d1) {
|
||||
return !b.some(function(d2) { return d1.value === d2.value; });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user