<commit_before>import {handleActions, createAction} from 'redux-actions';

// An array to store notifications object
const INITIAL_DATA = [];
// Action types
const NOTIFICATION_ADD = 'NOTIFICATION_ADD';
const NOTIFICATION_UPDATE = 'NOTIFICATION_UPDATE';
const NOTIFICATION_REMOVE = 'NOTIFICATION_REMOVE';

/**
 * Add a notification
 * @param {Object} notification
 * @returns {Object} notification
 */
export const addNotification = (notification) => {
  return (dispatch) => {
    notification.id = new Date().getTime();
    dispatch(pushNotification(notification));
    return notification;
  };
};

/**
 * Add a notification (Redux action)
 * @param {Object} notification
 * @returns {Object} notification
 */
const pushNotification = createAction(NOTIFICATION_ADD, (notification) => {
  return notification;
});

/**
 * Update a notification (Redux action)
 * @param {Object} notification
 * @returns {Object} notification
 */
export const updateNotification = createAction(NOTIFICATION_UPDATE, (notification) => {
  return notification;
});

/**
 * Remove a notification (Redux action)
 * @param {Number} notification id
 * @returns {Number} notification id
 */
export const removeNotification = createAction(NOTIFICATION_REMOVE, (id) => id);

// Actions
export const actions = {
  pushNotification: pushNotification,
  updateNotification: updateNotification,
  removeNotification: removeNotification
};

// Actions
export const types = {
  NOTIFICATION_ADD: NOTIFICATION_ADD,
  NOTIFICATION_UPDATE: NOTIFICATION_UPDATE,
  NOTIFICATION_REMOVE: NOTIFICATION_REMOVE
};

// Reducers
export default handleActions({
  [NOTIFICATION_ADD]: (state, {payload}) => {
    return [...state, payload];
  },
  [NOTIFICATION_UPDATE]: (state, {payload}) => {
    // get index of the notification
    const index = state.findIndex((notification) => {
      return notification.id === payload.id;
    });
    // replace the old notification by the new one
    state[index] = payload;
    return [...state];
  },
  [NOTIFICATION_REMOVE]: (state, {payload}) => {
    return state.filter((notification) => notification.id !== payload);
  }
}, INITIAL_DATA);
<commit_msg>udpate notification action types<commit_after>import {handleActions, createAction} from 'redux-actions';

// An array to store notifications object
const INITIAL_DATA = [];
// Action types
const ADD_NOTIFICATION = 'ADD_NOTIFICATION';
const UPDATE_NOTIFICATION = 'UPDATE_NOTIFICATION';
const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION';

/**
 * Add a notification
 * @param {Object} notification
 * @returns {Object} notification
 */
export const addNotification = (notification) => {
  return (dispatch) => {
    notification.id = new Date().getTime();
    dispatch(pushNotification(notification));
    return notification;
  };
};

/**
 * Add a notification (Redux action)
 * @param {Object} notification
 * @returns {Object} notification
 */
const pushNotification = createAction(ADD_NOTIFICATION, (notification) => {
  return notification;
});

/**
 * Update a notification (Redux action)
 * @param {Object} notification
 * @returns {Object} notification
 */
export const updateNotification = createAction(UPDATE_NOTIFICATION, (notification) => {
  return notification;
});

/**
 * Remove a notification (Redux action)
 * @param {Number} notification id
 * @returns {Number} notification id
 */
export const removeNotification = createAction(REMOVE_NOTIFICATION, (id) => id);

// Actions
export const actions = {
  pushNotification: pushNotification,
  updateNotification: updateNotification,
  removeNotification: removeNotification
};

// Actions
export const types = {
  ADD_NOTIFICATION: ADD_NOTIFICATION,
  UPDATE_NOTIFICATION: UPDATE_NOTIFICATION,
  REMOVE_NOTIFICATION: REMOVE_NOTIFICATION
};

// Reducers
export default handleActions({
  [ADD_NOTIFICATION]: (state, {payload}) => {
    return [...state, payload];
  },
  [UPDATE_NOTIFICATION]: (state, {payload}) => {
    // get index of the notification
    const index = state.findIndex((notification) => {
      return notification.id === payload.id;
    });
    // replace the old notification by the new one
    state[index] = payload;
    return [...state];
  },
  [REMOVE_NOTIFICATION]: (state, {payload}) => {
    return state.filter((notification) => notification.id !== payload);
  }
}, INITIAL_DATA);

{'fraction_non_alphanumeric': 0.12572220938294432, 'fraction_numerical': 0.0, 'mean_word_length': 4.679790026246719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '3085356', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1201, 'n_words': 329}