<commit_before>/*
 *
 * TodoInput reducer
 *
 */

import { fromJS } from 'immutable';
import {
  NEWTASK_ACTION,
} from './constants';
import {
  CHANGETASK_ACTION,
} from '../TodoList/constants';

const initialState = fromJS({
  taskList: []
});

function todoInputReducer(state = initialState, action) {
  switch (action.type) {
    case NEWTASK_ACTION:
      return state.set('taskList', [...state.get("taskList"), action.payload]);
    case CHANGETASK_ACTION:
      var taskList = state.get("taskList"),
          index = action.payload;
      /*if (taskList[index].done) taskList[index].done = false;
      else taskList[index].done = true;*/
      return state.set("taskList",
        [...taskList.slice(0, index), {name: taskList[index].name, done: true}, ...taskList.slice(index + 1)]);
    default:
      return state;
  }
}

export default todoInputReducer;
<commit_msg>And make a little bit pritier<commit_after>/*
 *
 * TodoInput reducer
 *
 */

import { fromJS } from 'immutable';
import {
  NEWTASK_ACTION,
} from './constants';
import {
  CHANGETASK_ACTION,
} from '../TodoList/constants';

const initialState = fromJS({
  taskList: []
});

function todoInputReducer(state = initialState, action) {
  switch (action.type) {
    case NEWTASK_ACTION:
      return state.set('taskList', [...state.get("taskList"), action.payload]);
    case CHANGETASK_ACTION:
      var taskList = state.get("taskList"),
          index = action.payload;
      return state.set("taskList",
        [...taskList.slice(0, index),
          {name: taskList[index].name, done: taskList[index].done ? false : true},
          ...taskList.slice(index + 1)]);
    default:
      return state;
  }
}

export default todoInputReducer;

{'fraction_non_alphanumeric': 0.15339918651946544, 'fraction_numerical': 0.002324230098779779, 'mean_word_length': 3.251851851851852, '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': '109713', 'n_tokens_mistral': 557, 'n_tokens_neox': 560, 'n_words': 122}