Skip to content

Commit

Permalink
Added a separate case for clear
Browse files Browse the repository at this point in the history
  • Loading branch information
andreysakhno committed Oct 17, 2023
1 parent 6041c1f commit 84afc72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/transformStateWithClones.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
function transformStateWithClones(state, actions) {
const result = [];
const currentState = { ...state };
let currentState = { ...state };

for (const action of actions) {
const { type, extraData, keysToRemove } = action;
Expand All @@ -22,8 +22,8 @@ function transformStateWithClones(state, actions) {
keysToRemove.forEach((key) => delete currentState[key]);
break;

default:
Object.keys(currentState).forEach((key) => delete currentState[key]);
case 'clear':
currentState = {};
}

result.push({ ...currentState });
Expand Down

0 comments on commit 84afc72

Please sign in to comment.