Flatten out nested arrays and dicts in query params into correct format
968494
def flatten_params(self, data, base_key=None):
        
        result = {}

        if data is None:
            return result

        map_data = None
        if not isinstance(data, collections.Mapping):
            map_data = []
            for idx, val in enumerate(data):
                map_data.append([str(idx), val])
        else:
            map_data = list(data.items())

        for key, value in map_data:
            if not base_key is None:
                key = base_key + "[" + key + "]"

            if isinstance(value, basestring) or not hasattr(value, "__iter__"):
                result[key] = value
            else:
                result.update(self.flatten_params(value, key))

        return result
726321
def as_params(self):
        
        params = {}
        if self.has_filters:
            params['$filter'] = self.get_filters()
        if self.has_order:
            params['$orderby'] = self.get_order()
        if self.has_selects:
            params['$select'] = self.get_selects()
        if self.has_expands:
            params['$expand'] = self.get_expands()
        if self._search:
            params['$search'] = self._search
            params.pop('$filter', None)
            params.pop('$orderby', None)
        return params
147997
function(data, prefix) {
  prefix = prefix || '';
  var row = Object.keys(data).map(function(key) {
    if (typeof data[key] !== 'object') {
      return util.format('%s%s="%s"', prefix, key, data[key]);
    }
    // Flatten this nested object.
    return _reformat(data[key], key + '.');
  });
  return row.join(' ');
}
215686
protected function _flattenMultiDimensionalParams($arrays, $prefix = null)
    {
        $new = array();

        if (is_object($arrays)) {
            $arrays = get_object_vars($arrays);
        }

        foreach ($arrays as $key => $value) {
            $k =
                isset($prefix) ?
                    $prefix . '[' . $key . ']' :
                    $key;

            if (is_array($value) || is_object($value)) {
                $new =
                    array_merge(
                        $new,
                        $this->_flattenMultiDimensionalParams($value, $k)
                    );
            } else {
                $new[$k] = $value;
            }
        }

        return $new;
    }
6503
function flatten(keys) {
  var result = []
  var index = -1
  var length = keys.length

  while (++index < length) {
    if (own.call(alias, keys[index])) {
      result = result.concat(flatten(alias[keys[index]]))
    } else if (Array.isArray(keys[index])) {
      result = result.concat(keys[index])
    } else {
      result.push(keys[index])
    }
  }

  return result
}
286445
def to_nested_php_args(data, prefix_key=None):
    
    is_root = prefix_key is None
    prefix_key = prefix_key if prefix_key else ''

    if islist(data):
        data_iter = data if is_root else enumerate(data)
        new_data = [] if is_root else {}
    elif isdict(data):
        data_iter = list(data.items())
        new_data = {}
    else:
        raise TypeError('expected dict or list, got {0}'.format(type(data)))

    if islist(new_data):
        def data_set(k, v):
            new_data.append((k, v))
        def data_update(d):
            for k, v in list(d.items()):
                new_data.append((k, v))
    else:
        def data_set(k, v):
            new_data[k] = v
        data_update = new_data.update

    for key, value in data_iter:
        end_key = prefix_key + (str(key) if is_root else '[{0}]'.format(key))
        if _is_leaf(value):
            data_set(end_key, value)
        else:
            nested_args = to_nested_php_args(value, end_key)
            data_update(nested_args)

    return new_data
322201
def format_parameters(params):
    ''''''

    if not params:
        return {}

    # expect multiple invocations of --parameters but fall back
    # to ; delimited if only one --parameters is specified
    if len(params) == 1:
        if params[0].find(';') != -1:  # found
            params = params[0].split(';')
        else:
            params = params[0].split(',')

    parameters = {}
    for p in params:
        try:
            (n, v) = p.split('=', 1)
        except ValueError:
            msg = '%s(%s). %s.' % ('Malformed parameter', p,
                                   'Use the key=value format')
            raise exc.CommandError(msg)

        if n not in parameters:
            parameters[n] = v
        else:
            if not isinstance(parameters[n], list):
                parameters[n] = [parameters[n]]
            parameters[n].append(v)

    return parameters
612354
def clean_parameters(self, params):
        ''''''
        return {k: v for k, v in params.items() if k in self.adapter.facets}
1220376
def param_dict_to_list(dict,skeys=None):
    """"""
    #sort keys
    RV = SP.concatenate([dict[key].flatten() for key in skeys])
    return RV
    pass
1351821
function flatten(source) {
  var output = {};

  function step(object, prev) {
    for (var key in object) {
      if (has.call(object, key)) {
        var value = object[key];
        var newKey = prev ? prev + ' ' + key : key;

        if (!is.array(value) && is.object(value)) {
          return step(value, newKey);
        }

        output[newKey] = value;
      }
    }
  }

  step(source);

  return output;
}
1276496
function flattenArray(array, filter, map, result) {
  let index = -1;
  while (++index < array.length) {
    const value = array[index];
    if (Array.isArray(value)) {
      flattenArray(value, filter, map, result);
    } else if (filter(value)) {
      result.push(map(value));
    }
  }
  return result;
}
445967
function _flatten(_ref) {
  var _ref2 = _toArray(_ref);

  var first = _ref2[0];

  var rest = _ref2.slice(1);

  if (first === undefined) {
    return [];
  } else if (!Array.isArray(first)) {
    return [first].concat(_toConsumableArray(_flatten(rest)));
  } else {
    return [].concat(_toConsumableArray(_flatten(first)), _toConsumableArray(_flatten(rest)));
  }
}
815635
function (serializeArray) {
            var self = this;
            parseQuery(self);
            return S.param(self._queryMap, undefined, undefined, serializeArray);
        }
748557
function normaliseParams(params) {
			if (typeof params === 'string') {
				params = params.split(' ');
			}
			else if (!$.isArray(params)) {
				var opts = [];
				for (var name in params) {
					opts[0] = name;
					opts[1] = params[name];
				}
				params = opts;
			}
			return params;
		}
743002
def _convert_nest_to_flat(self, params, _result=None, _prefix=None):
        
        if _result is None:
            _result = {}
        for k, v in params.iteritems():
            if _prefix is None:
                path = k
            else:
                path = _prefix + '.' + k
            if isinstance(v, dict):
                self._convert_nest_to_flat(v, _result=_result, _prefix=path)
            else:
                _result[path] = v
        return _result
950114
function serialize(queryParams) {
  return Object.keys(queryParams)
    .filter(key => queryParams[key] !== undefined)
    .map(key => arrayToStr(key, queryParams[key]))
    .join('&');
}
975891
def prepare_query_params(**kwargs):
    
    return [
        (sub_key, sub_value)
        for key, value in kwargs.items()
        for sub_key, sub_value in expand(value, key)
        if sub_value is not None
    ]