feat: Add a function that combines multiple results and returns an object#610
feat: Add a function that combines multiple results and returns an object#610Karibash wants to merge 1 commit intosupermacro:masterfrom
Conversation
🦋 Changeset detectedLatest commit: 595c76a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
27569b4 to
595c76a
Compare
|
Faced this exact pattern before, and using ResultAsync.combine is very awkward. +1 for the feature. My one question is, does this really need to be a different method, or would it be possible to just overload I am thinking of the We could have similarly (for
overloads can be messy, but I'm more favourable of them in library code where the user is more likely to see these two cases as equivalent, and it avoids the need for them to remember any difference in behaviour between the two if they are truly analogous. |
Hi @supermacro ,
First of all, I would like to thank you for creating such a wonderful library. I have been using neverthrow in a production environment for about a year and I am very satisfied with it.
In this PR, I am adding a function that combines multiple Results, passed as an object, into a single Result. This can be very useful for functional programming as shown below:
To do the same thing with the current API, you need to use
mapas shown below. This requires you to remember which data is in which position in the array, which is not very convenient.