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

map.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _doParallel = require('./internal/doParallel');
  6. var _doParallel2 = _interopRequireDefault(_doParallel);
  7. var _map = require('./internal/map');
  8. var _map2 = _interopRequireDefault(_map);
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. /**
  11. * Produces a new collection of values by mapping each value in `coll` through
  12. * the `iteratee` function. The `iteratee` is called with an item from `coll`
  13. * and a callback for when it has finished processing. Each of these callback
  14. * takes 2 arguments: an `error`, and the transformed item from `coll`. If
  15. * `iteratee` passes an error to its callback, the main `callback` (for the
  16. * `map` function) is immediately called with the error.
  17. *
  18. * Note, that since this function applies the `iteratee` to each item in
  19. * parallel, there is no guarantee that the `iteratee` functions will complete
  20. * in order. However, the results array will be in the same order as the
  21. * original `coll`.
  22. *
  23. * If `map` is passed an Object, the results will be an Array. The results
  24. * will roughly be in the order of the original Objects' keys (but this can
  25. * vary across JavaScript engines).
  26. *
  27. * @name map
  28. * @static
  29. * @memberOf module:Collections
  30. * @method
  31. * @category Collection
  32. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  33. * @param {AsyncFunction} iteratee - An async function to apply to each item in
  34. * `coll`.
  35. * The iteratee should complete with the transformed item.
  36. * Invoked with (item, callback).
  37. * @param {Function} [callback] - A callback which is called when all `iteratee`
  38. * functions have finished, or an error occurs. Results is an Array of the
  39. * transformed items from the `coll`. Invoked with (err, results).
  40. * @example
  41. *
  42. * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
  43. * // results is now an array of stats for each file
  44. * });
  45. */
  46. exports.default = (0, _doParallel2.default)(_map2.default);
  47. module.exports = exports['default'];