|
1 | 1 | /** |
2 | | - * Provide steps. |
3 | | - * Register and lookup step types |
| 2 | + * Extends a class to fullfill step provider functionality |
| 3 | + * @param {Class} superclass class to extend |
| 4 | + * @return {Class} extended class |
4 | 5 | */ |
5 | 6 | export function StepProviderMixin(superclass) { |
| 7 | + /** |
| 8 | + * Extends a class to fullfill step provider functionality |
| 9 | + * Register and lookup step types |
| 10 | + * @param {Class} superclass class to extend |
| 11 | + * @return {Class} extended class |
| 12 | + */ |
6 | 13 | return class StepProviderMixin extends superclass { |
7 | 14 | constructor(...args) { |
8 | 15 | super(...args); |
9 | 16 |
|
10 | 17 | Object.defineProperty(this, 'registeredSteps', { value: new Map() }); |
11 | 18 | } |
12 | 19 |
|
| 20 | + /** |
| 21 | + * Registers a Step class for later use in createStep |
| 22 | + * @param {Object} step step class |
| 23 | + * @return {undefined} |
| 24 | + */ |
13 | 25 | registerStep(step) { |
14 | 26 | this.registeredSteps.set(step.name, step); |
15 | 27 | } |
16 | 28 |
|
17 | | - declareStep(config, ...args) { |
| 29 | + /** |
| 30 | + * Creates a step from its config |
| 31 | + * @param {Object} config |
| 32 | + * @param {string} config.type step type to create |
| 33 | + * @param {Object[]} args remaining |
| 34 | + * @return {Step} newly created step |
| 35 | + */ |
| 36 | + createStep(config, ...args) { |
18 | 37 | const factory = this.registeredSteps.get(config.type); |
19 | 38 | if (factory === undefined) { |
20 | 39 | throw new Error(`Undefined step ${config.type}`); |
|
0 commit comments