function App(){
}
App.prototype = {
use(fn){
this.fns.push(fn)
},
fns:[],
start(){
let i=0;
let fns = this.fns;
function f(){
fns[i]("s",()=>{
i++;
if(fns[i]){
f()
}
})
}
f()
}
}
const app = new App()
app.use((ctx, next)=>{
console.log('1-1')
next()
console.log('1-2')
})
app.use((ctx, next)=>{
console.log('2-1')
next()
console.log('2-2')
})
app.use((ctx, next)=>{
console.log('3-1')
next()
console.log('3-2')
})
app.start()