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

@jovulic/lazy-promise

v1.3.0

Published

A lazy promise that waits until you ask it to get to work.

Downloads

277

Readme

Disclaimer

This repository is a personal project created for practicing the process of building and publishing an open-source library.


License: MIT NPM Build Status

Lazy Promise

A lazy promise that waits until you ask it to get to work.

📌 Description

LazyPromise is a lightweight utility for lazily initializing values in JavaScript and TypeScript. Specifically, it will not perform any computation until the value is accessed (e.g., awaited). Additionally, LazyPromise supports lazy chaining, allowing you to chain operations that also won’t execute until the result is needed.

✨ Features

Lazy evaluation – Compute values only when first accessed.
Lazy Chaining – Define transformations to values lazily.
Minimal – No dependencies.
TypeScript support – Fully typed.

📦 Installation

Using npm:

npm install @jovulic/lazy-promise

Using yarn:

yarn add @jovulic/lazy-promise

Using pnpm:

pnpm add @jovulic/lazy-promise

🚀 Usage

Basic Example

import { LazyPromise } from "@jovulic/lazy-promise";

const lazyValue = new LazyPromise(async () => {
  return "My Lazy Value";
});

(async () => {
  console.log(await lazyValue); // "My Lazy Value"
  console.log(await lazyValue); // "My Lazy Value" (no recomputation)
})();

Lazy Chaining

import { LazyPromise } from "@jovulic/lazy-promise";

const lazyValue = new LazyPromise(async () => {
  return "My Lazy Value";
});

const transformedValue = lazyValue.later((value) => value.toUpperCase());

console.log(await transformedValue); // "MY LAZY VALUE"

🛠️ Build

This project uses Nix for development to ensuring a consistent and reproducible environment. It is easy enough to build without it, but the following guide will be using Nix.

Follow these steps to build and work on the project locally:

  1. Install Nix: If you don't have Nix installed, follow the instructions for your platform at https://nixos.org/download.html.

  2. Clone the Repository: Clone the lazy-promise repository to your local machine.

    git clone https://github.com/jovulic/lazy-promise.git
    cd lazy-promise
  3. Enter the Development Shell: Use the following command to enter the Nix development shell. This will automatically install all the necessary dependencies defined in the flake.nix file.

    nix develop

    This command might take a while the first time as it downloads and installs the dependencies. Subsequent entries into the shell will be much faster.

  4. Install NPM Dependencies: Once inside the Nix shell, you'll need to install the project's npm dependencies. Even though Nix provides Node.js and npm, the project dependencies are managed by npm. We do this via the ctl command that is added into the development shell.

    ctl setup
  5. Build the Library: You can now build the library.

    ctl build

    This will create a dist directory containing the compiled library files.