option-result
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

option-result Build Status Coverage Status npm bundle size (minified + gzip) npm

A lightweight JavaScript and TypeScript library with simple Option and Result monads.

Motivation

Null pointers are considered a billion dollar mistake. Because of all the problems they're causing many programming languages were designed specifically without null values, instead implementing various optional types (i.e. Rust or Haskell). Other languages are trying to fix this (like Optional type in Java). Unfortunatelly, we on the web are stuck with not one null, but with two, each having a different use.

This package ports the excellent Option and Result types from the Rust language to JavaScript, in an attempt to remove null and undefined from your code. ES5 is full of function returning undefined, NaNs, invalid Date objects etc. and wrapping everything with Options ans Results would be too cumbersome. Still, you can benefit from using these monads in your own functions.

Package Sidebar

Install

npm i option-result

Weekly Downloads

0

Version

0.1.1

License

ISC

Unpacked Size

18.5 kB

Total Files

9

Last publish

Collaborators

  • co0sh