lang/multiply.js

  1. import { convert } from 'core/convert'
  2. /**
  3. * Replaces by the multiplication 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} multiplicand The second number in the multiplication.
  9. * @return {Object} Returns the updated object.
  10. * @example multiply({ nested: { prop: 333 } }, 'nested.prop', 2) // => { nested: { prop: 666 } }
  11. * @since 1.0.0
  12. */
  13. const multiply = convert((value, multiplier) => Number(value) * Number(multiplier))
  14. export { multiply }