"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const curry_1 = require("@arrows/composition/curry");
const _groupBy_ = (groupingFn, arr) => {
    const groups = {};
    arr.forEach((item) => {
        const key = groupingFn(item);
        if (groups[key] !== undefined) {
            groups[key].push(item);
        }
        else {
            groups[key] = [item];
        }
    });
    return groups;
};
/**
 * Creates an object that groups array items
 * by field specified by grouping functions.
 *
 * @param groupingFn Grouping function
 * @param arr Initial array of objects
 * @returns New array
 */
const groupBy_ = curry_1.default(_groupBy_);
exports.groupBy_ = groupBy_;
exports.default = groupBy_;
