function groupBy(array, iteratee) {
  const result = Object.create(null);

  for (const value of array) {
    const key = iteratee(value);

    if (Array.isArray(result[key])) {
      result[key].push(value);
    } else {
      result[key] = [value];
    }
  }

  return result;
}
@template Obj
@template Key
@param {Array<Obj>} array
@param {(value: Obj) => Key} iteratee
@returns {{[p in Key]: T}}