UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

38 lines (33 loc) 1.11 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ramda = require("ramda"); var _mapOver = _interopRequireDefault(require("./mapOver")); /** * Maps over a specific path on a list of objects, it returns a new list of objects * * @func * @category List * * @param {string[]} path The path to be modified. * @param {Function} fn The function to be called on every specified path element of the `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. * * @example * * const objs = [ * { value: { id: 1 } }, * { value: { id: 2 } }, * ]; * const valueLens = R.lensProp("value"); * R_.mapOverPath(["value", "id"], R.add(100), objs) // [{ value: { id: 101 } }, { value: { id: 102 } }] * * @sig string[] -> (* -> *) -> [object] -> [object] */ var mapOverPath = (0, _ramda.useWith)(_mapOver.default, [_ramda.lensPath, _ramda.identity, _ramda.identity]); var _default = mapOverPath; exports.default = _default;