Does this function
automationStatusIsSuccessful = (data) -> data.Automation.Status isnt "FAILED" and data.Automation.Status isnt "COMPLETEDWITHERROR"`
make the conditional statement more readable or less readable?
With:
automationStatusIsSuccessful = (data) ->
data.Automation.Status isnt "FAILED" and data.Automation.Status isnt "COMPLETEDWITHERROR"
checkIteration = (data) ->
if iteration < Configuration.CHECK_ITERATIONS and automationStatusIsSuccessful(data)
Without:
checkIteration = (data) ->
if iteration < Configuration.CHECK_ITERATIONS and data.Automation.Status isnt "FAILED" \
and data.Automation.Status isnt "COMPLETEDWITHERROR"
automationStatusIsSuccessful
. For example maybe theurl.get().then (data) ...
in "without" shouldn't be there? It would be a lot easier to see what you want. And yes, using a function is definitely more readable: extracting complex conditions to a method is a common refactoring technique. After you clarify I'll be happy to vote to reopen + upvote \$\endgroup\$