Skip to content

Commit

Permalink
Fix problems
Browse files Browse the repository at this point in the history
  • Loading branch information
AndruhaMan committed Jul 13, 2023
1 parent dfa9556 commit e3553d0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
* @param {Object[]} actions
*/
function transformState(state, actions) {
const actionTypes = {
addProperties: 'addProperties',
removeProperties: 'removeProperties',
clear: 'clear',
};

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

case 'removeProperties':
case actionTypes.removeProperties:
action.keysToRemove.forEach((key) => delete state[key]);
break;

case 'clear':
case actionTypes.clear:
Object.keys(state).forEach((key) => delete state[key]);
break;

Expand Down

0 comments on commit e3553d0

Please sign in to comment.