Skip to content

Commit

Permalink
Update transformState.js
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyrsar authored Jul 20, 2023
1 parent 3fb60a8 commit 5d351be
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
* @param {Object} state
* @param {Object[]} actions
*/
const actionTypes = {
addProperties: 'addProperties',
removeProperties: 'removeProperties',
clear: 'clear',
const ACTIONTYPES = {
addProperties: 'AddProperties',
removeProperties: 'RemoveProperties',
clear: 'Clear',
};

function transformState(state, actions) {
for (const action of actions) {
switch (action.type) {
case actionTypes.addProperties:
case ACTIONTYPES.addProperties:
Object.assign(state, action.extraData);
break;

case actionTypes.removeProperties:
case ACTIONTYPES.removeProperties:
for (const key of action.keysToRemove) {
delete state[key];
}
break;
case actionTypes.clear:
case ACTIONTYPES.clear:
for (const key in state) {
delete state[key];
};
Expand Down

0 comments on commit 5d351be

Please sign in to comment.