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

@adaptive-ds/result

v0.5.0

Published

A simple, type-safe Result type for TypeScript. Handle errors gracefully without try-catch soup.

Readme

@adaptive-ds/result

Stop letting errors crash your parties. Handle them gracefully with a simple, type-safe Result type that tells you exactly what went wrong and where.

Features

  • Type-safe - Full TypeScript inference, no more any
  • Explicit errors - Know exactly which operation failed and why
  • No try-catch soup - Clean, readable error handling
  • Chainable - Transform results with resultMap, resultMapErr
  • Lightweight - Zero dependencies, tree-shakable

The Problem

// Traditional error handling? No thanks.
async function fetchUser(id: string) {
  try {
    const user = await api.getUser(id)
    return user
  } catch (e) {
    // Wait, was it a network error? Validation? Database?
    console.log(e) // "Something went wrong" 😩
    throw e // Re-throwing loses context
  }
}

The Solution

import { createResult, createResultError, type PromiseResult } from "@adaptive-ds/result"

async function fetchUser(id: string): PromiseResult<User> {
  const validation = validateId(id)
  if (!validation.success) return createResultError("fetchUser", "Invalid ID", validation.error)

  try {
    const user = await api.getUser(id)
    return createResult(user)
  } catch (e) {
    return createResultError("fetchUser", "API failed", e.message)
  }
}

// Usage is explicit and safe
const result = await fetchUser("123")
if (!result.success) {
  console.log(result.op, result.errorMessage) // Exactly what went wrong
  return
}
console.log(result.data) // TypeScript knows this is User

Installation

bun add @adaptive-ds/result
# or
npm install @adaptive-ds/result

Quick Start

import { createResult, createResultError, resultIsOk, resultMap } from "@adaptive-ds/result"

// Create success
const ok = createResult({ name: "Alice" })
// { success: true, data: { name: "Alice" } }

// Create error
const err = createResultError("saveUser", "Email already taken")
// { success: false, op: "saveUser", errorMessage: "Email already taken" }

// Type guard
if (resultIsOk(ok)) {
  console.log(ok.data) // TypeScript knows it's valid
}

// Transform data
const mapped = resultMap(ok, (user) => user.name.toUpperCase())

API

Types

  • ResultOk<T> - Success state with data
  • ResultErr - Failure state with operation, message, optional code/data
  • Result<T> - Union of Ok and Err
  • PromiseResult<T> - Async Result

Functions

  • createResult(data) - Create a success result
  • createError(op, message, data?) - Create an error result
  • createResultError(op, message, data?) - Alias for createError
  • createResultErrorCode(op, message, code) - Create error with error code
  • resultIsOk(r) - Type guard for success
  • resultIsErr(r) - Type guard for failure
  • resultGetOrElse(r, default) - Get data or return default
  • resultMap(r, fn) - Transform data if success
  • resultMapErr(r, fn) - Transform error if failure

License

MIT