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

_baseInverter.js 736B

123456789101112131415161718192021
  1. var baseForOwn = require('./_baseForOwn');
  2. /**
  3. * The base implementation of `_.invert` and `_.invertBy` which inverts
  4. * `object` with values transformed by `iteratee` and set by `setter`.
  5. *
  6. * @private
  7. * @param {Object} object The object to iterate over.
  8. * @param {Function} setter The function to set `accumulator` values.
  9. * @param {Function} iteratee The iteratee to transform values.
  10. * @param {Object} accumulator The initial inverted object.
  11. * @returns {Function} Returns `accumulator`.
  12. */
  13. function baseInverter(object, setter, iteratee, accumulator) {
  14. baseForOwn(object, function(value, key, object) {
  15. setter(accumulator, iteratee(value), key, object);
  16. });
  17. return accumulator;
  18. }
  19. module.exports = baseInverter;