core/set.js

  1. import { apply } from './apply'
  2. /**
  3. * Sets the value at <code>path</code> of <code>obj</code>.
  4. * @memberof core
  5. * @param {*} obj The object to modify.
  6. * @param {string|Array} path The path of the property to set.
  7. * @param {*} value The value to set.
  8. * @return {*} Returns the updated object.
  9. * @example set({ nested: { prop: 'old' } }, 'nested.prop', 'new') // => { nested: { prop: 'new' } }
  10. * @since 1.0.0
  11. */
  12. const set = apply((_, value) => value, { fixedArity: true })
  13. export { set }