<commit_before>import Dispatcher from './Dispatcher';

function createDispatchable(type) {
  return {
    dispatch(payload) {
      // TODO ActionCreator displayName to make funcName belongs to ActionCreator
      Dispatcher.dispatch({type, payload});
    }
  };
}

function createAction(funcName, func, spec) {
  var action, scope = Object.assign(createDispatchable(funcName), spec);
  action = func.bind(scope);
  action.actionType = funcName;
  return action;
}

var ActionCreator = function (spec) {
  var func, funcName;
  for (var propName in spec) {
    if (!spec.hasOwnProperty(propName)) {
      continue;
    }

    switch (typeof spec[propName]) {
      case 'function':
        funcName = propName;
        func = spec[funcName];

        this[funcName] = createAction(funcName, func, spec);

        // HACK
        spec[funcName] = this[funcName];

        break;
      default:
        this[propName] = spec[propName];
        break;
    }
  }
};

export default ActionCreator;<commit_msg>Added _ to private methods<commit_after>import Dispatcher from './Dispatcher';

function _createDispatchable(type) {
  return {
    dispatch(payload) {
      // TODO ActionCreator displayName to make funcName belongs to ActionCreator
      Dispatcher.dispatch({type, payload});
    }
  };
}

function _createAction(funcName, func, spec) {
  var action, scope = Object.assign(_createDispatchable(funcName), spec);
  action = func.bind(scope);
  action.actionType = funcName;
  return action;
}

var ActionCreator = function (spec) {
  var func, funcName;
  for (var propName in spec) {
    if (!spec.hasOwnProperty(propName)) {
      continue;
    }

    switch (typeof spec[propName]) {
      case 'function':
        funcName = propName;
        func = spec[funcName];

        this[funcName] = _createAction(funcName, func, spec);

        // HACK
        spec[funcName] = this[funcName];

        break;
      default:
        this[propName] = spec[propName];
        break;
    }
  }
};

export default ActionCreator;
{'fraction_non_alphanumeric': 0.11259259259259259, 'fraction_numerical': 0.0, 'mean_word_length': 2.949317738791423, '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': '922632', 'n_tokens_mistral': 614, 'n_tokens_neox': 598, 'n_words': 148}