Releases: everweij/typescript-result
Releases · everweij/typescript-result
v1.2.0
- 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>