{"ScriptPreparationCode":null,"TestCases":[{"Name":"Vanilla Switch","Code":"function isFunc (v) {\r\n return typeof v === \u0027function\u0027;\r\n}\r\n\r\nfunction isDefined (v) {\r\n return v !== undefined \u0026\u0026 v !== null;\r\n}\r\n\r\nfunction switchEnum(e, handlers) {\r\n const specific = handlers[e];\r\n if (isDefined(specific)) {\r\n return isFunc(specific) ? specific(e) : specific;\r\n }\r\n\r\n if (isDefined(handlers.else)) {\r\n return isFunc(handlers.else) ? handlers.else(e) : handlers.else;\r\n }\r\n\r\n throw new Error(\u0060Unhandled switchEnum statement for value (${e}).\u0060);\r\n}\r\n\r\nfunction normal(inp) {\r\n switch (inp) {\r\n case \u0022today\u0022:\r\n return 1;\r\n case \u0022tomorrow\u0022:\r\n return 2;\r\n case \u0022yesterday\u0022:\r\n return -1;\r\n default:\r\n return 0;\t\r\n }\r\n};\r\n\r\nnormal(\u0027today\u0027);\r\nnormal(\u0027yesterday\u0027);\r\nnormal(\u0027tomorrow\u0027);","IsDeferred":false},{"Name":"Switch Fn style","Code":"function isFunc (v) {\r\n return typeof v === \u0027function\u0027;\r\n}\r\n\r\nfunction isDefined (v) {\r\n return v !== undefined \u0026\u0026 v !== null;\r\n}\r\n\r\nfunction switchEnum(e, handlers) {\r\n const specific = handlers[e];\r\n if (isDefined(specific)) {\r\n return isFunc(specific) ? specific(e) : specific;\r\n }\r\n\r\n if (isDefined(handlers.else)) {\r\n return isFunc(handlers.else) ? handlers.else(e) : handlers.else;\r\n }\r\n\r\n throw new Error(\u0060Unhandled switchEnum statement for value (${e}).\u0060);\r\n}\r\n\r\nfunction funcccy(inp) {\r\n return switchEnum(inp, {\r\n \u0022today\u0022: () =\u003E 1,\r\n \u0022tomorrow\u0022: () =\u003E 2,\r\n \u0022yesterday\u0022: () =\u003E -1,\r\n \u0022else\u0022: () =\u003E 0,\r\n });\r\n}\r\nfuncccy(\u0027today\u0027);\r\nfuncccy(\u0027yesterday\u0027);\r\nfuncccy(\u0027tomorrow\u0027);","IsDeferred":false}]}