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

gopherqueue

v1.1.2

Published

TypeScript/JavaScript SDK for GopherQueue - Enterprise-grade background job processing

Readme

GopherQueue JavaScript/TypeScript SDK

A TypeScript/JavaScript client library for GopherQueue, an enterprise-grade background job processing system.

Installation

npm install gopherqueue
# or
yarn add gopherqueue
# or
pnpm add gopherqueue

Quick Start

import { GopherQueue } from "gopherqueue";

const client = new GopherQueue("http://localhost:8080");

// Submit a job
const job = await client.submit("email", {
  to: "[email protected]",
  subject: "Hello!",
});
console.log(`Job created: ${job.id}`);

// Wait for completion
const result = await client.wait(job.id, { timeout: 30000 });
console.log(`Job completed: ${result.success}`);

Features

  • Full TypeScript support - Complete type definitions included
  • Modern async/await API - Promise-based interface
  • Zero dependencies - Uses native fetch API
  • Batch submission - Submit up to 1000 jobs atomically
  • Long-polling wait - Efficiently wait for job completion
  • SSE events - Real-time job status updates via async generators
  • Tree-shakeable - ESM and CJS builds available

API Reference

Client Options

import { GopherQueue } from "gopherqueue";

const client = new GopherQueue("http://localhost:8080", {
  apiKey: "your-api-key", // Optional API key
  timeout: 30000, // Request timeout in ms
});

Submit Job

const job = await client.submit(
  "email",
  { to: "[email protected]" },
  {
    priority: 1, // 0=Critical, 1=High, 2=Normal, 3=Low, 4=Bulk
    delay: "5m", // Delay before execution
    timeout: "30m", // Max execution time
    maxAttempts: 3, // Retry attempts
    idempotencyKey: "unique-key", // Deduplication
    tags: { env: "prod" }, // Metadata
  },
);

Batch Submit

const result = await client.submitBatch(
  [
    { type: "email", payload: { to: "[email protected]" } },
    { type: "email", payload: { to: "[email protected]" } },
  ],
  { atomic: true },
); // All-or-nothing

console.log(`Accepted: ${result.accepted}, Rejected: ${result.rejected}`);

Wait for Job

const result = await client.wait(job.id, { timeout: 60000 });
if (result.completed) {
  if (result.success) {
    console.log("Output:", result.result);
  } else {
    console.log("Error:", result.result?.error);
  }
}

Get Job Status

const job = await client.get(jobId);
console.log(`State: ${job.state}, Progress: ${job.progress}%`);

List Jobs

const jobs = await client.list({ state: "running", type: "email", limit: 100 });
for (const job of jobs) {
  console.log(`${job.id}: ${job.state}`);
}

Cancel Job

const job = await client.cancel(jobId, {
  reason: "No longer needed",
  force: true,
});

Retry Failed Job

const job = await client.retry(jobId, { resetAttempts: true });

SSE Events

// Subscribe to all job events
for await (const event of client.events("*")) {
  console.log(`Event: ${event.event}, Data:`, event.data);
}

// Subscribe to specific job
for await (const event of client.events(jobId)) {
  if (event.event === "job.completed") break;
}

Queue Statistics

const stats = await client.stats();
console.log(`Pending: ${stats.pending}, Running: ${stats.running}`);

Error Handling

import { GopherQueue, JobNotFoundError, ValidationError } from "gopherqueue";

try {
  const job = await client.get("non-existent-id");
} catch (error) {
  if (error instanceof JobNotFoundError) {
    console.log("Job not found:", error.jobId);
  } else if (error instanceof ValidationError) {
    console.log("Validation error:", error.message);
  }
}

Browser Support

This SDK uses the native fetch API and is compatible with:

  • Node.js 18+
  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Deno
  • Bun

For Node.js 16-17, you may need to provide a polyfill:

import fetch from "node-fetch";

const client = new GopherQueue("http://localhost:8080", {
  fetch: fetch as any,
});

License

MIT License