parallel.js 965 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _isArrayLike = require('./isArrayLike.js');
  6. var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
  7. var _wrapAsync = require('./wrapAsync.js');
  8. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  9. var _awaitify = require('./awaitify.js');
  10. var _awaitify2 = _interopRequireDefault(_awaitify);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. exports.default = (0, _awaitify2.default)((eachfn, tasks, callback) => {
  13. var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
  14. eachfn(tasks, (task, key, taskCb) => {
  15. (0, _wrapAsync2.default)(task)((err, ...result) => {
  16. if (result.length < 2) {
  17. [result] = result;
  18. }
  19. results[key] = result;
  20. taskCb(err);
  21. });
  22. }, err => callback(err, results));
  23. }, 3);
  24. module.exports = exports['default'];