ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
51 lines (48 loc) • 1.03 kB
JavaScript
;
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 path.
*
* @func
* @category Object
*
* @param Array path
* @param Array list
*
* @return Object An object with the output of determined by `path` for keys,
* mapped to arrays of elements that produced that key.
*
* @example
*
* R_.groupByPath(["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 groupByPath = (0, _ramda.useWith)(_ramda.groupBy, [_ramda.path, _ramda.identity]);
var _default = groupByPath;
exports.default = _default;