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

@reachdesign/flip

v1.0.6

Published

A TypeScript library for elegant error handling using result types with ok/err pattern

Readme

Flip

A TypeScript library that makes error handling less painful than stepping on a LEGO barefoot.

Reach Design Flip

npm version TypeScript License: MIT

Installation

npm install @reachdesign/flip

Why Flip?

Because nobody likes try-catch blocks that look like a pyramid scheme. Instead of throwing tantrums (I mean exceptions), functions return a Flip.R<T, E> that's either "Yay, it worked!" or "Oops, something went sideways."

Usage

import { Flip } from '@reachdesign/flip';

function countSlices(pizzas: number): Flip.R<number, string> {
  if (pizzas === 0) return Flip.err("No pizza, no life! 😭");
  return Flip.ok(pizzas * 8);
}

const result = countSlices(0);
console.log(Flip.isErr(result) ? Flip.e(result) : Flip.v(result));
// "No pizza, no life! 😭"

Cat Mood 😸

function checkCat(treats: number): Flip.R<boolean, string> {
  if (treats < 3) return Flip.err("Cat is plotting revenge 😾");
  return Flip.ok(true);
}

const result = checkCat(2);
console.log(Flip.isOk(result) ? "Happy cat!" : Flip.e(result));
// "Cat is plotting revenge 😾"

Async Coffee ☕

async function brewCoffee(beans: number): Promise<Flip.R<string, Error>> {
  if (beans === 0) return Flip.err(new Error("Zombie mode ON 🧟‍♂️"));
  return Flip.ok("☕ Ready!");
}

const result = await brewCoffee(0);
console.log(Flip.isOk(result) ? Flip.v(result) : Flip.e(result).message);
// "Zombie mode ON 🧟‍♂️"

API Reference

Types

  • Flip.R<T, E>: A result type that's either { ok: true, value: T } (success) or { ok: false, error: E } (error)

Functions

  • Flip.ok<T>(value: T): Creates a successful result (like finding money in your old jeans)
  • Flip.err<E>(error: E): Creates an error result (like realizing it was just a receipt)
  • Flip.v<T, E>(result: Flip.R<T, E>): Extracts the value from success (throws if error - handle with care!)
  • Flip.e<T, E>(result: Flip.R<T, E>): Extracts the error from failure (throws if success - also handle with care!)
  • Flip.isOk<T, E>(result: Flip.R<T, E>): Checks if result is successful (type-safe way to check)
  • Flip.isErr<T, E>(result: Flip.R<T, E>): Checks if result is an error (for when things go sideways)
  • Flip.isOk<T, E>(result: Promise<Flip.R<T, E>>): Async version for promise results
  • Flip.isErr<T, E>(result: Promise<Flip.R<T, E>>): Async version for promise results

Benefits

  • 🚫 No more exceptions: Handle errors like a responsible adult
  • 🔒 Type-safe: TypeScript will hold your hand and guide you
  • 🎯 Explicit: No surprises, no hidden exceptions jumping out
  • 📦 Lightweight: Smaller than your morning coffee
  • 🧪 Testable: Testing error scenarios is now fun (or at least bearable)

Why "Flip"?

Because sometimes your code works, sometimes it doesn't - it's like flipping a coin, but now you can handle both outcomes gracefully! 🪙

License

MIT - Use it, abuse it, just don't blame us if your cat still gives you the death stare.

Contributing

Found a bug? Have a funny example? PRs welcome! Just remember: with great power comes great responsibility to write good error messages.