AsyncSeriesHook.js 863 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 AsyncSeriesHookCodeFactory extends HookCodeFactory {
  9. content({ onError, onDone }) {
  10. return this.callTapsSeries({
  11. onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
  12. onDone
  13. });
  14. }
  15. }
  16. const factory = new AsyncSeriesHookCodeFactory();
  17. const COMPILE = function(options) {
  18. factory.setup(this, options);
  19. return factory.create(options);
  20. };
  21. function AsyncSeriesHook(args = [], name = undefined) {
  22. const hook = new Hook(args, name);
  23. hook.constructor = AsyncSeriesHook;
  24. hook.compile = COMPILE;
  25. hook._call = undefined;
  26. hook.call = undefined;
  27. return hook;
  28. }
  29. AsyncSeriesHook.prototype = null;
  30. module.exports = AsyncSeriesHook;