<commit_before>const initialState = {
	data: null,
	menus: [],
	lastUpdated: 0,
	lookup: null
};

function dining(state = initialState, action) {
	const newState = { ...state };

	switch (action.type) {
	case 'SET_DINING': {
		// create a lookup object for restaurant IDs
		const newLookup = {};

		for (let i = 0; i < action.data.length; i++) {
			newLookup[action.data[i].id] = i;
		}

		return Object.assign({}, newState, {
			data: action.data,
			lastUpdated: new Date().getTime(),
			lookup: newLookup
		});
	}
	case 'SET_DINING_MENU': {
		const newMenusArray = newState.menus;

		newMenusArray[action.id] = action.data;
		newMenusArray[action.id].lastUpdated = new Date().getTime();

		newState.menus = newMenusArray;
		return newState;
	}
	default:
		return state;
	}
}

module.exports = dining;<commit_msg>Handle null menus<commit_after>const initialState = {
	data: null,
	menus: [],
	lastUpdated: 0,
	lookup: null
};

function dining(state = initialState, action) {
	const newState = { ...state };

	switch (action.type) {
	case 'SET_DINING': {
		// create a lookup object for restaurant IDs
		const newLookup = {};

		for (let i = 0; i < action.data.length; i++) {
			newLookup[action.data[i].id] = i;
		}

		return Object.assign({}, newState, {
			data: action.data,
			lastUpdated: new Date().getTime(),
			lookup: newLookup
		});
	}
	case 'SET_DINING_MENU': {
		const newMenusArray = newState.menus;

		newMenusArray[action.id] = action.data;
		if (newMenusArray[action.id]) {
			newMenusArray[action.id].lastUpdated = new Date().getTime();
		}

		newState.menus = newMenusArray;
		return newState;
	}
	default:
		return state;
	}
}

module.exports = dining;
{'fraction_non_alphanumeric': 0.14763897190675435, 'fraction_numerical': 0.002390914524805738, 'mean_word_length': 3.6629526462395545, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3704752', 'n_tokens_mistral': 660, 'n_tokens_neox': 596, 'n_words': 137}