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

@ludeschersoftware/promise

v1.1.0

Published

A minimal utility for observing the lifecycle of a single Promise. It lets you check whether a promise is pending, fulfilled, or rejected, and safely access its result or error without needing extra state handling.

Readme

A minimal utility for observing the lifecycle of a Promise — and managing collections of them. Check whether a promise is pending, fulfilled, or rejected, and access its result or error without blocking.


✨ Features

  • Track a single promise with TrackedPromise
  • Manage multiple promises with TrackedPromisePool
  • Check promise state synchronously in loops or render ticks (no need to await)
  • Query promises by status: Pending, Fulfilled, Rejected
  • Clear resolved tasks and keep only active ones
  • Fully typed with TypeScript

📦 Installation

npm install @ludeschersoftware/promise

or with yarn:

yarn add @ludeschersoftware/promise

🔹 Usage

1. TrackedPromise — observe a single promise

import { TrackedPromise, PromiseStatus } from "@ludeschersoftware/promise";

const tracked = new TrackedPromise(fetch("/api/data").then(res => res.json()));

function loop() {
    if (tracked.Status === PromiseStatus.Fulfilled) {
        console.log("Data ready:", tracked.Result);
    } else if (tracked.Status === PromiseStatus.Rejected) {
        console.error("Failed:", tracked.Error);
    } else {
        console.log("Still loading...");
    }

    // Keep looping without blocking on the promise
    requestAnimationFrame(loop);
}

loop();

➡️ Unlike plain promises, you don’t need to await — you can check the status non-blocking inside a loop.


2. TrackedPromisePool — manage multiple promises

import { TrackedPromisePool } from "@ludeschersoftware/promise";

const pool = new TrackedPromisePool();

pool.Add(fetch("/assets/texture.png").then(r => r.blob()));
pool.Add(fetch("/assets/sound.mp3").then(r => r.blob()));

function gameLoop() {
    for (const p of pool.Fulfilled) {
        console.log("Loaded:", p.Result);
    }

    for (const p of pool.Rejected) {
        console.warn("Failed:", p.Error);
    }

    if (!pool.Resolved) {
        requestAnimationFrame(gameLoop); // keep looping until all done
    } else {
        console.log("All assets loaded!");
    }
}

gameLoop();

➡️ Perfect for game loops and render cycles, where you want to check async state every frame without blocking execution.


📖 API

enum PromiseStatus

  • PromiseStatus.Pending
  • PromiseStatus.Fulfilled
  • PromiseStatus.Rejected

class TrackedPromise<T>

Wraps a Promise<T> and exposes its state.

  • Status: PromiseStatus
  • Result?: T
  • Error?: any
  • Promise: Promise<T>

class TrackedPromisePool

Manages a collection of tracked promises.

  • Add<T>(promise: Promise<T>): TrackedPromise<T>
  • Active: TrackedPromise<any>[]
  • Fulfilled: TrackedPromise<any>[]
  • Rejected: TrackedPromise<any>[]
  • All: TrackedPromise<any>[]
  • Resolved: boolean (true if no pending promises remain)
  • ClearResolved(): void (removes all fulfilled & rejected promises, keeps only pending)

🧪 Tests

The project uses Jest.

npm test
npm run test:coverage

📦 Module Support

This package ships with both:

  • CommonJS (require)
  • ES Modules (import)

So it works in:

  • Node.js projects
  • Modern bundlers (Vite/Webpack/Rollup)
  • TypeScript projects

📜 License

MIT © Johannes Ludescher