AsyncSeriesLoopHook.js 761 B

123456789101112131415161718192021222324252627282930313233
  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. class AsyncSeriesLoopHook extends Hook {
  18. constructor(args) {
  19. super(args);
  20. this.call = this._call = undefined;
  21. }
  22. compile(options) {
  23. factory.setup(this, options);
  24. return factory.create(options);
  25. }
  26. }
  27. module.exports = AsyncSeriesLoopHook;