Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sMishas committed Mar 12, 2024
1 parent 31b825e commit 06d77f5
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@
* @param {Object[]} actions
*/
function transformState(state, actions) {
for (const obj of actions) {
if (obj.type === 'addProperties') {
for (const i in obj.extraData) {
state[i] = obj.extraData[i];
}
}
for (const action of actions) {
switch (action.type) {
case 'addProperties':
Object.assign(state, action.extraData);
break;

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

if (obj.type === 'removeProperties') {
for (const i of obj.keysToRemove) {
if (state[i]) {
case 'clear':
for (const i in state) {
delete state[i];
}
}
}
break;

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

Expand Down

0 comments on commit 06d77f5

Please sign in to comment.