You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

4 years ago
  1. import _curry3 from "./internal/_curry3.js";
  2. import mergeDeepWithKey from "./mergeDeepWithKey.js";
  3. /**
  4. * Creates a new object with the own properties of the two provided objects.
  5. * If a key exists in both objects:
  6. * - and both associated values are also objects then the values will be
  7. * recursively merged.
  8. * - otherwise the provided function is applied to associated values using the
  9. * resulting value as the new value associated with the key.
  10. * If a key only exists in one object, the value will be associated with the key
  11. * of the resulting object.
  12. *
  13. * @func
  14. * @memberOf R
  15. * @since v0.24.0
  16. * @category Object
  17. * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
  18. * @param {Function} fn
  19. * @param {Object} lObj
  20. * @param {Object} rObj
  21. * @return {Object}
  22. * @see R.mergeWith, R.mergeDeepWithKey
  23. * @example
  24. *
  25. * R.mergeDeepWith(R.concat,
  26. * { a: true, c: { values: [10, 20] }},
  27. * { b: true, c: { values: [15, 35] }});
  28. * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
  29. */
  30. var mergeDeepWith =
  31. /*#__PURE__*/
  32. _curry3(function mergeDeepWith(fn, lObj, rObj) {
  33. return mergeDeepWithKey(function (k, lVal, rVal) {
  34. return fn(lVal, rVal);
  35. }, lObj, rObj);
  36. });
  37. export default mergeDeepWith;