lang/add.js

  1. import { apply } from 'core/apply'
  2. /**
  3. * Replaces by the addition of the former number and the given number.
  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 {number} addend The number to add.
  9. * @return {Object} Returns the updated object.
  10. * @example add({ nested: { prop: 2 } }, 'nested.prop', 4) // => { nested: { prop: 6 } }
  11. * @since 1.0.0
  12. */
  13. const add = apply((value, addend) => Number(value) + Number(addend), { fixedArity: true })
  14. export { add }