Front end of the Slack clone application.

map.js 903B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = _asyncMap;
  6. var _noop = require('lodash/noop');
  7. var _noop2 = _interopRequireDefault(_noop);
  8. var _wrapAsync = require('./wrapAsync');
  9. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function _asyncMap(eachfn, arr, iteratee, callback) {
  12. callback = callback || _noop2.default;
  13. arr = arr || [];
  14. var results = [];
  15. var counter = 0;
  16. var _iteratee = (0, _wrapAsync2.default)(iteratee);
  17. eachfn(arr, function (value, _, callback) {
  18. var index = counter++;
  19. _iteratee(value, function (err, v) {
  20. results[index] = v;
  21. callback(err);
  22. });
  23. }, function (err) {
  24. callback(err, results);
  25. });
  26. }
  27. module.exports = exports['default'];