I have the following:
if (someCondition) {
return promiseMakerA().then(function() {
return promiseMakerB(someLongListOfArguments);
});
}
else
return promiseMakerB(someLongListOfArguments);
How can I eliminate that code repetition (promiseMakerB
)?
you can do the following, however, it's not necessarily the most readable way of doing so
return (someCondition ? promiseMakerA(): Promise.resolve()).then(function() {
return promiseMakerB(someLongListOfArguments);
});