<commit_before>import _ from 'lodash';

import { FETCH_POSTS, CREATE_POST, FETCH_POST } from '../actions';

export default function(state = {}, action) {
    switch (action.type) {
        case FETCH_POSTS:
            return _.mapKeys(action.payload.data, 'id');     
        case FETCH_POST:
            // ES 5:
            // const post = action.payload.data;
            // const newState = { ...state };
            // newState[post.id] = post;
            // return newState;

            // ES 6:
            const post = action.payload.data;
            return { ...state, [post.id]: post };
        case CREATE_POST:
            return state;
        default:
            return state;
    }
}<commit_msg>Section 150: Wrapup<commit_after>import _ from 'lodash';

import { FETCH_POSTS, CREATE_POST, FETCH_POST, DELETE_POST } from '../actions';

export default function(state = {}, action) {
    switch (action.type) {
        case FETCH_POSTS:
            return _.mapKeys(action.payload.data, 'id');     
        case FETCH_POST:
            // ES 5:
            // const post = action.payload.data;
            // const newState = { ...state };
            // newState[post.id] = post;
            // return newState;

            // ES 6:
            const post = action.payload.data;
            return { ...state, [post.id]: post };
        case DELETE_POST:
            return _.omit(state, action.payload);
        case CREATE_POST:
            return state;
        default:
            return state;
    }
}
{'fraction_non_alphanumeric': 0.12393442622950819, 'fraction_numerical': 0.0045901639344262295, 'mean_word_length': 1.5561139028475712, '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': '810366', 'n_tokens_mistral': 457, 'n_tokens_neox': 439, 'n_words': 108}