{"ScriptPreparationCode":"var filters = [{\r\n name: \u0027operation\u0027,\r\n value: \u0027some value\u0027\r\n },\r\n {\r\n name: \u0027process\u0027,\r\n value: \u0027some value\u0027\r\n },\r\n {\r\n name: \u0027notUsed\u0027,\r\n value: \u0027slkjrklwejr\u0027\r\n },\r\n {\r\n name: \u0027position\u0027,\r\n value: \u00272\u0027\r\n },\r\n {\r\n name: \u0027multiChoise\u0027,\r\n value: [{\r\n value: \u0027FOO\u0027\r\n }, {\r\n value: \u0027BAR\u0027\r\n }]\r\n },\r\n];","TestCases":[{"Name":"Swtich \u002B spread","Code":"const query = filters.reduce((res, { name, value }) =\u003E {\r\n switch (name) {\r\n case \u0027position\u0027:\r\n return {\r\n ...res,\r\n position: Number(value),\r\n };\r\n case \u0027operation\u0027:\r\n case \u0027process\u0027:\r\n return {\r\n ...res,\r\n [name]: value,\r\n }; \r\n case \u0027multiChoise\u0027:\r\n return {\r\n ...res,\r\n multiChoise: value.map(({ value }) =\u003E value),\r\n };\r\n default: \r\n return res;\r\n }\r\n}, {});","IsDeferred":false},{"Name":"if/else","Code":"const strings = [\u0027operation\u0027, \u0027process\u0027];\r\n\r\nconst query = filters.reduce((res, { name, value }) =\u003E {\r\n if (name === \u0027position\u0027) {\r\n res.position = Number(value);\r\n } else if (name === \u0027multiChoise\u0027) {\r\n res.multiChoise = value.map(({ value }) =\u003E value);\r\n } else if (strings.includes(name)) {\r\n res[name] = value;\r\n }\r\n return res;\r\n}, {});","IsDeferred":false}]}