object/set.js

  1. import _set from 'lodash/fp/set'
  2. import { lodashFpConvert } from 'util/lodashFpConvert'
  3. /**
  4. * Sets the value at <code>path</code> of <code>object</code>.
  5. * This is the <code>lodash/fp</code> <code>set</code>, with no arguments rearranging and no currying.
  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 {*} value The value to set.
  11. * @return {Object} Returns the updated object.
  12. * @example set({ nested: { prop: 'old' } }, 'nested.prop', 'new') // => { nested: { prop: 'new' } }
  13. * @see {@link https://lodash.com/docs#set|lodash.set} for more information.
  14. * @since 0.1.5
  15. */
  16. const set = lodashFpConvert(_set)
  17. export { set, set as default }