npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@deessejs/core

v0.3.2

Published

Type-safe error handling for TypeScript - Result, Maybe, Try, and AsyncResult monads with zero runtime dependencies

Readme

Functional programming patterns for TypeScript.

Requirements

  • TypeScript 5.0+

Installation

# Install core
npm install @deessejs/core

# Or using pnpm
pnpm add @deessejs/core

# Or using yarn
yarn add @deessejs/core

Usage

import { ok, err, isOk, isErr, Result } from '@deessejs/core'

// Ok - Normal Operation Result
const ok = ok({ id: 1, name: 'John' })
if (isOk(ok)) {
  console.log(ok.value.name) // TypeScript knows this is User
}

// Err - Domain Errors (Business Logic)
const notFound = err({
  name: 'NOT_FOUND',
  args: { id: 123 }
})
if (isErr(notFound)) {
  console.log(notFound.error.name) // "NOT_FOUND"
  console.log(notFound.error.args.id) // 123
}

// Result - Union Type
function getUser(id: number): Result<User> {
  const user = findUser(id)
  if (!user) {
    return err({ name: 'NOT_FOUND', args: { id } })
  }
  return ok(user)
}

const result = getUser(123)
if (isOk(result)) {
  console.log(result.value.name)
} else if (isErr(result)) {
  console.log(result.name) // "NOT_FOUND"
}

Features

  • Result Type - Successful operation result with value or error
  • Maybe Type - Optional values (Some/None)
  • Try Type - Exception handling wrapper
  • Type Guards - isOk, isErr, isSome, isNone for narrowing
  • Fully Typed - Comprehensive TypeScript support
  • Minimal Dependencies - Only Zod for runtime validation, no other external deps
  • 100% Test Coverage - Thoroughly tested

API Reference

Types

| Type | Description | |------|-------------| | Result<T, E> | Successful operation result with value or error | | Maybe<T> | Optional value (Some or None) | | Try<T> | Exception handling wrapper |

Functions

| Function | Description | |----------|-------------| | ok<T>(value) | Create an Ok result | | err<E>(options) | Create an Err result | | some<T>(value) | Create a Some | | none() | Create a None | | try<T>(fn) | Wrap a function in Try | | flattenMaybe(maybe) | Flatten a nested Maybe |

Type Guards

| Guard | Description | |-------|-------------| | isOk(result) | Check if result is Ok (narrows type) | | isErr(result) | Check if result is Err (narrows type) | | isSome(maybe) | Check if maybe is Some (narrows type) | | isNone(maybe) | Check if maybe is None (narrows type) |

TypeScript Signature Examples

// Ok result
ok<T>(value: T): Ok<T>

// Err with typed args
err<E>(options: { name: string; args: E }): Err<Error<E>>

// Result type
type Result<T, E = Err<unknown>> = Ok<T> | Err<E>

Why This Package?

These patterns are useful in any TypeScript project:

  • Backend services
  • CLI tools
  • Workers
  • Even frontend (with care)

Having them as a separate package means:

  • Users can use FP patterns without the full API framework
  • Smaller bundle size for simple projects
  • The patterns are well-tested and reusable
  • Can be used in any project, not just @deessejs ecosystem

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

  • Nesalia Inc.

Security

If you discover any security vulnerabilities, please send an e-mail to [email protected].

License

MIT License - see the LICENSE file for details.