Skip to main content
Module

x/ramda/source/partialObject.js

:ram: Practical functional Javascript
Latest
File
import mergeDeepRight from './mergeDeepRight.js';import _curry2 from './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 * @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 }) */
export default _curry2((f, o) => (props) => f.call(this, mergeDeepRight(o, props)));