{"ScriptPreparationCode":"const create = () =\u003E console.log(\u0022Creating\u0022);\r\nconst find = () =\u003E console.log(\u0022Finding\u0022);\r\nconst index = () =\u003E console.log(\u0022Indexing\u0022);\r\nconst update = () =\u003E console.log(\u0022Updating\u0022);\r\nconst destroy = () =\u003E console.log(\u0022Destroying\u0022);\r\n\r\nconst actionNames = {\r\n\tCREATE: \u0022CREATE\u0022,\r\n \tFIND: \u0022FIND\u0022,\r\n \tINDEX: \u0022INDEX\u0022,\r\n \tUPDATE: \u0022UPDATE\u0022,\r\n \tDESTROY: \u0022DESTROY\u0022,\r\n}\r\n\r\nconst actions = new Map([\r\n\t[actionNames.CREATE, create],\r\n \t[actionNames.FIND, find],\r\n \t[actionNames.INDEX, index],\r\n \t[actionNames.UPDATE, update],\r\n \t[actionNames.DESTROY, destroy],\r\n]);\r\n\r\nconst actionsObject = {\r\n \t[actionNames.CREATE]: create,\r\n \t[actionNames.FIND]: find,\r\n \t[actionNames.INDEX]: index,\r\n \t[actionNames.UPDATE]: update,\r\n \t[actionNames.DESTROY]: destroy,\r\n}\r\n\r\nfunction mapDispatch({actionName, payload}) {\r\n const action = actionsObject[actionName];\r\n \r\n if(action === undefined) return;\r\n \r\n return action(payload);\r\n}\r\n\r\nfunction objectDispatch({actionName, payload}) {\r\n const action = actions.get(actionName);\r\n \r\n if(action === undefined) return;\r\n \r\n return action(payload);\r\n}\r\n\r\nfunction switchDispatch({actionName, payload}) {\r\n switch(actionName) {\r\n case actionNames.CREATE:\r\n return create(payload);\r\n case actionNames.FIND:\r\n return find(payload);\r\n case actionNames.INDEX:\r\n return index(payload);\r\n case actionNames.UPDATE:\r\n return update(payload);\r\n case actionNames.DESTROY:\r\n return destroy(payload);\r\n default:\r\n return;\r\n }\r\n}\r\n\r\nvar randomActions = [actionNames.DESTROY, actionNames.CREATE, actionNames.DESTROY, actionNames.FIND, actionNames.CREATE, actionNames.FIND, actionNames.CREATE, actionNames.UPDATE]\r\n\r\n","TestCases":[{"Name":"mapDispatch","Code":"for(const action of randomActions) {\r\n\tmapDispatch({actionName: action, payload: {}});\r\n}","IsDeferred":false},{"Name":"objectDispatch","Code":"for(const action of randomActions) {\r\n objectDispatch({actionName: action, payload: {}});\r\n}","IsDeferred":false},{"Name":"switchDispatch","Code":"for(const action of randomActions) {\r\n switchDispatch({actionName: action, payload: {}});\r\n}","IsDeferred":false}]}