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

@efesto-cloud/maybe-async

v0.1.1

Published

Async Maybe type for efesto-cloud — companion to @efesto-cloud/maybe

Readme

@efesto-cloud/maybe-async

Asynchronous Maybe<T> for expressing optional values produced by async work without null/undefined at the call site. Companion to @efesto-cloud/maybe.

Installation

pnpm add @efesto-cloud/maybe-async @efesto-cloud/maybe

Quick Start

import MaybeAsync, { maybeAsync, noneAsync } from "@efesto-cloud/maybe-async";

declare function findUser(id: string): Promise<User | null>; // may reject

function lookupUser(id: string) {
    return MaybeAsync.fromPromise(findUser(id)); // rejection or null -> None
}

const displayName = await lookupUser("42")
    .map((user) => user.nickname)
    .filter((n) => n.length > 0)
    .unwrapOr("anonymous");

Core Rules

  • Wrap a promise of an optional value with MaybeAsync.fromPromise(p) — a rejection or a nullish resolution both become None.
  • Use MaybeAsync.fromSafePromise(p) only when p never rejects.
  • Create from a value with someAsync(value) / noneAsync() / maybeAsync(value).
  • await a MaybeAsync<T> to get a Maybe<T>.
  • Use unwrapOrThrow() only when a missing value is a programmer error (throws NoneError).

Only NonNullable types are allowed as the contained value.

API

Constructors

someAsync(value);                       // MaybeAsync<T> — always Some
noneAsync();                            // MaybeAsync<never> — always None
maybeAsync(value);                      // Some if non-nullish, otherwise None

MaybeAsync.fromPromise(p);              // rejection or null -> None
MaybeAsync.fromSafePromise(p);          // wrap a non-rejecting promise
MaybeAsync.fromThrowable(asyncFn);      // wrap an async function; throw -> None

Instance methods

| Method | Purpose | | --- | --- | | then(...) | Implements PromiseLike, so await ma returns Maybe<T>. | | map(fn) | Transform the contained value. fn may be async. | | flatMap(fn) / andThen(fn) | Chain another Maybe / MaybeAsync / Promise<Maybe>. | | filter(predicate) | Drop to None if predicate fails. predicate may be async. | | orElse(fn) | Recover from None by returning a new Maybe/MaybeAsync. | | match(onSome, onNone) | Collapse to a single value (some-first). Returns a Promise. | | tap(fn) | Side-effect if Some; passes through. | | tapNone(fn) | Side-effect if None; passes through. | | unwrapOr(fallback) | Returns Promise<T \| U> — value or fallback. | | unwrapOrThrow() | Returns Promise<T> or throws NoneError. |

Patterns

Chain two async lookups

function loadProfile(id: string) {
    return MaybeAsync.fromPromise(fetchUser(id)).andThen((user) =>
        MaybeAsync.fromPromise(fetchAvatar(user.id)).map((avatar) => ({
            user,
            avatar,
        })),
    );
}

Bridge from a sync Maybe

import { some } from "@efesto-cloud/maybe";

function start() {
    return maybeAsync(1).andThen((n) => some(n + 1)); // MaybeAsync<number>
}

Recover

const value = await lookupPrimary(id)
    .orElse(() => lookupFallback(id))
    .unwrapOr(0);