diff --git a/middleware/localNamingConventions.js b/middleware/localNamingConventions.js index 20c77f6b..a8818e8b 100644 --- a/middleware/localNamingConventions.js +++ b/middleware/localNamingConventions.js @@ -28,7 +28,7 @@ function applyLocalNamingConventions(req, res, next) { // relevant for some countries var flip = place.parent.country_a.some(function(country) { - return _.includes(flipNumberAndStreetCountries, country); + return flipNumberAndStreetCountries.includes(country); }); if (!flip){ return false; } if( !place.hasOwnProperty('address_parts') ){ return false; } diff --git a/sanitizer/_deprecate_quattroshapes.js b/sanitizer/_deprecate_quattroshapes.js index bd45c025..1f188816 100644 --- a/sanitizer/_deprecate_quattroshapes.js +++ b/sanitizer/_deprecate_quattroshapes.js @@ -18,7 +18,7 @@ function sanitize( raw, clean, opts ) { if( raw.hasOwnProperty('sources') ){ var sources = raw.sources.split(','); - if (_.includes(sources, 'quattroshapes') || _.includes(sources, 'qs')) { + if (sources.includes('quattroshapes') || sources.includes('qs')) { // emit a warning message so users can transition. messages.warnings.push('You are using Quattroshapes as a data source in this query. ' + diff --git a/sanitizer/_details.js b/sanitizer/_details.js index c67f7c47..9f3d27e1 100644 --- a/sanitizer/_details.js +++ b/sanitizer/_details.js @@ -1,6 +1,4 @@ - -var _ = require('lodash'), - check = require('check-types'); +var check = require('check-types'); var DEFAULT_DETAILS_BOOL = true; @@ -22,7 +20,7 @@ function sanitize( raw, clean ){ // be lenient with 'truthy' values function isTruthy(val) { if( check.string( val ) ){ - return _.includes( ['true', '1'], val ); + return ['true', '1'].includes( val ); } return val === 1 || val === true; diff --git a/sanitizer/_flag_bool.js b/sanitizer/_flag_bool.js index 4ed5c339..aac57cdf 100644 --- a/sanitizer/_flag_bool.js +++ b/sanitizer/_flag_bool.js @@ -44,7 +44,7 @@ function sanitize( raw, clean, opts ){ * @returns {boolean} */ function isTruthy(val) { - return _.includes( ['true', '1', 1, true], val ); + return ['true', '1', 1, true].includes( val ); } module.exports = setup; diff --git a/sanitizer/_geo_reverse.js b/sanitizer/_geo_reverse.js index 3b031089..1ce49909 100644 --- a/sanitizer/_geo_reverse.js +++ b/sanitizer/_geo_reverse.js @@ -30,7 +30,7 @@ module.exports = function sanitize( raw, clean ){ // if no radius was passed, set the default if ( _.isUndefined( raw['boundary.circle.radius'] ) ) { // the default is small unless layers other than venue or address were explicitly specified - if (clean.layers && clean.layers.length > 0 && !_.includes(clean.layers, 'venue') && !_.includes(clean.layers, 'address')) { + if (clean.layers && clean.layers.length > 0 && !clean.layers.includes('venue') && !clean.layers.includes('address')) { raw['boundary.circle.radius'] = defaults['boundary:circle:radius:coarse']; } else { raw['boundary.circle.radius'] = defaults['boundary:circle:radius']; diff --git a/sanitizer/_groups.js b/sanitizer/_groups.js index fc1d3f30..0da39666 100644 --- a/sanitizer/_groups.js +++ b/sanitizer/_groups.js @@ -1,5 +1,3 @@ -var _ = require('lodash'); - /* * Specify an object and array of keys to check. * An error will be thrown if at least one, but not all of them are specified @@ -10,7 +8,10 @@ var _ = require('lodash'); * returns true if all are present, false if none are present, throws an exception otherwise */ function optional_group(object, keys) { - var contained_in_object = _.includes.bind(null, Object.keys(object)); + var object_properties = Object.keys(object); + var contained_in_object = function(key_to_check) { + return object_properties.includes(key_to_check); + }; if (keys.every(contained_in_object)) { return true; @@ -26,7 +27,10 @@ function optional_group(object, keys) { * An error will be thrown if any of the keys are missing from the object */ function required_group(object, keys) { - var contained_in_object = _.includes.bind(null, Object.keys(object)); + var object_properties = Object.keys(object); + var contained_in_object = function(key_to_check) { + return object_properties.includes(key_to_check); + }; if (keys.every(contained_in_object)) { return true; diff --git a/sanitizer/_ids.js b/sanitizer/_ids.js index ba456766..e598d0c9 100644 --- a/sanitizer/_ids.js +++ b/sanitizer/_ids.js @@ -30,17 +30,17 @@ function sanitizeId(rawId, messages) { var id = parts.slice(2).join(ID_DELIM); // check if any parts of the gid are empty - if (_.includes([source, layer, id], '')) { + if ([source, layer, id].includes('')) { messages.errors.push( formatError(rawId) ); return; } var valid_values = Object.keys(type_mapping.source_mapping); - if (!_.includes(valid_values, source)) { + if (!valid_values.includes(source)) { messages.errors.push( targetError(source, valid_values) ); return; } - if (!_.includes(type_mapping.layers, layer)) { + if (!type_mapping.layers.includes(layer)) { messages.errors.push( targetError(layer, type_mapping.layers) ); return; } diff --git a/sanitizer/_sources_and_layers.js b/sanitizer/_sources_and_layers.js index fa0325b2..6ca52193 100644 --- a/sanitizer/_sources_and_layers.js +++ b/sanitizer/_sources_and_layers.js @@ -15,7 +15,7 @@ function sanitize( raw, clean ){ clean.sources.forEach(function(source) { var layers_for_source = type_mapping.layers_by_source[source]; clean.layers.forEach(function(layer) { - if (_.includes(layers_for_source, layer)) { + if (layers_for_source.includes(layer)) { at_least_one_valid_combination = true; } else { var message = 'You have specified both the `sources` and `layers` ' +