We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
function compose (middlewares) { return ctx => { const dispatch = (i) => { const middleware = middlewares[i] if (i === middlewares.length) { return } return middleware(ctx, () => dispatch(i+1)) } return dispatch(0) } }
Sorry, something went wrong.
const middlewares = []; middlewares.push(async function(ctx, next) { console.log('1'); await next(); console.log('6'); }); middlewares.push(async function(ctx, next) { console.log('2'); await next(); console.log('5'); }); middlewares.push(async function(ctx, next) { console.log('3'); await next(); console.log('4'); }); async function run() { const middleware = middlewares.shift(); await (middleware && middleware({}, run)); } run(); // expect output: 1 2 3 4 5 6
@haotie1990 你这种实现,简洁多了!
这个好棒
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: