UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

36 lines (35 loc) 1.08 kB
import { converge, set } from 'ramda'; import headArg from './headArg'; import alwaysEmptyObject from './alwaysEmptyObject'; import viewWith from './viewWith'; /** * Firstly applies transformation on input data structure according to provided "lens". * Returning value is made by the "setting" the portion * of the result focused by the given `lens`. * * @func * @category Object * * * @param {Object} lens Lens * @param {function} tranformation Transformation function * @param {any} input * @returns {Object} Firstly applies transformation on `input` according to `lens` (`R.over`) * and than returning value is made by the "setting" (`R.set`) the portion * of previous result focused by the given `lens`. * * @example * * R_.objOfOver( * R.lensPath(['a', 'b']), * (x) => "Hello " + x, * { * a: { b: 'foo' }, * c: 'bar', * } * ) * // { a: { b: "Hello foo" } } * */ var objOfOver = /*#__PURE__*/converge(set, [headArg, viewWith, alwaysEmptyObject]); export default objOfOver;