1 | import mergeDeepRight from "./mergeDeepRight.js";
|
---|
2 | import _curry2 from "./internal/_curry2.js";
|
---|
3 | /**
|
---|
4 | * Takes a function `f` and an object, and returns a function `g`.
|
---|
5 | * When applied, `g` returns the result of applying `f` to the object
|
---|
6 | * provided initially merged deeply (right) with the object provided as an argument to `g`.
|
---|
7 | *
|
---|
8 | * @func
|
---|
9 | * @memberOf R
|
---|
10 | * @since v0.28.0
|
---|
11 | * @category Function
|
---|
12 | * @sig (({ a, b, c, ..., n }) -> x) -> { a, b, c, ...} -> ({ d, e, f, ..., n } -> x)
|
---|
13 | * @param {Function} f
|
---|
14 | * @param {Object} props
|
---|
15 | * @return {Function}
|
---|
16 | * @see R.partial, R.partialRight, R.curry, R.mergeDeepRight
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * const multiply2 = ({ a, b }) => a * b;
|
---|
20 | * const double = R.partialObject(multiply2, { a: 2 });
|
---|
21 | * double({ b: 2 }); //=> 4
|
---|
22 | *
|
---|
23 | * const greet = ({ salutation, title, firstName, lastName }) =>
|
---|
24 | * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
|
---|
25 | *
|
---|
26 | * const sayHello = R.partialObject(greet, { salutation: 'Hello' });
|
---|
27 | * const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' });
|
---|
28 | * sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!'
|
---|
29 | * @symb R.partialObject(f, { a, b })({ c, d }) = f({ a, b, c, d })
|
---|
30 | */
|
---|
31 |
|
---|
32 | var partialObject =
|
---|
33 | /*#__PURE__*/
|
---|
34 | _curry2((f, o) => props => f.call(this, mergeDeepRight(o, props)));
|
---|
35 |
|
---|
36 | export default partialObject; |
---|