UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

35 lines (32 loc) 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ramda = require("ramda"); /** * Maps over a specific property on a list of objects, it returns a new list of objects * * @func * @category List * * @param {Lens} lens * @param {Function} fn The function to be called on every specified property element of the `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. * * @example * * const objs = [ * { value: 1 }, * { value: 2 }, * { value: 3 }, * ]; * const valueLens = R.lensProp("value"); * R_.mapOver(valueLens, R.add(100), objs) // [{ value: 101 }, { value: 102 }, { value: 103 }] * * @sig Lens s a -> (* -> *) -> [object] -> [object] */ var mapOver = (0, _ramda.uncurryN)(3, (0, _ramda.compose)(_ramda.map, (0, _ramda.binary)(_ramda.over))); var _default = mapOver; exports.default = _default;