0.0.0 • Published 10 months ago

@bearz/option v0.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@bearz/option

Overview

The '@bearz/option' module provides the Option<T> type with functions some, none, and from which are all used to help deal with null and undefined values.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io

A list of other modules can be found at github.com/bearz-io/js

Usage

import { ok, some, none } from "@bearz/functional";

const o1 = none<number>();
console.log(o1.isSome); // false 
console.log(o1.isNone); // true
console.log(o1.unwrapOrElse(() => 50)); // 50

const o = some(10);
console.log(o.isSome); // true
console.log(o.isNone); // false
o.inspect(g => console.log(g));
console.log(o.map(g => g * 60).unwrap()); // 60

License

MIT License