Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233
  1. var baseUpdate = require('./_baseUpdate'),
  2. castFunction = require('./_castFunction');
  3. /**
  4. * This method is like `_.update` except that it accepts `customizer` which is
  5. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  6. * path creation is handled by the method instead. The `customizer` is invoked
  7. * with three arguments: (nsValue, key, nsObject).
  8. *
  9. * **Note:** This method mutates `object`.
  10. *
  11. * @static
  12. * @memberOf _
  13. * @since 4.6.0
  14. * @category Object
  15. * @param {Object} object The object to modify.
  16. * @param {Array|string} path The path of the property to set.
  17. * @param {Function} updater The function to produce the updated value.
  18. * @param {Function} [customizer] The function to customize assigned values.
  19. * @returns {Object} Returns `object`.
  20. * @example
  21. *
  22. * var object = {};
  23. *
  24. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  25. * // => { '0': { '1': 'a' } }
  26. */
  27. function updateWith(object, path, updater, customizer) {
  28. customizer = typeof customizer == 'function' ? customizer : undefined;
  29. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30. }
  31. module.exports = updateWith;