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