Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: everweij/typescript-result

3.1.1

01 Jan 15:44
Compare
Choose a tag to compare

Fixes

  • Fixes cases where exceptions thrown inside AsyncResult's were trapped, which resulted in unhandled exceptions.

3.1.0

03 Nov 11:07
Compare
Choose a tag to compare

Minor changes

  • adds toTuple() to both the Result and AsyncResult class, allowing you to destructure a result and use TypeScript's narrowing capabilities (instead of having to check with isOk() and isError()).
declare const result: Result<number, ErrorA>;

const [value, error] = result.toTuple();

if (error) {
  // error is ErrorA
} else {
  // at this point the value must be a number
}

// or 'Go-style'
if (error === null) {
 // do something with the value
}

3.0.0

15 Oct 09:18
Compare
Choose a tag to compare

Breaking changes

  • #2 Throws the error directly instead of wrapping the encapsulated error in an additional error when using getOrThrow()

2.1.1

08 Oct 12:57
Compare
Choose a tag to compare

Fixes

  • Fixes issue where AsyncResult's onSuccess and onFailure did not await promises well, resulting in 'dangling' promises

2.1.0

03 Sep 08:02
Compare
Choose a tag to compare

Minor changes

  • added mapError method to both the Result and AsyncResult instances, which allows you to transform the encapsulated error of a failed result (#9 )
  • added an additional parameter to the mapCatching method (transformErrorFn) which allows you to transform the potential error caught while transforming. (#9)

Thanks @derkbell for suggesting this improvement and helping out with a solution!

Fixes

  • Moves the default export condition to last position in package.json. See #6.

Thanks @trombipeti for helping and pointing this out!

2.0.0

09 Jun 12:51
Compare
Choose a tag to compare
v2.0.0

bumps version

2.0.0-beta.1

09 Jun 11:16
Compare
Choose a tag to compare
2.0.0-beta.1 Pre-release
Pre-release
v2.0.0-beta.1

adds release workflow

v1.2.0

02 Sep 12:13
Compare
Choose a tag to compare
  • Result.safe() now accepts a error-class as parameter:
class CustomError() {}
const result = Result.safe(CustomError, () => 2 * 2);
  • Result.safe() now accepts a callback which returns another Result an will merge both Results:
class CustomError() {}
function doStuff(): Result<CustomError, number> {}
const result = Result.safe(() => doStuff()); // Result<Error | CustomError, number>
  • Result#map() now accepts a callback that returns another result (flat-map) or a callback that transforms the value directly:
function doStuff(): Result<CustomError, number> {}

const result = doStuff().map(num => num * 2); // Result<Error | CustomError, number>

v1.1.0

01 Sep 10:15
Compare
Choose a tag to compare

Added Result.forward()

v1.0.0

22 Aug 16:34
Compare
Choose a tag to compare

Initial release!