{"ScriptPreparationCode":"var obj = {};\r\n\r\nfor (i = 1000; i \u003E 0; i--) {\r\n \tobj[i] = {\r\n container: {\r\n sm: {\r\n layout: [\u0027p-4\u0027],\r\n presentation: \u0027bg-blue-100\u0027,\r\n },\r\n md: [\u0027md:bg-green-100\u0027, \u0027md:p-6\u0027],\r\n lg: [\u0027lg:bg-yellow-100\u0027, \u0027lg:p-8\u0027],\r\n xl: [\u0027xl:bg-red-100\u0027, \u0027xl:p-10\u0027],\r\n xxl: \u0027xxl:bg-gray-100 xxl:p-12\u0027,\r\n },\r\n heading: {\r\n sm: [ \u0027bg-yellow-200\u0027, \u0027md:bg-green-200\u0027 ],\r\n md: ( ()=\u003E \u0027md:bg-yellow-200\u0027 )(),\r\n },\r\n paragraph: [\u0027bg-gray-300\u0027,\u0027p-12\u0027],\r\n box: \u0027bg-yellow-400\u0027,\r\n button: {},\r\n };\r\n}\r\n\r\n","TestCases":[{"Name":"Recursive outer","Code":"function rec(classList, key, collection = {} ) {\r\n\r\n return Object.values( collection ).reduce( (acc, col) =\u003E { \r\n const colCheck = Object.prototype.toString.call(col);\r\n\r\n switch (colCheck) {\r\n case \u0027[object Object]\u0027: {\r\n if ( Object.keys(col).length === 0 ) {\r\n acc[key] = \u0027\u0027;\r\n break;\r\n }\r\n rec(classList, key, col );\r\n break;\r\n }\r\n \r\n case \u0027[object Array]\u0027:\r\n acc[key] \u002B= col.join(\u0027 \u0027) \u002B \u0027 \u0027;\r\n break;\r\n \r\n case \u0027[object String]\u0027:\r\n acc[key] \u002B= col \u002B \u0027 \u0027;\r\n break;\r\n\r\n }\r\n\r\n return acc;\r\n\r\n }, classList );\r\n}\r\n\r\nfunction ClassList(collection = {}) {\r\n const keys = Object.keys(collection);\r\n \r\n return keys.reduce( (classList, key) =\u003E {\r\n switch (Object.prototype.toString.call(collection[key]) ) {\r\n case \u0027[object Object]\u0027: {\r\n classList[key] = \u0027\u0027;\r\n if ( Object.keys(collection[key]).length === 0 ) {\r\n break;\r\n }\r\n rec(classList, key, collection[key] );\r\n break;\r\n }\r\n \r\n case \u0027[object Array]\u0027:\r\n classList[key] = collection[key].join(\u0027 \u0027) \u002B \u0027 \u0027;\r\n break;\r\n \r\n case \u0027[object String]\u0027:\r\n classList[key] = collection[key] \u002B \u0027 \u0027;\r\n break;\r\n\r\n }\r\n\r\n return classList;\r\n\r\n }, {} );\r\n}\r\n\r\nClassList( obj );","IsDeferred":false},{"Name":"Recursive flatten (no trim)","Code":"function ClassList(collection = {}) {\r\n const result = {};\r\n\r\n function flatten(node, str) {\r\n const nodeType = Object.prototype.toString.call(node);\r\n \r\n switch (nodeType) {\r\n case \u0027[object String]\u0027: {\r\n str \u002B= node \u002B \u0027 \u0027;\r\n break;\r\n }\r\n case \u0027[object Array]\u0027: {\r\n str \u002B= node.join(\u0027 \u0027) \u002B \u0027 \u0027;\r\n break;\r\n }\r\n case \u0027[object Object]\u0027: {\r\n for (const key in node) {\r\n str \u002B= flatten(node[key], \u0027\u0027);\r\n }\r\n break;\r\n }\r\n }\r\n \r\n return str;\r\n }\r\n\r\n for (const key in collection) {\r\n result[key] = flatten(collection[key], \u0027\u0027);\r\n }\r\n\r\n return result;\r\n}\r\n\r\nClassList(obj);","IsDeferred":false}]}