<commit_before>'use strict';

exports.__esModule = true;
exports['default'] = createGroupByReducer;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _warning = require('warning');

var _warning2 = _interopRequireDefault(_warning);

var _immutable = require('immutable');

function createGroupByReducer(actionTypes, groupingKey) {
  var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

  var groupedDefaultState = _immutable.fromJS({});
  var loadAction = actionTypes[0];
  var deleteAction = actionTypes[1];

  var keyFn = options.keyFn || function (val) {
    return val ? '' + val : null;
  };

  return function groupBy() {
    var _state = arguments.length <= 0 || arguments[0] === undefined ? groupedDefaultState : arguments[0];

    var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

    var state = _state;

    if (deleteAction && action.type === deleteAction) {
      var id = action.deletedModel.id;
      var _key = groupingKey(action.deletedModel);
      var key = keyFn(_key);
      var current = state.get(key);

      if (_lodash2['default'].isNil(key)) {
        _warning2['default'](false, '[fl-react-utils] groupByReducer: groupingKey(action.deletedModel) was nil for deleted model ' + JSON.stringify(action.deletedModel));
      } else if (!current) {
        _warning2['default'](false, '[fl-react-utils] groupByReducer: state.get(key) was nil for key ' + key + ' from deleted model ' + JSON.stringify(action.deletedModel));
      } else {
        var _state$merge;

        return state.merge((_state$merge = {}, _state$merge[key] = current.remove(id), _state$merge));
      }
    } else if (action.type === loadAction) {<commit_msg>build<commit_after>'use strict';

exports.__esModule = true;
exports['default'] = createGroupByReducer;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _warning = require('warning');

var _warning2 = _interopRequireDefault(_warning);

var _immutable = require('immutable');

function createGroupByReducer(actionTypes, groupingKey) {
  var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

  var groupedDefaultState = _immutable.fromJS({});
  var loadAction = actionTypes[0];
  var deleteAction = actionTypes[1];

  var keyFn = options.keyFn || function (val) {
    return val ? '' + val : null;
  };

  return function groupBy() {
    var _state = arguments.length <= 0 || arguments[0] === undefined ? groupedDefaultState : arguments[0];

    var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

    var state = _state;

    if (deleteAction && action.type === deleteAction) {
      var id = action.deletedModel.id;
      var _key = groupingKey(action.deletedModel);
      var key = keyFn(_key);
      var current = state.get(key);

      if (_lodash2['default'].isNil(key)) {
        _warning2['default'](false, '[fl-react-utils] groupByReducer: groupingKey(action.deletedModel) was nil for deleted model ' + JSON.stringify(action.deletedModel));
      } else if (!current) {
        _warning2['default'](false, '[fl-react-utils] groupByReducer: state.get(key) doesnt exist for key ' + key + ' from deleted model ' + JSON.stringify(action.deletedModel));
      } else {
        if (_immutable.Set.isSet(current)) {
          var _state$merge;

          return state.merge((_state$merge = {}, _state$merge[key] = current.remove(id), _state$merge));
        }
        return state.remove(key);
      }
    } else if (action.type === loadAction) {
{'fraction_non_alphanumeric': 0.14570230607966456, 'fraction_numerical': 0.008385744234800839, 'mean_word_length': 3.9315245478036176, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5366538', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1142, 'n_words': 272}