mergeWith.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import _curry3 from "./internal/_curry3.js";
  2. import mergeWithKey from "./mergeWithKey.js";
  3. /**
  4. * Creates a new object with the own properties of the two provided objects. If
  5. * a key exists in both objects, the provided function is applied to the values
  6. * associated with the key in each object, with the result being used as the
  7. * value associated with the key in the returned object.
  8. *
  9. * @func
  10. * @memberOf R
  11. * @since v0.19.0
  12. * @category Object
  13. * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
  14. * @param {Function} fn
  15. * @param {Object} l
  16. * @param {Object} r
  17. * @return {Object}
  18. * @see R.mergeDeepWith, R.merge, R.mergeWithKey
  19. * @example
  20. *
  21. * R.mergeWith(R.concat,
  22. * { a: true, values: [10, 20] },
  23. * { b: true, values: [15, 35] });
  24. * //=> { a: true, b: true, values: [10, 20, 15, 35] }
  25. */
  26. var mergeWith =
  27. /*#__PURE__*/
  28. _curry3(function mergeWith(fn, l, r) {
  29. return mergeWithKey(function (_, _l, _r) {
  30. return fn(_l, _r);
  31. }, l, r);
  32. });
  33. export default mergeWith;