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

@kyuki3rain/ts-result

v0.1.3

Published

A Rust-like `Result` and `Option` type implementation for TypeScript, along with a set of utilities for error handling, asynchronous operations, and more. This library aims to bring a familiar, functional-style error handling approach from Rust into the T

Readme

@kyuki3rain/ts-result

A Rust-like Result and Option type implementation for TypeScript, along with a set of utilities for error handling, asynchronous operations, and more. This library aims to bring a familiar, functional-style error handling approach from Rust into the TypeScript ecosystem.

Key Features:

  • Rust-like Result<T,E>: Use Ok and Err to represent success or failure.
  • Rust-like Option<T>: Use Some and None to represent optional values.
  • Rich Utility Methods: Methods like map, andThen, mapErr, fold, bimap, flatten, tryMap, tryForEach, fromPromise, tryCatch, and more.
  • Extensible Error Types: Standardized StdError with cause, plus common patterns (InvalidArgumentError, NotFoundError, etc.).

Installation

You can install this package using npm, yarn, or pnpm:

# npm
npm install @kyuki3rain/ts-result

# yarn
yarn add @kyuki3rain/ts-result

# pnpm
pnpm add @kyuki3rain/ts-result

Basic Usage

Here is a simple example demonstrating basic operations:

import { Ok, Err, fromPromise, Some, None } from '@kyuki3rain/ts-result';

// Using Result
const result = Ok(42)
  .map(x => x * 2)       // Ok(84)
  .fold(
    val => `Value: ${val}`,
    err => `Error: ${err}`
  );

console.log(result); // "Value: 84"

// Using fromPromise to handle async
async function fetchData() {
  const res = await fromPromise(fetch('https://example.com').then(r => r.text()));
  if (res.ok) {
    console.log("Fetched data:", res.value);
  } else {
    console.error("Fetch error:", res.error);
  }
}

// Using Option
function getOptionalValue(flag: boolean) {
  return flag ? Some("Hello") : None();
}

const opt = getOptionalValue(true)
  .map(str => str + " World")
  .unwrapOr("Default Value");

console.log(opt); // "Hello World"

Documentation

For detailed documentation, usage patterns, and more examples, we plan to provide a GitHub Pages site or additional docs in the future.

Contributing

Contributions are welcome! You can open issues for bugs or feature requests, and submit pull requests with improvements. Before contributing, please ensure:

  • Code is well-formatted and linted.
  • Tests (if applicable) run successfully.

License

This project is licensed under the MIT License.

By using this library, you agree to the terms of the MIT license.