core/unset.js

  1. import { apply } from 'path/apply'
  2. const unsetOperation = (obj, prop) => { delete obj[prop] }
  3. /**
  4. * Removes the property at <code>path</code> of <code>object</code>.
  5. * @function
  6. * @memberof core
  7. * @param {Object} obj The object to modify.
  8. * @param {Array|string} path The path of the property to unset.
  9. * @return {Object} Returns the updated object.
  10. * @example unset({ nested: { prop: 'value' } }, 'nested.prop') // => { nested: {} }
  11. * @since 1.0.0
  12. */
  13. const unset = apply(unsetOperation)
  14. export { unset }