Skip to content

Option represents an optional value: it is either some and contains a value, or none, and does not.

Notifications You must be signed in to change notification settings

igrek8/some-none

Repository files navigation

Some/None Value

Runkit

Option represents an optional value: it is either some and contains a value, or none, and does not.

Installation

npm i some-none --save
yarn add some-none

Usage

import { Option } from "some-none";

let a: Option<number> = Option.some(42);

switch (a) {
  case Option.none:
    console.log("No value");
    break;
  default:
    console.log("Some value");
    break;
}

console.log(a.unwrap());

a = Option.none;

switch (a) {
  case Option.none:
    console.log("No value");
    break;
}

About

Option represents an optional value: it is either some and contains a value, or none, and does not.

Topics

Resources

Stars

Watchers

Forks