{"ScriptPreparationCode":"var MAX_SAFE_INTEGER = 9007199254740991\r\n\r\nfunction arrayReduce(array, iteratee, accumulator, initAccum) {\r\n let index = -1\r\n const length = array == null ? 0 : array.length\r\n\r\n if (initAccum \u0026\u0026 length) {\r\n accumulator = array[\u002B\u002Bindex]\r\n }\r\n while (\u002B\u002Bindex \u003C length) {\r\n accumulator = iteratee(accumulator, array[index], index, array)\r\n }\r\n return accumulator\r\n}\r\n\r\n\r\nfunction baseFor(object, iteratee, keysFunc) {\r\n const iterable = Object(object)\r\n const props = keysFunc(object)\r\n let { length } = props\r\n let index = -1\r\n\r\n while (length--) {\r\n const key = props[\u002B\u002Bindex]\r\n if (iteratee(iterable[key], key, iterable) === false) {\r\n break\r\n }\r\n }\r\n return object\r\n}\r\n\r\nfunction isLength(value) {\r\n return typeof value === \u0027number\u0027 \u0026\u0026\r\n value \u003E -1 \u0026\u0026 value % 1 == 0 \u0026\u0026 value \u003C= MAX_SAFE_INTEGER\r\n}\r\n\r\nfunction isArrayLike(value) {\r\n return value != null \u0026\u0026 typeof value !== \u0027function\u0027 \u0026\u0026 isLength(value.length)\r\n}\r\n\r\n\r\nfunction baseForOwn(object, iteratee) {\r\n return object \u0026\u0026 baseFor(object, iteratee, keys)\r\n}\r\n\r\n\r\nfunction baseEach(collection, iteratee) {\r\n if (collection == null) {\r\n return collection\r\n }\r\n if (!isArrayLike(collection)) {\r\n return baseForOwn(collection, iteratee)\r\n }\r\n const length = collection.length\r\n const iterable = Object(collection)\r\n let index = -1\r\n\r\n while (\u002B\u002Bindex \u003C length) {\r\n if (iteratee(iterable[index], index, iterable) === false) {\r\n break\r\n }\r\n }\r\n return collection\r\n}\r\n\r\n\r\nfunction baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {\r\n eachFunc(collection, (value, index, collection) =\u003E {\r\n accumulator = initAccum\r\n ? (initAccum = false, value)\r\n : iteratee(accumulator, value, index, collection)\r\n })\r\n return accumulator\r\n}\r\n\r\n\r\nfunction reduce(collection, iteratee, accumulator) {\r\n const func = Array.isArray(collection) ? arrayReduce : baseReduce\r\n const initAccum = arguments.length \u003C 3\r\n return func(collection, iteratee, accumulator, initAccum, baseEach)\r\n}\r\n\r\n\r\nvar hasOwnProperty = Object.prototype.hasOwnProperty\r\n\r\nfunction baseAssignValue(object, key, value) {\r\n if (key == \u0027__proto__\u0027) {\r\n Object.defineProperty(object, key, {\r\n \u0027configurable\u0027: true,\r\n \u0027enumerable\u0027: true,\r\n \u0027value\u0027: value,\r\n \u0027writable\u0027: true\r\n })\r\n } else {\r\n object[key] = value\r\n }\r\n}\r\n\r\nfunction groupBy(collection, iteratee) {\r\n return reduce(collection, (result, value, key) =\u003E {\r\n key = iteratee(value)\r\n if (hasOwnProperty.call(result, key)) {\r\n result[key].push(value)\r\n } else {\r\n baseAssignValue(result, key, [value])\r\n }\r\n return result\r\n }, {})\r\n}\r\n\r\nvar n = 730;\r\nvar arr = [...Array(n)].map((_) =\u003E Math.random() * 10);\r\n\r\n","TestCases":[{"Name":"gp","Code":"const lm = groupBy(arr, Math.floor)","IsDeferred":false},{"Name":"map","Code":"const m = new Map();\r\n\r\nfor (const v of arr) {\r\n const k = Math.floor(v);\r\n const temp = m.get(k) ?? [];\r\n temp.push(v);\r\n m.set(k, temp)\r\n}","IsDeferred":false},{"Name":"reduce","Code":"const rm = arr.reduce((acc, v) =\u003E {\r\n const k = Math.floor(v);\r\n (acc[k] || (acc[k] = [])).push(v)\r\n return acc;\r\n}, {})","IsDeferred":false}]}