lang/toggle.js

  1. import update from '../object/update'
  2. /**
  3. * Applies <code>!</code> to the property.
  4. * @function toggle
  5. * @memberof lang
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @return {Object} Returns the updated object.
  9. * @example toggle({ nested: { prop: true } }, 'nested.prop') // { nested: { prop: false } }
  10. * @see {@link object.update|update} for more information.
  11. * @since 0.1.5
  12. */
  13. export default update(v => !v)