lang/or.js

  1. import { apply } from 'core/apply'
  2. /**
  3. * Applies <code>||</code> between the former value and <code>args</code>
  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. * @param {...*} [args] Other operands.
  9. * @return {Object} Returns the updated object.
  10. * @example or({ nested: { prop: false } }, 'nested.prop', true) // { nested: { prop: true } }
  11. * @example or({ nested: { prop: true } }, 'nested.prop', false, false) // { nested: { prop: true } }
  12. * @since 1.0.0
  13. */
  14. const or = apply((v, ...args) => args.reduce((acc, arg) => acc || arg, v))
  15. export { or }