object/merge.js

  1. import { merge as _merge } from 'lodash/fp'
  2. import { convertLodashFp } from 'util/convertLodashFp'
  3. /**
  4. * Replaces by an object deeply merging own enumerable string keyed properties of source objects to the former object.<br />
  5. * Source objects are applied from left to right. Subsequent sources overwrite properties of previous sources.
  6. * @function
  7. * @memberof object
  8. * @param {Object} object The object to modify.
  9. * @param {Array|string} path The path of the property to set.
  10. * @param {...Object} [sources] The source objects.
  11. * @return {Object} Returns the updated object.
  12. * @example merge({ nested: { prop: { a: 1 } } }, 'nested', { prop: { a: 2, b: 3 } }) // => { nested: { prop: { a: 2, b: 3 } } }
  13. * @see {@link https://lodash.com/docs#merge|lodash.merge} for more information.
  14. * @since 1.0.0
  15. */
  16. const merge = convertLodashFp(_merge)
  17. export { merge }