{"ScriptPreparationCode":"var str = \u0027style\u0027;\r\nvar obj = {\r\n \t \u0027style-2\u0027: true,\r\n \t \u0027style-3\u0027: false,\r\n \t \u0027style-4\u0027: true,\r\n}\r\nvar arr = [\u0027style-5\u0027, \u0027style-6\u0027]","TestCases":[{"Name":"classnames","Code":"let result = window.classNames(str, obj, arr, \u0027test classname\u0027)","IsDeferred":false},{"Name":"clsx","Code":"let result = window.clsx(str, obj, arr, \u0027test classname\u0027)","IsDeferred":false},{"Name":"Array based","Code":"function ts(...args){\r\n let template = [];\r\n args.forEach(arg =\u003E {\r\n \tif (typeof arg === \u0027string\u0027) {\r\n template.push(arg); \r\n return; \r\n }\r\n \r\n \tif (arg.join) {\r\n template = [...template, ...arg]; \r\n return;\r\n }\r\n \r\n let entries = Object.entries(arg);\r\n if (entries.length) {\r\n entries.forEach(entry =\u003E {\r\n if(entry[1]) template.push(entry[0]) \r\n })\r\n }\r\n })\r\n return template.join(\u0027 \u0027);\r\n}\r\nlet result = ts(str, obj, arr, \u0027test classname\u0027)","IsDeferred":false},{"Name":"String based (return struct)","Code":"function ts(...args){\r\n let template = \u0027\u0027;\r\n args.forEach(arg =\u003E {\r\n \tif (typeof arg === \u0027string\u0027) { \r\n template \u002B= \u0027 \u0027\u002Barg;\r\n return; \r\n }\r\n \tif (arg.join) { \r\n arg.forEach((e) =\u003E { \r\n template \u002B= \u0027 \u0027 \u002B e; \r\n }) \r\n return;\r\n }\r\n let entries = Object.entries(arg);\r\n if (entries.length) {\r\n entries.forEach(entry =\u003E {\r\n if(entry[1]) template \u002B= \u0027 \u0027 \u002B entry[0]\r\n })\r\n }\r\n })\r\n return template;\r\n}\r\nlet result = ts(str, obj, arr, \u0027test classname\u0027)","IsDeferred":false},{"Name":"String based (if-else struct)","Code":"function ts(...args){\r\n let template = \u0027\u0027;\r\n args.forEach(arg =\u003E {\r\n \tif (typeof arg === \u0027string\u0027) { \r\n template \u002B= \u0027 \u0027\u002Barg;\r\n } else if (arg.join) { \r\n arg.forEach((e) =\u003E { \r\n template \u002B= \u0027 \u0027 \u002B e; \r\n }) \r\n } else {\r\n let entries = Object.entries(arg);\r\n if (entries.length) {\r\n entries.forEach(entry =\u003E {\r\n if(entry[1]) template \u002B= \u0027 \u0027 \u002B entry[0]\r\n })\r\n }\r\n }\r\n })\r\n return template;\r\n}\r\nlet result = ts(str, obj, arr, \u0027test classname\u0027)","IsDeferred":false},{"Name":"Entries, filter, map, join","Code":"let objStyle = Object.entries(obj).filter((style)=\u003Estyle[1]).map(style =\u003E style[0]).join(\u0027 \u0027);\r\nlet arrComb = arr.join(\u0027 \u0027)\r\nlet result = \u0060${str} ${objStyle} ${arrComb} test classname\u0060","IsDeferred":false},{"Name":"Flat array join","Code":"const cn = (...classnames) =\u003E classnames.flat().filter(Boolean).join(\u0022 \u0022);\r\n\r\nlet result = cn(\u0027style\u0027, true, false, null, \u0027style-4\u0027, [\u0027style-5\u0027, \u0027style-6\u0027])","IsDeferred":false}]}