acyclic-steps
v1.0.0
Published
## Example
Downloads
2
Readme
acyclic-steps
Example
// 1. 定义执行步骤
const step = Step.define('step 1').build(() => 'data');
const step2 = Step.define('step 2').build(() => 'data2');
const step3 = Step.define('step 3').build(() => 'data3');
const step4 = Step.define('step 4').build(() => 'data4');
const step5 = Step.define('step 5').build(() => 'data5');
const step6 = Step.define('step 6').build(() => 'data6');
const step7 = Step.define('step 7').build(() => 'data7');
const step8 = Step.define('step 8').build(() => 'data8');
const step9 = Step.define('step 9').build(() => 'data9');
const step10 = Step.define('step 10').build(() => 'data10');
const step11 = Step.define('step 11').build(() => 'data11');
// 2. 添加步骤依赖, 形成 "基础流" 或 "支流"
const basic = Step.define('basic flow')
.dep(step)
.dep(step2)
.dep(step3)
.dep(step4)
.dep(step5)
.dep(step6)
.dep(step7)
.dep(step8)
.dep(step9)
.deps([step10, step11])
.build((v, v2, v3, v4, v5, v6, v7, v8, v9, v10) => `${v} ${v2} ${v3} ${v4} ${v5} ${v6} ${v7} ${v8} ${v9} ${v10}`);
const r = new Runner();
// 可以重写 step2 的执行结果
r.override(step2, 'test replace');
try {
// 3. 执行步骤, 执行逻辑流
const result = await r.run(basic);
console.log(result);
} catch (e) {
// 4. 处理异常流
console.log(e);
}