series.js 597 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 buildSeries() {
  11. var args = helpers.verifyArguments(arguments);
  12. var extensions = helpers.getExtensions(last(args));
  13. if (extensions) {
  14. args = initial(args);
  15. }
  16. function series(done) {
  17. nowAndLater.mapSeries(args, iterator, extensions, done);
  18. }
  19. return series;
  20. }
  21. module.exports = buildSeries;