lang/divide.js

  1. import { apply } from 'core/apply'
  2. /**
  3. * Replaces by the division 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} divisor The second number in the division.
  9. * @return {Object} Returns the updated object.
  10. * @example divide({ nested: { prop: 1332 } }, 'nested.prop', 2) // => { nested: { prop: 666 } }
  11. * @since 1.0.0
  12. */
  13. const divide = apply((value, divider) => Number(value) / Number(divider), { fixedArity: true })
  14. export { divide }