diff --git a/package.json b/package.json index e83fa6dc..55e4ae2d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "license": "GPL-3.0", "devDependencies": { "@mate-academy/eslint-config": "*", - "@mate-academy/scripts": "^0.3.5", + "@mate-academy/scripts": "^1.2.8", "eslint": "^5.16.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", diff --git a/src/transformState.js b/src/transformState.js index a1eaa064..87f0bc5b 100644 --- a/src/transformState.js +++ b/src/transformState.js @@ -5,7 +5,27 @@ * @param {Object[]} actions */ function transformState(state, actions) { - // write code here + for (const keys of actions) { + switch (keys.type) { + case 'addProperties' : + Object.assign(state, keys.extraData); + + break; + case 'removeProperties' : + for (const removing of keys.keysToRemove) { + delete state[removing]; + } + + break; + + case 'clear' : + for (const stateKeys in state) { + delete state[stateKeys]; + } + } + } + + return state; } module.exports = transformState;