{"ScriptPreparationCode":"var data = [\r\n { name: \u0027pi\u0027, value: 3.14 },\r\n { name: \u0027hundred\u0027, value: 100 },\r\n { name: \u0027truthy\u0027, value: true },\r\n { name: \u0027falsy\u0027, value: false },\r\n { name: \u0027estring\u0027, value: \u00272.71828\u0027 },\r\n];\r\n\r\nvar partitionBy = (arr, key) =\u003E Object.values(arr.reduce((acc, item) =\u003E {\r\n var _a;\r\n return (Object.assign(Object.assign({}, acc), { [String(item[key])]: [...((_a = acc[String(item[key])]) !== null \u0026\u0026 _a !== void 0 ? _a : []), item] }));\r\n}, {}));\r\n\r\nvar partitionByForEach = (array, fn) =\u003E {\r\n var acc = {};\r\n _.forEach(array, (value) =\u003E {\r\n acc[fn(value)] = value;\r\n });\r\n return Object.values(acc);\r\n};\r\n\r\nvar partitionByForLoop = (array, fn) =\u003E {\r\n var acc = {};\r\n for (let i = 0; i \u003C array.length; i\u002B\u002B) {\r\n acc[fn(array[i])] = array[i];\r\n }\r\n return Object.values(acc);\r\n};","TestCases":[{"Name":"_.partitionBy(data, (v) =\u003E v.name);","Code":"_.partitionBy(data, (v) =\u003E v.name);","IsDeferred":false},{"Name":"partitionBy with native reduce","Code":"partitionBy(data, (v) =\u003E v.name);","IsDeferred":false},{"Name":"partitionBy with forEach","Code":"partitionByForEach(data, (v) =\u003E v.name);","IsDeferred":false},{"Name":"partitionBy with for loop","Code":"partitionByForLoop(data, (v) =\u003E v.name);","IsDeferred":false}]}