code: 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;
  }
docs: Apply the appropriate filter based on the input data
  
  @param data
  @param restrictedFields
  @param allowedFields
  @returns {{}}