ramda
Version:
A practical functional library for JavaScript programmers.
36 lines • 1.46 kB
JavaScript
var mergeDeepRight = /*#__PURE__*/require("./mergeDeepRight.js");
var _curry2 = /*#__PURE__*/require("./internal/_curry2.js");
/**
* Takes a function `f` and an object, and returns a function `g`.
* When applied, `g` returns the result of applying `f` to the object
* provided initially merged deeply (right) with the object provided as an argument to `g`.
*
* @func
* @memberOf R
* @since v0.28.0
* @category Function
* @sig (({ a, b, c, ..., n }) -> x) -> { a, b, c, ...} -> ({ d, e, f, ..., n } -> x)
* @param {Function} f
* @param {Object} props
* @return {Function}
* @see R.partial, R.partialRight, R.curry, R.mergeDeepRight
* @example
*
* const multiply2 = ({ a, b }) => a * b;
* const double = R.partialObject(multiply2, { a: 2 });
* double({ b: 2 }); //=> 4
*
* const greet = ({ salutation, title, firstName, lastName }) =>
* salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
*
* const sayHello = R.partialObject(greet, { salutation: 'Hello' });
* const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' });
* sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!'
* @symb R.partialObject(f, { a, b })({ c, d }) = f({ a, b, c, d })
*/
var partialObject = /*#__PURE__*/_curry2(function partialObject(f, o) {
return function _partialObject(props) {
return f(mergeDeepRight(o, props));
};
});
module.exports = partialObject;