object/assign.js

  1. import assign from 'lodash/fp/assign'
  2. import { lodashFpConvertOptions } from '../consts'
  3. import update from '../object/update'
  4. const rawAssign = assign.convert(lodashFpConvertOptions)
  5. /**
  6. * Assigns own enumerable string keyed properties of source objects to the
  7. * destination object. Source objects are applied from left to right.
  8. * Subsequent sources overwrite property assignments of previous sources.
  9. * @function assign
  10. * @memberof object
  11. * @param {Object} object The object to modify.
  12. * @param {Array|string} path The path of the property to set.
  13. * @param {...Object} [sources] The source objects.
  14. * @return {Object} Returns the updated object.
  15. * @example assign({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 3, c: 4 } }
  16. * @see {@link object.update|update} for more information.
  17. * @see {@link https://lodash.com/docs#assign|lodash.assign} for more information.
  18. * @since 0.1.12
  19. */
  20. export default update(rawAssign)