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

@arnavk-09/unwrap-go

v0.1.1

Published

Go-like Error Handling for TypeScript/JavaScript

Downloads

9

Readme

[!NOTE]

unwrap-go brings Go-style error handling to TypeScript and JavaScript, offering a clean and predictable way to handle errors using Result tuples. This approach eliminates the need for try-catch blocks and provides a more functional approach to error management.

🌟 Features

unwrap-go features intro:

  • Go-Style Error Handling – Uses tuple returns ([data, error]) similar to Go's approach, making error handling more explicit and predictable
  • Promise Support – Built-in support for handling asynchronous operations with the same elegant syntax
  • Type Safety – Full TypeScript support with generic types for both success and error cases
  • Zero Dependencies – Lightweight implementation with no external dependencies
  • Synchronous Support – Handle both async and sync operations with consistent patterns

🧨 Registries

💻 Installation

You can add unwrap-go with one command via:

terminal
npm install @arnavk-09/unwrap-go
deno add jsr:@arnavk-09/unwrap-go
bun add @arnavk-09/unwrap-go
pnpm add @arnavk-09/unwrap-go
yarn add @arnavk-09/unwrap-go
Deno
deno add jsr:@arnavk-09/unwrap-go
Npx
npm install @arnavk-09/unwrap-go
Bun
bun add @arnavk-09/unwrap-go
Pnpm
pnpm add @arnavk-09/unwrap-go
Yarn
yarn add @arnavk-09/unwrap-go

🚀 Usage

import { unwrapPromise, unwrapSync } from "@arnavk-09/unwrap-go";

// Async example
async function fetchData() {
  const [data, err] = await unwrapPromise(
    fetch("https://api.example.com/data"),
  );
  if (err) {
    console.error("Failed to fetch:", err);
    return;
  }
  console.log("Data:", data);
}

// Sync example
function divide(a: number, b: number) {
  const [result, err] = unwrapSync(() => {
    if (b === 0) throw new Error("Division by zero");
    return a / b;
  });
  if (err) {
    console.error("Division failed:", err);
    return;
  }
  console.log("Result:", result);
}

📚 API Reference

| Function | Description | Parameters | Return Type | | --------------------- | ---------------------------------------------------------- | ------------------------------------ | ------------------------ | | unwrapPromise<T, E> | Wraps a promise to return a Result tuple | promise: Promise<T> | Promise<Result<T, E>> | | unwrapSync<T, E> | Executes a synchronous function and returns a Result tuple | fn: () => T | Result<T, E> | | Result<T, E> | Type representing either success (T) or error (E) | T: Success typeE: Error type | [T, null] \| [null, E] |

🛣️ Roadmap

| Task | Status | | :---------------: | :----: | | 🧪 Add tests | 🔴 | | 🧪 Publish To JSR | 🟢 | | 🧪 Publish To NPM | 🟢 |

💻 Contributing

[!TIP]
We welcome contributions to improve unwrap-go! If you have suggestions, bug fixes, or new feature ideas, follow these steps:

  1. Fork the Repository you Click the Fork button at the top-right of the repo page.

  2. Clone Your Fork
    Clone the repo locally: YOU

    git clone https://github.com/ArnavK-09/unwrap-go.git
  3. Create a Branch
    Create a new branch for your changes:

    git checkout -b your-feature-branch
  4. Make Changes
    Implement your changes (bug fixes, features, etc.).

  5. Commit and Push
    Commit your changes and push the branch:

    git commit -m "feat(scope): description"
    git push origin your-feature-branch
  6. Open a Pull Request
    Open a PR with a detailed description of your changes.

  7. Collaborate and Merge
    The maintainers will review your PR, request changes if needed, and merge it once approved.

🙋‍♂️ Issues

Found a bug or need help? Please create an issue on the GitHub repository with a detailed description.

👤 Author