I have a .then()
waterfall with promise steps, and sometimes a promise doesn't apply. So I have code like this:
var maybe_noop_promise;
if (some_condition)
maybe_noop_promise = fetch(...).then(...)... // work need be done
else
maybe_noop_promise = /* code for resolved promise (?) */
Were I using jQuery, there's a suggestion that this can be done with $.when()
. And it appears Promise.all([])
is resolved, which I guess is fine, though I don't know if that is wasteful or slow.
Is there a favored idiom for a pre-cooked resolved promise?