parallel.js 726 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. var bach = require('bach');
  3. var metadata = require('./helpers/metadata');
  4. var buildTree = require('./helpers/buildTree');
  5. var normalizeArgs = require('./helpers/normalizeArgs');
  6. var createExtensions = require('./helpers/createExtensions');
  7. function parallel() {
  8. var create = this._settle ? bach.settleParallel : bach.parallel;
  9. var args = normalizeArgs(this._registry, arguments);
  10. var extensions = createExtensions(this);
  11. var fn = create(args, extensions);
  12. var name = '<parallel>';
  13. metadata.set(fn, {
  14. name: name,
  15. branch: true,
  16. tree: {
  17. label: name,
  18. type: 'function',
  19. branch: true,
  20. nodes: buildTree(args),
  21. },
  22. });
  23. return fn;
  24. }
  25. module.exports = parallel;