how to pipe functions, when a promise in the promise in the middle checks authorization?
问题 i'm trying to compose some functions together: compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); checkAuthorization returns a promise that check if a user is authorized. buildParams receives someRequestData , and pipes the result to searchItem . checkAuthorization() .then(() => { compose( searchItem, buildParams )(someRequestData) }, (e) => { handleError(e) }) I think it's OK, but I wish to have a more elegant look for readability, something like: compose( searchItem,