source: node_modules/ramda-adjunct/es/mergeProp.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1016 bytes
Line 
1import { curry, of } from 'ramda';
2import mergePath from './mergePath';
3
4/**
5 * Create a new object with the own properties of the object under the `p`
6 * merged with the own properties of the provided `source`.
7 * If a key exists in both objects, the value from the `source` object will be used.
8 *
9 * @func mergeProp
10 * @memberOf RA
11 * @since {@link https://char0n.github.io/ramda-adjunct/1.18.0|v1.18.0}
12 * @category Object
13 * @sig [k] -> {a} -> {k: {a}} -> {k: {a}}
14 * @see {@link RA.mergePath|mergePath}
15 * @param {!Array} p The property of the destination object
16 * @param {!Object} source The source object
17 * @param {!Object} obj The object that has destination object under corresponding property
18 * @return {!Object} The new version of object
19 * @example
20 *
21 * RA.mergeProp(
22 * 'outer',
23 * { foo: 3, bar: 4 },
24 * { outer: { foo: 2 } }
25 * ); //=> { outer: { foo: 3, bar: 4 } };
26 */
27var mergeProp = curry(function (p, subj, obj) {
28 return mergePath(of(Array, p), subj, obj);
29});
30export default mergeProp;
Note: See TracBrowser for help on using the repository browser.