v3.0.0 released

Type-Safe Error Handling
for TypeScript

Result, Maybe, Try, and AsyncResult — composable types that make errors a first-class citizen.

Type-Safe

Errors are encoded in the type system — the compiler forces you to handle them

Composable

Chain, map, and combine operations without nested if/else spaghetti

Ergonomic

No more undefined/null checks everywhere — methods like .map(), .flatMap(), .unwrap()

2KB

Lightweight

Zero dependencies, tree-shakeable, ~2KB gzipped

Quick Start

Get up and running in under 2 minutes.

Installation

$ pnpm add @deessejs/fp

Basic Usage

Core Types

The four building blocks of type-safe error handling.

Result

Represents success or failure with error

try/catch as a type

Result<number, Error>
Maybe

Represents optional values (something/nothing)

Type-safe undefined

Maybe<User>
Try

Lazy evaluation of code that might throw

() => try {} wrapped

Try<ParseResult>
AsyncResult

Async operations that might fail

Promise<Result>

AsyncResult<User, Error>

Code Examples

Real-world usage patterns for common scenarios.

Features

Everything you need for production-ready error handling.

Fully tree-shakeable
Zero runtime dependencies
TypeScript-first (strict mode compatible)
ESM + CJS exports
Works with Zod, effect-ts, and other FP libraries
Comprehensive test coverage

Install

Add @deessejs/fp to your project using your preferred package manager.

pnpm$ pnpm add @deessejs/fp
npm$ npm install @deessejs/fp
yarn$ yarn add @deessejs/fp
bun$ bun add @deessejs/fp

Import

import { Result, ok, err }from '@deessejs/fp'