{"ScriptPreparationCode":"var obj = {};\r\n\r\nfor (i = 1000; i \u003E 0; i--) {\r\n if (i%2 == 0) {\r\n \tobj[i] = \u0027String\u0027;\r\n } else {\r\n obj[i] = [ \u0027Array of String\u0027, \u0027Array of String\u0027 ];\r\n }\r\n}\r\n","TestCases":[{"Name":"forEach","Code":"function ClassList(collection={}) {\r\n const classNames = {};\r\n const keys = Object.keys(collection);\r\n\r\n keys.forEach((key) =\u003E {\r\n const innerCollection = collection[key];\r\n const collectionCheck = Object.prototype.toString.call(innerCollection);\r\n\r\n switch (collectionCheck) {\r\n case \u0027[object Object]\u0027: {\r\n const innerKeys = Object.keys(innerCollection);\r\n\r\n if (innerKeys.length === 0) {\r\n classNames[key] = \u0027\u0027;\r\n break;\r\n }\r\n\r\n let classList = [];\r\n innerKeys.forEach((innerKey) =\u003E {\r\n if (!innerCollection[innerKey] || !innerCollection[innerKey].length) {\r\n return;\r\n }\r\n\r\n const innerCollectionCheck = Object.prototype.toString.call(innerCollection[innerKey]);\r\n switch (innerCollectionCheck) {\r\n case \u0027[object Array]\u0027:\r\n classList.push(...innerCollection[innerKey]);\r\n break;\r\n\r\n case \u0027[object String]\u0027:\r\n classList.push(innerCollection[innerKey]);\r\n break;\r\n }\r\n });\r\n\r\n classNames[key] = classList.reduce((acc, cl) =\u003E (acc \u002B= cl \u002B \u0027 \u0027), \u0027\u0027);\r\n break;\r\n }\r\n\r\n case \u0027[object Array]\u0027:\r\n classNames[key] = innerCollection.reduce((acc, cl) =\u003E (acc \u002B= cl \u002B \u0027 \u0027), \u0027\u0027);\r\n break;\r\n\r\n case \u0027[object String]\u0027:\r\n classNames[key] = innerCollection;\r\n break;\r\n }\r\n });\r\n\r\n return classNames;\r\n}\r\n\r\nClassList( obj );","IsDeferred":false},{"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","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).trimEnd();\r\n }\r\n\r\n return result;\r\n}\r\n\r\nClassList(obj);","IsDeferred":false}]}