parallel.js 599 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. var initial = require('array-initial');
  3. var last = require('array-last');
  4. var asyncDone = require('async-done');
  5. var nowAndLater = require('now-and-later');
  6. var helpers = require('./helpers');
  7. function iterator(fn, key, cb) {
  8. return asyncDone(fn, cb);
  9. }
  10. function buildParallel() {
  11. var args = helpers.verifyArguments(arguments);
  12. var extensions = helpers.getExtensions(last(args));
  13. if (extensions) {
  14. args = initial(args);
  15. }
  16. function parallel(done) {
  17. nowAndLater.map(args, iterator, extensions, done);
  18. }
  19. return parallel;
  20. }
  21. module.exports = buildParallel;