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

@nifrajs/jobs

v2.2.0

Published

Typed background jobs for nifra — enqueue work off the request path with retries, exponential backoff, and dead-lettering on a pluggable store. In-process worker for Bun/Node/Deno (Workers use CF Queues); the async companion to @nifrajs/cron. Dependency-f

Readme

@nifrajs/jobs

Typed background jobs for nifra — enqueue work off the request path, run it with retries + exponential backoff + dead-lettering on a pluggable store. The async companion to @nifrajs/cron (cron schedules; jobs does the deferred work — email, webhooks, image processing). Dependency-free.

import { createQueue } from "@nifrajs/jobs"
import { t } from "@nifrajs/schema"

const q = createQueue()

const email = q.define("send-email", {
  input: t.object({ to: t.string(), subject: t.string() }), // validated at enqueue (the trust boundary)
  retries: { attempts: 5 },                                 // 5 tries, exponential backoff, then dead-letter
  async handler({ to, subject }, ctx) {
    await send(to, subject) // ctx = { id, name, attempt }
  },
})

// In a route handler — enqueue and return immediately:
await email.enqueue({ to: "[email protected]", subject: "Welcome" })
await email.enqueue({ to: "[email protected]", subject: "Later" }, { delayMs: 60_000 }) // run in 1 min

// Start the worker on a long-running server (Bun/Node/Deno):
const worker = q.start({ concurrency: 4 })
// graceful shutdown: await worker.stop()

enqueue is typed against the handler's payload, and input (any Standard Schema validator — @nifrajs/schema's t, Zod, Valibot, …) validates it before it's stored, so a bad payload fails at the call site, not three retries later.

Retries

Per-job: retries: number (attempts) or { attempts, backoff }. A handler that throws is routed to onError, then retried with the backoff delay; after the last attempt it's dead-lettered, not lost.

import { exponentialBackoff, fixedBackoff } from "@nifrajs/jobs"

q.define("flaky", { retries: { attempts: 3, backoff: fixedBackoff(5_000) }, handler })
createQueue({ backoff: exponentialBackoff({ baseMs: 500, maxMs: 60_000, jitter: 0.2 }) }) // queue default

Stores

The default MemoryJobStore is single-process — correct for dev and a single server, but not durable and not multi-worker. Implement the JobStore interface (enqueue / lease / complete / retry / deadLetter / counts) over Redis/Postgres for durability or horizontal workers:

const q = createQueue({ store: new RedisJobStore(redis) })

Leasing is at-least-once: a leased job is hidden for leaseMs; a worker that dies mid-job releases it back automatically. Make handlers idempotent.

Cloudflare Workers

Workers has no long-lived process, so don't call start(). Back the queue with a durable store and a CF Queue, enqueue via the producer binding, and drain from the consumer:

export default {
  async queue(_batch, env) {
    const q = createQueue({ store: new D1JobStore(env.DB) })
    await q.process() // one round; the platform schedules invocations
  },
}

API

  • createQueue(options?)Queue{ store?, onError?, now?, defaultAttempts?, backoff? }.
  • queue.define(name, { handler, input?, retries? }) → typed JobHandle with .enqueue(payload, { delayMs? | runAt? }).
  • queue.enqueue(name, payload, options?) — enqueue by name.
  • queue.start({ concurrency?, pollIntervalMs?, leaseMs? })Worker (.stop() drains gracefully).
  • queue.process() — run one poll round (for Workers / custom drivers). queue.drain() — process until empty.
  • queue.counts(){ pending, active, dead }. queue.store — the underlying store.
  • Stores: MemoryJobStore. Backoff: exponentialBackoff, fixedBackoff, noBackoff.

For AI agents

Start with LLM.md — this package's contract card (the exports you call + its footguns), one cheap read instead of the whole corpus. For the wider framework: the repo's AGENTS.md is the copy-paste quick reference, and llms-full.txt is the full machine-readable corpus. Run nifra check as the done-gate, or nifra mcp to give the agent live project tools.