<commit_before>'use strict';

var _ = require('lodash');
var Promise = require('bluebird');
var themes = require('../services/themes');
var $q = require('../services/ng-utils').$q;
var searchService = require('../services/search');
var cosmopolitan = require('../services/cosmopolitan');
var ngModule = require('../module');
var config = window.globalConfig || {};

var SEARCH_FILTERS = [
  'authors',
  'regions',
  'countries',
  'cities',
  'formats'
];

function createToken() {
  return '' + (new Date() * 1) + ':' + Math.round(Math.random() * 1000000);
}

function createNameMap(items) {
  return _.chain(items)
    .map(function(item) {
      return [item.code, item.name];
    })
    .fromPairs()
    .value();
}

function getInitialSearchParams(searchQuery) {
  var params = Object.assign(
    {},
    searchQuery,
    {
      filter: {}
    }
  );

  SEARCH_FILTERS.forEach(function(filter) {
    if (params[filter] !== undefined) {
      // eslint-disable-next-line max-len
      var value = (_.isArray(params[filter])) ? params[filter] : [params[filter]];
      params.filter[filter] = value;

      delete params[filter];
    }
  });<commit_msg>Use lodash for .assign to support IE11<commit_after>'use strict';

var _ = require('lodash');
var Promise = require('bluebird');
var themes = require('../services/themes');
var $q = require('../services/ng-utils').$q;
var searchService = require('../services/search');
var cosmopolitan = require('../services/cosmopolitan');
var ngModule = require('../module');
var config = window.globalConfig || {};

var SEARCH_FILTERS = [
  'authors',
  'regions',
  'countries',
  'cities',
  'formats'
];

function createToken() {
  return '' + (new Date() * 1) + ':' + Math.round(Math.random() * 1000000);
}

function createNameMap(items) {
  return _.chain(items)
    .map(function(item) {
      return [item.code, item.name];
    })
    .fromPairs()
    .value();
}

function getInitialSearchParams(searchQuery) {
  var params = _.assign(
    {},
    searchQuery,
    {
      filter: {}
    }
  );

  SEARCH_FILTERS.forEach(function(filter) {
    if (params[filter] !== undefined) {
      // eslint-disable-next-line max-len
      var value = (_.isArray(params[filter])) ? params[filter] : [params[filter]];
      params.filter[filter] = value;

      delete params[filter];
    }
  });
{'fraction_non_alphanumeric': 0.18279109589041095, 'fraction_numerical': 0.007705479452054794, 'mean_word_length': 3.4261363636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101915', 'n_tokens_mistral': 782, 'n_tokens_neox': 754, 'n_words': 150}