seangwright / typescript-functional-extensions

A TypeScript implementation of the C# library CSharpFunctionalExtensions, including synchronous and asynchronous Maybe and Result monads.
MIT License
33 stars 4 forks source link

Feature: Improve API helpers and error handling callbacks #18

Closed seangwright closed 1 year ago

seangwright commented 1 year ago

This PR changes how the fetchResponse helper works by returning the Response object instead of mapping it to Unit. This lets consumers use all the Response state to make additional logic decisions.

It also makes all the error handlers callbacks for async operations optionally async.

Finally, some missing tests were added for ResultAsync.try, and the fetchResponse/fetchJsonResponse helpers. There are still more test cases that need to be added for async error handlers, but there are no regressions with existing functionality, so the additional tests can wait for a later PR.

Because of the change to fetchResponse, this will result in a major version bump to 2.0.0.

xShivan commented 1 year ago

Node.js version in README.md should be updated too.

seangwright commented 1 year ago

Good catch! I'll also want to update the stats of the file sizes since they were modified.