<commit_before>import { Map } from 'immutable'
import { EDIT_ROW, UPLOAD_DATA } from '../constants/ActionTypes'

function updateStateWithUpload(state, data) {
  for (let i = 0; i < data.size; i++) {
    const newDatum = data.get(i)
    const code = newDatum.get('code')

    state.set(code,
      state.get(code).set('value', newDatum.get('value'))
    )
  }
}

export default function regionData(state = Map(), action) {
  switch (action.type) {
    case EDIT_ROW: {
      const { regionCode, value } = action
      return state.update(regionCode, (item) => item.set('value', value))
    }

    case UPLOAD_DATA: {
      return state.withMutations((_state) =>
        updateStateWithUpload(_state, action.data))
    }

    default:
      return state
  }
}
<commit_msg>update regionData reducer - starts with empty data<commit_after>import { Map } from 'immutable'
import { EDIT_ROW, UPLOAD_DATA } from '../constants/ActionTypes'

import statesEmptyData from '../data/states-empty-data'

function updateEmptyData(emptyData, data) {
  for (let i = 0; i < data.size; i++) {
    const newDatum = data.get(i)
    const code = newDatum.get('code')

    emptyData.set(code,
      emptyData.get(code).set('value', newDatum.get('value'))
    )
  }
}

export default function regionData(state = Map(), action) {
  switch (action.type) {
    case EDIT_ROW: {
      const { regionCode, value } = action
      return state.update(regionCode, (item) => item.set('value', value))
    }

    case UPLOAD_DATA: {
      return statesEmptyData.withMutations((emptyData) =>
        updateEmptyData(emptyData, action.data))
    }

    default:
      return state
  }
}

{'fraction_non_alphanumeric': 0.13757575757575757, 'fraction_numerical': 0.0012121212121212121, 'mean_word_length': 3.211734693877551, 'pattern_counts': {'":': 0, '<': 5, '<?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': '748322', 'n_tokens_mistral': 536, 'n_tokens_neox': 539, 'n_words': 122}