<commit_before>import Immutable, { Map } from 'immutable'
import { generateActionNames } from './utils/actionNames'
import { createReducer, fetchReducer, updateReducer, deleteReducer } from './reducers'

/**
 * Creates a reducer with the provided config
 * @param  {Object} config - reducer configuration
 *
 * @return {Function} - Reducer function
 */
const reducer = (config) => {

  if (!config) throw new Error('clerk.reducer: Expected config')
  if (!config.actionPrefix) throw new Error('clerk.reducer: Expected actionPrefix')
  if (!config.uidField) throw new Error('clerk.reducer: Expected uidField')

  // Generate action names for create, fetch, update, delete
  const createActions = generateActionNames(config.actionPrefix, 'create')
  const fetchActions = generateActionNames(config.actionPrefix, 'fetch')
  const updateActions = generateActionNames(config.actionPrefix, 'update')
  const deleteActions = generateActionNames(config.actionPrefix, 'delete')

  const defaultState = Immutable.fromJS({

    // raw: Contains raw data objects
    // {
    //   123: { ... },
    //   234: { ... }
    // }
    raw: {}
  })

  // Clerk reducer
  return (state = new Map({}), action) => {

    // Extend existing state
    // This comes into play when clerk is used to extend an existing reducer
    state = state.merge(defaultState)

    switch(action.type) {
      case fetchActions.success: return fetchReducer.success(state, action)
      case createActions.start: return createReducer.start(state, action)
      case updateActions.start: return updateReducer.start(state, action)
      case deleteActions.start: return deleteReducer.start(state, action)
      default: return state
    }
  }
}

export default reducer
<commit_msg>add cases for every action type<commit_after>import Immutable, { Map } from 'immutable'
import { generateActionNames } from './utils/actionNames'
import { createReducer, fetchReducer, updateReducer, deleteReducer } from './reducers'

/**
 * Creates a reducer with the provided config
 * @param  {Object} config - reducer configuration
 *
 * @return {Function} - Reducer function
 */
const reducer = (config) => {

  if (!config) throw new Error('clerk.reducer: Expected config')
  if (!config.actionPrefix) throw new Error('clerk.reducer: Expected actionPrefix')
  if (!config.uidField) throw new Error('clerk.reducer: Expected uidField')

  // Generate action names for create, fetch, update, delete
  const createActions = generateActionNames(config.actionPrefix, 'create')
  const fetchActions = generateActionNames(config.actionPrefix, 'fetch')
  const updateActions = generateActionNames(config.actionPrefix, 'update')
  const deleteActions = generateActionNames(config.actionPrefix, 'delete')

  const defaultState = Immutable.fromJS({

    // raw: Contains raw data objects
    // {
    //   123: { ... },
    //   234: { ... }
    // }
    raw: {}
  })

  // Clerk reducer
  return (state = new Map({}), action) => {

    // Extend existing state
    // This comes into play when clerk is used to extend an existing reducer
    state = state.merge(defaultState)

    switch(action.type) {
      case fetchActions.start: return fetchReducer.start(state, action)
      case fetchActions.success: return fetchReducer.success(state, action)
      case fetchActions.error: return fetchReducer.error(state, action)
      case createActions.start: return createReducer.start(state, action)
      case createActions.success: return createReducer.success(state, action)
      case createActions.error: return createReducer.error(state, action)
      case updateActions.start: return updateReducer.start(state, action)
      case updateActions.success: return updateReducer.success(state, action)
      case updateActions.error: return updateReducer.error(state, action)
      case deleteActions.start: return deleteReducer.start(state, action)
      case deleteActions.success: return deleteReducer.success(state, action)
      case deleteActions.error: return deleteReducer.error(state, action)
      default: return state
    }
  }
}

export default reducer

{'fraction_non_alphanumeric': 0.10780487804878049, 'fraction_numerical': 0.002926829268292683, 'mean_word_length': 3.8937947494033414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4389871', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1119, 'n_words': 331}