Skip to content

Commit 88c7a38

Browse files
committed
Add merge to the README.
1 parent b4bb294 commit 88c7a38

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ plan.step('Some cool step', { slow: 500 }, (data, done) => {
181181

182182
Adds a phase with `label` to the plan, executing `fn` with a `phase` object to define the phase plan.
183183

184-
The `phase` object has the `step` and `phase` methods, allowing you to build a hierarchy of other phases and steps.
184+
The `phase` object has the `step`, `phase` and `merge` methods, allowing you to build a hierarchy of other phases and steps.
185185

186186
```js
187187
const planify = require('planify');
@@ -193,6 +193,29 @@ plan.phase('Phase 1', (phase) => {
193193
});
194194
```
195195

196+
#### .merge(plan)
197+
198+
Merges a plan into self, which may be a plan or a phase.
199+
200+
The child steps and phases of `plan` becomes children of self. Additionally, the `data` associated with the `plan` are shallow copied to self.
201+
202+
```js
203+
const planify = require('planify');
204+
205+
const plan1 = planify()
206+
.phase('Phase 1', (phase) => {
207+
phase.step('Inner step', () => {});
208+
phase.phase('Inner phase', () => {});
209+
});
210+
211+
const plan2 = planify()
212+
.phase('Phase 2', (phase) => {
213+
phase.step('Inner step', () => {});
214+
phase.phase('Inner phase', () => {});
215+
})
216+
.merge(plan1);
217+
```
218+
196219
#### .run([options])
197220

198221
Runs the plan.

0 commit comments

Comments
 (0)