• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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/[email protected]`/mod.ts";

// Option
import {
  Option,
  Some,
  None,
} from "https://deno.land/x/[email protected]/mod.ts";

Documentation

Please find further documentation on the doc page!