Skip to main content
Home

Built and signed on GitHub Actions

A result type for Typescript which acts as enhanced monad/tuple for returning a results and errors without the need to throw an error.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
4 months ago (0.0.0)

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

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@bearz/result

Import symbol

import * as result from "@bearz/result";
or

Import directly with a jsr specifier

import * as result from "jsr:@bearz/result";

Add Package

pnpm i jsr:@bearz/result
or (using pnpm 10.8 or older)
pnpm dlx jsr add @bearz/result

Import symbol

import * as result from "@bearz/result";

Add Package

yarn add jsr:@bearz/result
or (using Yarn 4.8 or older)
yarn dlx jsr add @bearz/result

Import symbol

import * as result from "@bearz/result";

Add Package

vlt install jsr:@bearz/result

Import symbol

import * as result from "@bearz/result";

Add Package

npx jsr add @bearz/result

Import symbol

import * as result from "@bearz/result";

Add Package

bunx jsr add @bearz/result

Import symbol

import * as result from "@bearz/result";