Apply the appropriate filter based on the input data

@param data
@param restrictedFields
@param allowedFields
@returns {{}}
163682
function applyFilter(data, restrictedFields, allowedFields) {
    var filterFunc;

    // if string, something like a sort where each word should be a value
    var isString = _.isString(data);
    if (isString) { data = data.split(' '); }

    if (restrictedFields) {
        filterFunc = _.isArray(data) ? removeItemsFromList : removeFieldsFromObj;
        data = filterFunc(data, restrictedFields);
    }
    else if (allowedFields) {
        filterFunc = _.isArray(data) ? getItemsFromList : getFieldsFromObj;
        data = filterFunc(data, allowedFields);
    }

    return isString ? data[0] : data;
}
4457
def filtered(self, allowed):
        
        kws = {k:v for k,v in self.kwargs.items() if k in allowed}
        return self.__class__(key=self.key,
                              allowed_keywords=self.allowed_keywords,
                              merge_keywords=self.merge_keywords, **kws)
163603
def _clean_fields(allowed_fields: dict, fields: FieldsParam) -> Iterable[str]:
    """"""
    if fields == ALL:
        fields = allowed_fields.keys()
    else:
        fields = tuple(fields)
        unknown_fields = set(fields) - allowed_fields.keys()
        if unknown_fields:
            raise ValueError('Unknown fields: {}'.format(unknown_fields))
    return fields
1337359
function filter(rows = [], filters = [], filterText, columns) {
  let filteredRows = rows.slice(0);
  if (filters.length === 0 && !filterText) {
    return filteredRows;
  }

  const textFilters = [
    ...(filterText ? [filterText.toLowerCase()] : []),
    ...filters.filter(f => f.textFilter).map(f => f.value),
  ];

  const valueFilters = filters.filter(f => f.valueFilter);

  // apply text filters across all columns
  if (textFilters.length > 0) {
    filteredRows = _.filter(rows, row => _.some(columns, (column) => {
      if (!column.searchable) {
        return false;
      }
      const normalized = String(_.get(row, column.key)).toLowerCase();
      return _.every(textFilters, f => normalized.indexOf(f) > -1);
    }));
  }

  // apply value filters on filterable columns
  if (valueFilters.length > 0) {
    const groups = _.groupBy(valueFilters, 'key');
    filteredRows = _.filter(filteredRows, row => _.every(
      groups,
      (groupFilters, groupKey) => {
        const value = _.get(row, groupKey);
        return _.some(groupFilters, f => f.value === value);
      }
    ));
  }

  return filteredRows;
}
639371
def data_filter(data, filters)
      filters.split(',').each do |filter|
        field = filter.split(':').first.strip.downcase
        search = filter.split(':').last.strip
        if search =~ /^\/.*\/?/
          data = data.find_all { |k| k["#{field}"].to_s =~ search.to_regexp } if field && search
        else
          data = data.find_all { |k| k["#{field}"].to_s == "#{search}" } if field && search
        end
      end
      data
    end
331495
function filter(type) {
  if (utils.isObject(type)) {
    return type
  }
  else if (!filters.hasOwnProperty(type)) {
    throw new FieldError('Bad filter type: ' + type)
  }

  var args = utils.args(arguments, 1)
    , filter = {
      type: type
    }

  filters[type].apply(filter, args)

  return filter
}
93973
function applyDisallowedRuleToArray( itemsRule, items ) {
		if ( !itemsRule )
			return false;

		var hadInvalid = false,
			allDisallowed = itemsRule === true;

		for ( var i = items.length; i--; ) {
			if ( allDisallowed || itemsRule( items[ i ] ) ) {
				items.splice( i, 1 );
				hadInvalid = true;
			}
		}

		return hadInvalid;
	}
1237573
def is_restricted(self, assets, dt):
        
        if isinstance(assets, Asset):
            return self._is_restricted_for_asset(assets, dt)

        is_restricted = partial(self._is_restricted_for_asset, dt=dt)
        return pd.Series(
            index=pd.Index(assets),
            data=vectorize(is_restricted, otypes=[bool])(assets)
        )
409760
function prepareSelectionData (fields, i) {
    const resp = {};
    for (let field of fields) {
        resp[field.name()] = new Value(field.partialField.data[i], field);
    }
    return resp;
}
1050479
function (data, filters) {
			this.writeDebug('filterData',arguments);
			var filterTest = true;

			for (var k in filters) {
				if (filters.hasOwnProperty(k)) {

					// Exclusive filtering
					if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
						var filterTests = filters[k];
						var exclusiveTest = [];

						if (typeof data[k] !== 'undefined') {
							for (var l = 0; l < filterTests.length; l++) {
								exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, ''));
							}
						}

						if (exclusiveTest.indexOf(true) === -1) {
							filterTest = false;
						}
					}
					// Inclusive filtering
					else {
						if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '')))) {
							filterTest = false;
						}
					}
				}
			}

			if (filterTest) {
				return true;
			}
		}
485409
function _applyFilters(rawdata, filterOptions) {
			var dataToWorkOn = (JSON.parse(JSON.stringify(rawdata)));
			var containerWidth = document.querySelector('#sapUiSupportPerfHeaderTimeline').offsetWidth - document.querySelector('#sapUiSupportPerfHeaderTimelineBarInfoWrapper').offsetWidth;
			var scrollWidth = 20;
			var filteredTime = 1;

			dataToWorkOn = _filterByTime(filterOptions.filterByTime, dataToWorkOn);
			dataToWorkOn = _sortBy(filterOptions.orderByValue, dataToWorkOn);
			dataToWorkOn = _filterMinValue(filterOptions.minValue, dataToWorkOn);

			if (dataToWorkOn.length) {
				filteredTime = filterOptions.filterByTime.end - filterOptions.filterByTime.start;
			}

			_widthSingleUnit = ((containerWidth - scrollWidth) / filteredTime); //ms in px

			return dataToWorkOn;
		}
566364
function exclude(array $exclusionFields = [], $exclusionBehave = self::EXCLUDE_DISALLOW)
    {
        $exclude = [];
        foreach ($this->value as $field => $term)
        {
            if (!empty($exclusionFields))
            {
                $flag = in_array($field, $exclusionFields);

                ($exclusionBehave != self::EXCLUDE_ALLOW) ?: $flag = !$flag;

                if ($flag)
                    // The Field not considered as Expression Term
                    continue;
            }

            $exclude[$field] = $term;

        }// end foreach


        return new StdArray($exclude);
    }
157265
function(schemaData) {
    var fields = [];

    if (schemaData &&
           'object' === typeof schemaData &&
           schemaData['fields'] &&
            Array.isArray(schemaData['fields'])) {
      schemaData['fields'].forEach((f) => {
        if (f['field'] && f['type'] && 'nested' !== f['type']) {
          fields.push(f['field']);
        }
      });

    }

    if (fields.length) {
      fields = fields.filter(this.uniqueFilter);
    }

    return fields;
  }
344804
function allowedMethods(methods) {
  // default values
  var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false  };
  // check and override if one of the default methods
  for (var key in methods) {
    var newKey = key.toUpperCase();
    if ( methodsAllowed[newKey]!=undefined) {
      methodsAllowed[newKey] = Boolean(methods[key]);
    }
  }
  return methodsAllowed;
}
707238
private JSType restrictByUndefined(JSType type) {
    // If not voidable, there's nothing to do. If not nullable then the easiest
    // thing is to simply remove both null and undefined. If nullable, then add
    // null back into the union after removing null and undefined.
    if (!type.isVoidable()) {
      return type;
    }
    JSType restricted = type.restrictByNotNullOrUndefined();
    if (type.isNullable()) {
      JSType nullType = registry.getNativeType(JSTypeNative.NULL_TYPE);
      return registry.createUnionType(ImmutableList.of(restricted, nullType));
    }
    // The bottom type cannot appear in a jsdoc
    return restricted.isEmptyType() ? type : restricted;
  }
769734
def is_restricted(self, assets, dt):
        
        if isinstance(assets, Asset):
            return assets in self._restricted_set
        return pd.Series(
            index=pd.Index(assets),
            data=vectorized_is_element(assets, self._restricted_set)
        )
1263543
function( value, allowed_values ) {
			var error;

			// Convert the allowed_values to an array:
			allowed_values = allowed_values.split( ',' );

			if ( allowed_values.indexOf( value ) === -1 ) {
				error = {
					"rule": "matches",
					"message": "ERROR:provided value does not match an allowed value: " + allowed_values
				};
				return [ error ];
			}
			return;
		}