36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
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
|
|
* @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((f, o) => props => f.call(this, mergeDeepRight(o, props)));
|
|
|
|
export default partialObject; |