AsyncParallelHook.js 877 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Hook = require("./Hook");
  7. const HookCodeFactory = require("./HookCodeFactory");
  8. class AsyncParallelHookCodeFactory extends HookCodeFactory {
  9. content({ onError, onDone }) {
  10. return this.callTapsParallel({
  11. onError: (i, err, done, doneBreak) => onError(err) + doneBreak(true),
  12. onDone
  13. });
  14. }
  15. }
  16. const factory = new AsyncParallelHookCodeFactory();
  17. const COMPILE = function(options) {
  18. factory.setup(this, options);
  19. return factory.create(options);
  20. };
  21. function AsyncParallelHook(args = [], name = undefined) {
  22. const hook = new Hook(args, name);
  23. hook.constructor = AsyncParallelHook;
  24. hook.compile = COMPILE;
  25. hook._call = undefined;
  26. hook.call = undefined;
  27. return hook;
  28. }
  29. AsyncParallelHook.prototype = null;
  30. module.exports = AsyncParallelHook;