tms-flow
v0.0.8
Published
lightweight flow engine
Downloads
29
Readme
支持流水线方式
import { Pipeline } from './pipeline.js'
new Pipeline()
.use(function (req, res, next) {
res.x = 'hello'
next()
})
.use(function (req, res, next) {
res.y = 'world'
next()
})
.run({}, {}, function (err: Error | null, req: any, res: any) {
console.log('res', res)
})pipeline 可以嵌套
只支持线性执行
流水线中的方法执行上下文绑定为流水线
用use方法指定要执行的节点,所有节点函数的参数是一样的
用run方法启动流水线
流水线将next方法作为最后一个参数传给节点函数
流水线内部有个step指定当前的执行位置
要求流水线中的节点函数主动调用next方法,驱动流水线继续执行
同步、异步问题
