Skip to main content
Module

x/ramda/source/mergeAll.js

:ram: Practical functional Javascript
Latest
File
import _objectAssign from './internal/_objectAssign.js';import _curry1 from './internal/_curry1.js';

/** * Creates one new object with the own properties from a list of objects. * If a key exists in more than one object, the value from the last * object it exists in will be used. * * @func * @memberOf R * @since v0.10.0 * @category List * @sig [{k: v}] -> {k: v} * @param {Array} list An array of objects * @return {Object} A merged object. * @see R.reduce * @example * * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3} * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } */var mergeAll = _curry1(function mergeAll(list) { return _objectAssign.apply(null, [{}].concat(list));});export default mergeAll;