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