As discussed in sindresorhus/execa#15 (diff). How I think when coding is to handle errors and exceptions as soon as possible and return early. If we take a look at the two examples below, the latter one makes more sense to me. foobar()
in this case is the "real" body while the code in the if
statements deal with exceptions. When using the style in the former one, this isn't as clear to me.
if (conditon) {
someFn();
} else if (someOtherCondition) {
someOtherFn();
} else {
foobar();
}
if (condition) {
someFn();
return;
}
if (someOtherCondition) {
someOtherFn();
return;
}
foobar();
This might be worth reading too http://blog.timoxley.com/post/47041269194/avoid-else-return-early.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too