0.2.0 • Published 5 years ago

fn-onion v0.2.0

Weekly downloads
3
License
-
Repository
-
Last release
5 years ago

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