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

@topgunbuild/client

v2.0.2

Published

[![npm](https://img.shields.io/npm/v/@topgunbuild/client)](https://www.npmjs.com/package/@topgunbuild/client) [![License](https://img.shields.io/npm/l/@topgunbuild/client)](https://github.com/TopGunBuild/topgun/blob/main/LICENSE)

Readme

@topgunbuild/client

npm License

Browser and Node.js client for TopGun — build real-time apps that work offline. Local writes are instant and survive disconnects; reconnecting clients sync seamlessly with automatic conflict resolution.

Install

npm install @topgunbuild/client @topgunbuild/adapters

Quickstart

import { TopGunClient } from '@topgunbuild/client';
import { IDBAdapter } from '@topgunbuild/adapters';

const client = new TopGunClient({
  serverUrl: 'ws://localhost:8080',   // optional — omit for local-only
  storage: new IDBAdapter('my-app'),
});
client.start();

// Reactive map — fires on every change
const todos = client.getMap('todos');
todos.subscribe((entries) => render(entries));

// Optimistic write — applies locally, syncs in background
todos.set('todo-1', { text: 'Buy milk', done: false });

API at a glance

Construction

new TopGunClient({
  storage: new IDBAdapter('my-app'),  // required
  serverUrl: 'ws://...',              // optional — single-server mode
  // or
  cluster: { seeds: ['ws://node1', 'ws://node2'] },  // optional — cluster mode
});

client.start();      // initialize storage (non-blocking)
await client.close(); // graceful shutdown

Omit serverUrl and cluster to run local-only (no network, IndexedDB only).

Reactive primitives

| Primitive | Use for | Subscribe callback | |-----------|---------|--------------------| | client.getMap(name) | Last-write-wins key/value | (entries: [K, V][]) => void | | client.getORMap(name) | Multimap, concurrent adds | (entries: [K, V[]][]) => void | | client.query(name, filter) | Filtered live view | (results: T[]) => void | | client.topic(name) | Fire-and-forget pub/sub | (data, ctx) => void | | client.getPNCounter(name) | Distributed counter | (value: number) => void |

Filtered queries

import { Predicates } from '@topgunbuild/client';

const open = client.query('todos', {
  where: { done: false },
  // or use Predicates for richer filters:
  predicate: Predicates.and(
    Predicates.equal('done', false),
    Predicates.greaterThan('priority', 5),
  ),
  sort: { createdAt: 'desc' },
  limit: 20,
});

open.subscribe((results) => render(results));
open.onDelta((changes) => log(changes));   // add / update / remove deltas

Distributed locks

const lock = client.getLock('migration');
const acquired = await lock.lock(30_000);   // TTL in ms
if (acquired) {
  try { await runMigration(); }
  finally { await lock.unlock(); }
}

Hybrid search (BM25 + filters)

const results = await client.search('articles', 'distributed crdts', {
  limit: 10,
  minScore: 0.5,
});

React users

Use @topgunbuild/react for hooks (useQuery, useMap, useMutation, ...).

Documentation

License

Apache-2.0