Skip to content

Commit

Permalink
switch case was used
Browse files Browse the repository at this point in the history
  • Loading branch information
SergS committed Aug 10, 2023
1 parent 433cb0f commit 48f255a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
*/
function transformState(state, actions) {
for (const action of actions) {
if (action.type === 'addProperties') {
Object.assign(state, action.extraData);
}
switch (action.type) {
case 'addProperties':
Object.assign(state, action.extraData);
break;

if (action.type === 'removeProperties') {
for (const key of action.keysToRemove) {
delete state[key];
}
}
case 'removeProperties':
for (const key of action.keysToRemove) {
delete state[key];
}
break;

if (action.type === 'clear') {
for (const key in state) {
delete state[key];
}
default:
for (const key in state) {
delete state[key];
}
}
}

Expand Down

0 comments on commit 48f255a

Please sign in to comment.