0.0.0 • Published 9 months ago

@bearz/result v0.0.0

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

@bearz/result

Overview

The '@bearz/result' module provides the Result<T,E> type with functions ok, fail, tryCatch, and tryCatchSync which are all used to help deal with returning results or errors.

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, fail, tryCatchSync } from "@bearz/functional";

const r = ok(10);
console.log(r.isOk);
console.log(r.isError);

console.log(r.map((v) => v.toString()));

const r1 = tryCatchSync<number>(() => {
    throw Error("test");
});

console.log(r1.isError); // true

const r2 = fail<number>(new Error("test"));
console.log(r2.isError); // true;

License

MIT License

0.0.0

9 months ago