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

12345678910111213141516171819202122232425262728293031
  1. var baseFlatten = require('./_baseFlatten'),
  2. map = require('./map');
  3. /** Used as references for various `Number` constants. */
  4. var INFINITY = 1 / 0;
  5. /**
  6. * This method is like `_.flatMap` except that it recursively flattens the
  7. * mapped results.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 4.7.0
  12. * @category Collection
  13. * @param {Array|Object} collection The collection to iterate over.
  14. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  15. * @returns {Array} Returns the new flattened array.
  16. * @example
  17. *
  18. * function duplicate(n) {
  19. * return [[[n, n]]];
  20. * }
  21. *
  22. * _.flatMapDeep([1, 2], duplicate);
  23. * // => [1, 1, 2, 2]
  24. */
  25. function flatMapDeep(collection, iteratee) {
  26. return baseFlatten(map(collection, iteratee), INFINITY);
  27. }
  28. module.exports = flatMapDeep;