mergeAll.js 852 B

1234567891011121314151617181920212223242526272829
  1. import _objectAssign from "./internal/_objectAssign.js";
  2. import _curry1 from "./internal/_curry1.js";
  3. /**
  4. * Creates one new object with the own properties from a list of objects.
  5. * If a key exists in more than one object, the value from the last
  6. * object it exists in will be used.
  7. *
  8. * @func
  9. * @memberOf R
  10. * @since v0.10.0
  11. * @category List
  12. * @sig [{k: v}] -> {k: v}
  13. * @param {Array} list An array of objects
  14. * @return {Object} A merged object.
  15. * @see R.reduce
  16. * @example
  17. *
  18. * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
  19. * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}
  20. * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 }
  21. */
  22. var mergeAll =
  23. /*#__PURE__*/
  24. _curry1(function mergeAll(list) {
  25. return _objectAssign.apply(null, [{}].concat(list));
  26. });
  27. export default mergeAll;