I want to write a long promise chain in which some items will be skipped based on a condition. Something like this, unfortunately, this is not valid syntax:
function f(condition) {
A()
.then (B)
if (condition) {
.then(C)
.then(D)
}
.then(E)
}
What is the most graceful way to do what I want? I already have a way to handle data flow, so I'm not worried about the fact that the result of B and the result of D may not look similar. It's just control flow that I'm concerned with.