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

@tripod311/pump

v0.0.0

Published

Data storage for single page applications

Readme

Pump

Pump is a lightweight zero-dependency application-layer data storage.
It provides a minimal set of building blocks for managing global and local state, API calls, and reactive dependencies without unnecessary logic or restrictions.


Installation

npm install @tripod311/pump

Core Concepts

Pipe<Input, Output>

Base class for all pipes. Supports:

  • hierarchical structure (child pipes),
  • subscriptions (on, off),
  • manual update trigger (trigger).
const root = new Pipe();
const child = new Pipe();
root.addPipe("child", child);

child.on((newOut, oldOut, newIn, oldIn) => {
  console.log("Triggered!");
});
child.trigger();

StoragePipe<T>

Simple storage for global state (similar to useState, but global).
Provides data property and notifies listeners on changes.

const lang = new StoragePipe<string>();
lang.data = "en";

lang.on((newVal, oldVal) => {
  console.log("Language changed:", oldVal, "→", newVal);
});

lang.data = "ru";

DataPipe<Input, Output>

Pipe for computed values.
When input is set, it runs process() and updates output.

class DoublePipe extends DataPipe<number, number> {
  async process() {
    this._output = (this.input ?? 0) * 2;
  }
}

const dp = new DoublePipe();
dp.on((out) => console.log("Output:", out));

dp.input = 5; // → Output: 10

SyncFunctionPipe<Input, Output>

Synchronous processor.
run(input) immediately returns a result and also notifies listeners.
Optionally, you can enable wipeInput and wipeOutput to prevent storing sensitive values.

const tabPipe = new SyncFunctionPipe<string, string>((tab) => {
  return ["main", "settings"].includes(tab) ? tab : "main";
});
tabPipe.wipeInput = true;

tabPipe.on((out) => console.log("Tab set to:", out));
console.log(tabPipe.run("settings")); // "settings"
console.log(tabPipe.run("invalid"));  // "main"

AsyncFunctionPipe<Input, Output>

Asynchronous processor (e.g., for API calls).
run(input) returns a Promise<Output> and also notifies listeners.
Supports wipeInput and wipeOutput.

interface Credentials { email: string; password: string; }

const loginPipe = new AsyncFunctionPipe<Credentials, { error: boolean }>(
  async (cred) => {
    const res = await fetch("/api/login", {
      method: "POST",
      body: JSON.stringify(cred),
    });
    return await res.json();
  }
);
loginPipe.wipeInput = true;

const response = await loginPipe.run({ email: "[email protected]", password: "secret" });
console.log(response);

Pump

Global registry of pipes.
Allows building a provider tree and accessing pipes by string paths.

const pump = new Pump();

const settings = new Pipe();
pump.addPipe("settings", settings);

const lang = new StoragePipe<string>();
settings.addPipe("language", lang);

(pump.getPipe("settings.language") as StoragePipe<string>).data = "en";

When to Use

  • StoragePipe — global variables (language, theme, authToken).
  • DataPipe — computed or dependent values.
  • SyncFunctionPipe — pure functions, validation, or transformations.
  • AsyncFunctionPipe — API calls or async operations.
  • Pipe — container/structural node in the tree.

Example: Localization + Routing

// language
const lang = new StoragePipe<string>();
pump.addPipe("language", lang);
lang.data = "en";

// translation
const t = new SyncFunctionPipe<{ key: string; lang: string }, string>(
  ({ key, lang }) => translations[lang][key] ?? key
);
pump.addPipe("translate", t);

// router
const router = new SyncFunctionPipe<string, void>((path) => {
  history.pushState({}, "", path);
});
pump.addPipe("router", router);

// usage
lang.on((newLang) => {
  console.log("Current submit label:",
    t.run({ key: "submit", lang: newLang })
  );
});

router.run("/dashboard");

Features

  • Zero dependencies.
  • Minimal API (easy to extend or inherit).
  • Suitable for both global and local state.
  • Flexible provider tree (api.login, settings.language).
  • Built-in support for wiping input/output in FunctionPipe for sensitive data.