From 2336ab9790c5472043f2b6ecc0c1d5563ef2f798 Mon Sep 17 00:00:00 2001 From: Yulii Zilnyk Date: Tue, 18 Jul 2023 13:38:54 +0300 Subject: [PATCH] moved all cases to the object --- src/transformState.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/transformState.js b/src/transformState.js index c4804b511..58e928bee 100644 --- a/src/transformState.js +++ b/src/transformState.js @@ -5,19 +5,25 @@ * @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: for (const key of action.keysToRemove) { delete state[key]; } break; - case 'clear': + case actionTypes.clear: for (const key in state) { delete state[key]; }