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

1234567891011121314151617181920212223242526272829
  1. var baseFlatten = require('./_baseFlatten'),
  2. map = require('./map');
  3. /**
  4. * Creates a flattened array of values by running each element in `collection`
  5. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  6. * with three arguments: (value, index|key, collection).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Collection
  12. * @param {Array|Object} collection The collection to iterate over.
  13. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14. * @returns {Array} Returns the new flattened array.
  15. * @example
  16. *
  17. * function duplicate(n) {
  18. * return [n, n];
  19. * }
  20. *
  21. * _.flatMap([1, 2], duplicate);
  22. * // => [1, 1, 2, 2]
  23. */
  24. function flatMap(collection, iteratee) {
  25. return baseFlatten(map(collection, iteratee), 1);
  26. }
  27. module.exports = flatMap;