问答题1148/1566实现 compose 函数, 类似于 koa 的中间件洋葱模型

1// 题目需求 2let middleware = [] 3middleware.push((next) => { 4 console.log(1) 5 next() 6 console.log(1.1) 7}) 8middleware.push((next) => { 9 console.log(2) 10 next() 11 console.log(2.1) 12}) 13middleware.push((next) => { 14 console.log(3) 15 next() 16 console.log(3.1) 17}) 18 19let fn = compose(middleware) 20fn() 21 22 23/* 241 252 263 273.1 282.1 291.1 30*/ 31 32//实现compose函数 33function compose(middlewares) { 34 35}
难度:
2023-05-31 创建

赞赏支持

预览

题库维护不易,您的支持就是我们最大的动力!