0.2.0 • Published 7 years ago
fn-onion
Licence
—
Version
0.2.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0
fn-onion
compose functions to one which will be excuted like onion. re-factor from koajs/compose so that you can custom args.
$ npm i fn-onion
const compose = require('fn-onion')
let middleware = []
middleware[0] = async (next) => {
await console.log(1)
await next()
await console.log(4)
}
middleware[1] = async (next) => {
await next()
await console.log(3)
}
middleware[2] = async (next) => {
await console.log(2)
}
let fn = compose(middleware)
fn()
// 1 2 3 4