Skip to content

A TypeScript library inspired by Rust’s Option<T> and Result<T, E>, providing safe and expressive error handling. Avoid null, undefined, and exceptions with explicit, functional-style handling of missing values and errors. 🚀

Notifications You must be signed in to change notification settings

m1kc3b/explicitly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Explicitly

Explicitly is a TypeScript library inspired by Rust that introduces Option and Result<T, E>. These types eliminate null, undefined, and unexpected exceptions by enforcing explicit handling of missing values and errors. With a functional approach, explicit enhances code robustness and readability while offering intuitive methods such as unwrapOr(), map(), and isOk().

Whether you're dealing with uncertain data, handling API errors, or preventing crashes due to missing values, Explicitly provides a safe and elegant alternative to traditional error-handling practices in JavaScript and TypeScript.

This library implements two generic types:

  • Option<T>: stands for a real that can exist (Some<T>) or be absent (None).
  • Result<T, E>: stands for either a successful value (Ok<T>) or an error (Err<E>).

Option<T>

It is a safer alternative to null (the billion-dollar mistake) and undefined.

None, represents the absence of a value and forces the developer to handle this case explicitly.

Some<T> contains a value and provides method to handle it.

Result<T, E>

It is an alternative to throw new Error() and involve to handle errors explicitly.

Ok<T> contains a successfull value, and provides methods to handle it.

Err<E> contains an error and prevents use without verification.

About

A TypeScript library inspired by Rust’s Option<T> and Result<T, E>, providing safe and expressive error handling. Avoid null, undefined, and exceptions with explicit, functional-style handling of missing values and errors. 🚀

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages