seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
652 stars 13 forks source link

Improved `branch` method to act like conditional `pipe` #112

Closed gustavoguichard closed 1 year ago

gustavoguichard commented 1 year ago

This PR adds the possibility to return null from a branch compinator's predicate so it won't pipe and will follow on with the result of the first DF.

This is a non-breaking change to the already existent branch as you can see even the types are preserved. It will only add the type of the first DF to the possible output if the predicate returns null in the conditional return.

The motivation for this PR is that I've tried to come up with other ways to do it with a combination of branch and a passthrough. But I always ended up breaking the inference with passthrough and with this addition the inference is preserved.