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