Skip to content

Rust-like error handling and options for TypeScript and Deno!

License

Notifications You must be signed in to change notification settings

ghostlylake/optionals

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Optionals

Rust-like error handling and options for TypeScript, Node and Deno!

This module allows you to remove null and undefined from your projects with the help of ES6 Symbols and helper methods. Inspired by Rust's Option, Result enums.

Why should you use Optionals?

The standard practice of returning null or undefined when no other value can be returned means that there is no simple way to express the difference between a function that has returned "nothing" and a null return type. There are also no easy ways to handle errors in a functional pattern. Rust's implementation of Option and Result guarantees correctness by expressly forcing correct result-handling practices.

This module provides a minimal, fast and simple way to create expressive functions and perform better pattern matching on resulting values! 🚀

Usage

// Result
import { Result, Ok, Err } from "https://deno.land/x/optionals@v2.0.2`/mod.ts";

// Option
import {
  Option,
  Some,
  None,
} from "https://deno.land/x/optionals@v2.0.2/mod.ts";

Documentation

Please find further documentation on the doc page!

About

Rust-like error handling and options for TypeScript and Deno!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%