{"ScriptPreparationCode":"var test = Array.from({\r\n length: 100000\r\n}, () =\u003E Math.random())\r\nfunction createGroupedArray(arr, chunkSize) {\r\n const groups = [];\r\n let i = 0;\r\n while (i \u003C arr.length) {\r\n groups.push(arr.slice(i, i \u002B= chunkSize));\r\n }\r\n return groups;\r\n};\r\n\r\nfunction createGroupedArray2(arr, chunkSize) {\r\n const groups = [];\r\n for (let i= 0; i \u003C arr.length; i\u002B\u002B)\r\n groups.push(arr.slice(i, i \u002B= chunkSize));\r\n \r\n return groups;\r\n};\r\n\r\n\r\nfunction array_to_chunks(data, size){\r\n let chunks = []\r\n let d = data.slice()\r\n while (d.length \u003E= size) chunks.push(d.splice(0, size))\r\n return chunks\r\n}\r\n\r\nfunction chunk_ymnn(arr, chunkSize = 1, cache = []) {\r\n const tmp = [...arr]\r\n if (chunkSize \u003C= 0) return cache\r\n while (tmp.length) cache.push(tmp.splice(0, chunkSize))\r\n return cache\r\n}\r\n\r\nfunction chunkBucket(arr, size) {\r\n let buckets = []\r\n\r\n // Just create the buckets/chunks storage\r\n for (let i = 1; i \u003C= Math.ceil(arr.length / size); i\u002B\u002B) {\r\n buckets.push([])\r\n }\r\n\r\n // Put in the buckets/storage by index access only\r\n for (let i = 0; i \u003C arr.length; i\u002B\u002B) {\r\n var arrIndex = Math.ceil((i \u002B 1) / size) - 1\r\n buckets[arrIndex].push(arr[i])\r\n }\r\n\r\n return buckets;\r\n}","TestCases":[{"Name":"Lodash","Code":"_.chunk(test,5000)","IsDeferred":false},{"Name":"slice","Code":"createGroupedArray(test,5000)","IsDeferred":false},{"Name":"push","Code":"array_to_chunks(test,5000)","IsDeferred":false},{"Name":"you might not need","Code":"chunk_ymnn(test,5000)","IsDeferred":false},{"Name":"bucket","Code":"chunkBucket(test,5000)","IsDeferred":false},{"Name":"slice for","Code":"createGroupedArray2(test, 5000)","IsDeferred":false}]}