[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | const Hook = require("./Hook");
|
---|
| 8 | const HookCodeFactory = require("./HookCodeFactory");
|
---|
| 9 |
|
---|
| 10 | class SyncLoopHookCodeFactory extends HookCodeFactory {
|
---|
| 11 | content({ onError, onDone, rethrowIfPossible }) {
|
---|
| 12 | return this.callTapsLooping({
|
---|
| 13 | onError: (i, err) => onError(err),
|
---|
| 14 | onDone,
|
---|
| 15 | rethrowIfPossible
|
---|
| 16 | });
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | const factory = new SyncLoopHookCodeFactory();
|
---|
| 21 |
|
---|
| 22 | const TAP_ASYNC = () => {
|
---|
| 23 | throw new Error("tapAsync is not supported on a SyncLoopHook");
|
---|
| 24 | };
|
---|
| 25 |
|
---|
| 26 | const TAP_PROMISE = () => {
|
---|
| 27 | throw new Error("tapPromise is not supported on a SyncLoopHook");
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | const COMPILE = function(options) {
|
---|
| 31 | factory.setup(this, options);
|
---|
| 32 | return factory.create(options);
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | function SyncLoopHook(args = [], name = undefined) {
|
---|
| 36 | const hook = new Hook(args, name);
|
---|
| 37 | hook.constructor = SyncLoopHook;
|
---|
| 38 | hook.tapAsync = TAP_ASYNC;
|
---|
| 39 | hook.tapPromise = TAP_PROMISE;
|
---|
| 40 | hook.compile = COMPILE;
|
---|
| 41 | return hook;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | SyncLoopHook.prototype = null;
|
---|
| 45 |
|
---|
| 46 | module.exports = SyncLoopHook;
|
---|