Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function filterFeatures(features, filter, inverse = true) {
const new_features = [];
// the createFilter function is from mapbox!
// uses the mapbox gl style filters.
let filter_function = function() { return true; };
if (filter !== undefined && filter !== null ) {
filter_function = createFilter(['all'].concat(filter));
}
for(const feature of features) {
if(inverse !== filter_function(feature)) {
new_features.push(feature);
}
}
return new_features;
}