Skip to content

v1.2.0

Latest
Compare
Choose a tag to compare
@ghaerdi ghaerdi released this 30 Mar 15:42

This release introduces new convenience methods for handling Result values, making destructuring easier and more flexible.

✨ New Features

  • asTuple() Method: Represents the Result's state as a tuple [error, value]. This is useful for developers who prefer Go-style error handling destructuring.
    • Returns [undefined, value] if the Result is Ok(value).
    • Returns [error, undefined] if the Result is Err(error).
  • asObject() Method: Represents the Result's state as an object { error, value }. This is useful for standard object destructuring.
    • Returns { error: undefined, value: value } if the Result is Ok(value).
    • Returns { error: error, value: undefined } if the Result is Err(error).

These additions provide more ways to interact with Result types, enhancing the developer experience for this Rust-inspired error-handling library.

Full Changelog: v1.1.0...v1.2.0