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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lppedd/mini-result

v0.5.0

Published

Minimal Result type for TypeScript

Downloads

645

Readme

npm ecmascript status build coverage minified size license

Design considerations

mini-result is inspired by existing Result-type libraries such as:

However, unlike these libraries, mini-result intentionally focuses on minimalism. Rather than looking for features, tree-shakability or performance, it aims to provide a tiny and easy-to-understand Result type with just the essentials needed for practical error handling, which also includes async support.

The minified package currently sits at around 0.5 kB, and no further API additions are planned.

Installation

npm i @lppedd/mini-result
pnpm add @lppedd/mini-result
yarn add @lppedd/mini-result

Operations

Fundamentally, Result offers only 5 operations: map, tap, catch, unwrap and unwrapOr.
Those operations are also split into synchronous and asynchronous (suffixed with *Async) variants.

But let's start with creating an Ok or Err result.

Result factory

import { Res } from "@lppedd/mini-result";

const ok = Res.ok(1);        // Ok<number, never>
const er = Res.err("error"); // Err<never, string>

Result.map

Transforms the result's success value. No-op if the result represents an error state.

// result: Result<number, Error>
const r = result.map((n) => n + 1);
const r = result.map((n) => compute(n)); // () => Result<number, Error>

Result.tap

Invokes a function with the result's success value if the result represents a success state, or with the error value if it represents an error state.

// result: Result<number, Error>
const r = result.tap((n) => console.log(n), (e) => console.error(e));

Result.catch

Catches and transforms the result's error value. No-op if the result represents a success state.

// result: Result<number, Error>
// Transform the error value from Error to string
const r = result.catch((e) => Res.err(e.message));

// Replace the error value with a success value
const r = result.catch((e) => defaultValue);
// Or
const r = result.catch((e) => Res.ok(defaultValue));

// Replace the error value with a new result (which might be a success or error itself)
const r = result.catch((e) => computeDefault()); // (e) => Result<number, Error>

Result.unwrap

Unwraps the result's success value.

// result: Result<number, Error>
// n: number
const n = result.unwrap();

Or throws an Error if the result represents an error state.

[mini-result] cannot unwrap an Err result
  [value] Error: invalid number

Result.unwrapOr

Unwraps the result's success value, or falls back to the value returned by the given function if the result represents an error state.

// result: Result<number, Error>
// n: number
const n = result.unwrapOr((e) => defaultValue);

License

MIT 2025-present Edoardo Luppi