Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 1df14c3

Browse files
committed
fix: rename declareStep -> createStep
1 parent 4505312 commit 1df14c3

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ basic step implementation
3333
- [name](#name)
3434
- [startupOrder](#startuporder-1)
3535
- [StepProviderMixin](#stepprovidermixin)
36+
- [StepProviderMixin](#stepprovidermixin-1)
3637

3738
## Step
3839

@@ -77,12 +78,24 @@ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
7778

7879
## StepProviderMixin
7980

80-
Provide steps.
81+
Extends a class to fullfill step provider functionality
82+
83+
**Parameters**
84+
85+
- `superclass` **Class** class to extend
86+
87+
Returns **Class** extended class
88+
89+
## StepProviderMixin
90+
91+
Extends a class to fullfill step provider functionality
8192
Register and lookup step types
8293

8394
**Parameters**
8495

85-
- `superclass`
96+
- `superclass` **Class** class to extend
97+
98+
Returns **Class** extended class
8699

87100
# install
88101

src/step-provider-mixin.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
/**
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
45
*/
56
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+
*/
613
return class StepProviderMixin extends superclass {
714
constructor(...args) {
815
super(...args);
916

1017
Object.defineProperty(this, 'registeredSteps', { value: new Map() });
1118
}
1219

20+
/**
21+
* Registers a Step class for later use in createStep
22+
* @param {Object} step step class
23+
* @return {undefined}
24+
*/
1325
registerStep(step) {
1426
this.registeredSteps.set(step.name, step);
1527
}
1628

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) {
1837
const factory = this.registeredSteps.get(config.type);
1938
if (factory === undefined) {
2039
throw new Error(`Undefined step ${config.type}`);

tests/step-provider-mixin-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test('provider', async t => {
1515

1616
provider.registerStep(AStep);
1717

18-
const step = await provider.declareStep(
18+
const step = await provider.createStep(
1919
{
2020
name: 's1',
2121
type: 'a-step'
@@ -31,7 +31,7 @@ test('provider unknown type', async t => {
3131
const provider = new Provider();
3232

3333
try {
34-
const step = await provider.declareStep(
34+
const step = await provider.createStep(
3535
{
3636
name: 's2',
3737
type: 'unknown-step'

0 commit comments

Comments
 (0)