source: frontend/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[9af201e]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7const Hook = require("./Hook");
8const HookCodeFactory = require("./HookCodeFactory");
9
10class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory {
11 content({ onError, onResult, _onDone }) {
12 return this.callTapsSeries({
13 onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
14 onResult: (i, result, next) => {
15 let code = "";
16 code += `if(${result} !== undefined) {\n`;
17 code += `${this._args[0]} = ${result};\n`;
18 code += "}\n";
19 code += next();
20 return code;
21 },
22 onDone: () => onResult(this._args[0])
23 });
24 }
25}
26
27const factory = new AsyncSeriesWaterfallHookCodeFactory();
28
29function COMPILE(options) {
30 factory.setup(this, options);
31 return factory.create(options);
32}
33
34function AsyncSeriesWaterfallHook(args = [], name = undefined) {
35 if (args.length < 1) {
36 throw new Error("Waterfall hooks must have at least one argument");
37 }
38 const hook = new Hook(args, name);
39 hook.constructor = AsyncSeriesWaterfallHook;
40 hook.compile = COMPILE;
41 hook._call = undefined;
42 hook.call = undefined;
43 return hook;
44}
45
46AsyncSeriesWaterfallHook.prototype = null;
47
48module.exports = AsyncSeriesWaterfallHook;
Note: See TracBrowser for help on using the repository browser.