UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

51 lines (48 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ramda = require("ramda"); /** * Groups values in the list by the property found by provided key. * * @func * @category Object * * @param Array prop * @param Array list * * @return Object An object with the output of determined by `prop` for keys, * mapped to arrays of elements that produced that key. * * @example * * R_.groupByProp("id")([ * { id: 1 }, * { id: 3 }, * { id: 1, name: "c" } * ]) * // -> * // { * // "1": [ * // { * // id: 1 * // }, * // { * // id: 1, * // name: "c" * // } * // ], * // "3": [ * // { * // id: 3 * // } * // ] * // } * * @sig String -> [a] -> {String -> [a]} */ var groupByProp = (0, _ramda.useWith)(_ramda.groupBy, [_ramda.prop, _ramda.identity]); var _default = groupByProp; exports.default = _default;