lang/toggle.js

  1. import convert from '../util/convert'
  2. /**
  3. * Applies <code>!</code> to the property.
  4. * @function
  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. * @since 0.1.5
  11. */
  12. const toggle = convert(v => !v)
  13. export default toggle