mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/partialObject.js
|
|
|
|
|
|
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)));
|