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

@pumped-fn/lite-extension-scheduler

v0.2.0

Published

Recurring schedule extension for @pumped-fn/lite: a keepAlive schedule() atom against a pluggable SchedulerBackend

Readme

@pumped-fn/lite-extension-scheduler

A recurring-schedule extension for @pumped-fn/lite: schedule() returns a keepAlive atom whose resolved value is a registration ({ trigger, next, stop }) against a pluggable SchedulerBackend. This package does not import or ship a durable backend — only an in-process, non-persistent one for dev/test.

Contract

interface Scheduler.Backend {
  register(
    spec: {
      name: string
      cadence: { cron: string } | { every: string }
      overlap: "skip" | "queue"
      catchUp: "skip" | "last" | "all"
      onError?: (error: unknown, run: { key: string; scheduledAt: Date }) => void
    },
    tick: (run: { key: string; scheduledAt: Date }) => Promise<void>
  ): { trigger(dedupKey?: string): Promise<void>; next(): Date | undefined; stop(): Promise<void> }
}
  • scheduler.backend — a required tag (tags.required(scheduler.backend)) that schedule() reads off the scope. Wire your own SchedulerBackend (durable, distributed, whatever) via createScope({ tags: [scheduler.backend(myBackend)] }).
  • scheduler.schedule({ name?, cadence, overlap?, catchUp?, flow, input, onError?, tags? }) — returns a keepAlive atom. Resolving it calls backend.register(...) once and returns the registration. On scope disposal, ctx.cleanup calls registration.stop(). name defaults to the flow's own name; if neither is set, schedule() throws immediately. Each tick creates a fresh ctx.scope.createContext(...) with the scope's ambient tags plus tags() (if given — not app.context(), which is request-scoped and never runs for background ticks), execs flow with input(), and closes the context (ok: true on success, ok: false with the error otherwise) — the error is rethrown after close() so the immediate tick promise (e.g. what trigger() awaits) rejects, while the backend's own overlap chain does not die from it (see onError below).
  • onError — called once per failed tick with the raw error and its { key, scheduledAt }. The default (when onError is omitted) is to swallow the error after the fact: the tick's context already closed with ok: false and the error attached, so observability sees it there; nothing is logged or thrown from the backend's internal bookkeeping. A tick you triggered explicitly via registration.trigger() still rejects that call's promise regardless of onError — only the backend's own queue/timer plumbing swallows-by-default.
  • overlap: "queue" chains ticks through a .then() chain that always settles fulfilled internally (a failed tick does not poison the chain) — the next queued tick still runs. Every backend (inProcess, nats) is expected to uphold this.
  • scheduler.inProcess() — croner-based backend, dev/test grade only, not durable: no persistence, no distributed coordination, ticks are lost across process restarts.
    • cadence: { cron } — a standard cron expression, parsed by croner.
    • cadence: { every } — a plain string of milliseconds (e.g. "5000" for every 5s). There is no duration-string parser here; if you need "5m"-style parsing, convert it yourself before passing every.
    • overlap: "skip" — if the previous tick's promise hasn't resolved, the next tick is dropped entirely (not queued).
    • overlap: "queue" — the next tick's tick() call is chained after the previous tick's promise settles (a simple .then() chain, no queue library, no backpressure limit).
    • catchUpinProcess has no persistence to catch up from, so only "skip" is accepted; "last"/"all" throw immediately from register() pointing at "a durable backend".
    • trigger(dedupKey?)dedupKey is accepted for contract parity with distributed backends but ignored: a single inProcess instance is trivially deduped already (there is only ever one process running the tick).
    • stop() stops the underlying croner/interval job first (no new ticks start), then awaits any in-flight or queued tick before resolving.

Backends

  • @pumped-fn/lite-extension-scheduler-nats — a distributed backend built on NATS JetStream KV: exactly-once ticks across instances via KV create while the lock holder completes within lockTtlMs (degrading to at-least-once across a lease expiry — see that package's README), catchUp derived from a last: key, and a run history/audit trail in the KV itself.

Example

import { createScope } from "@pumped-fn/lite"
import { scheduler } from "@pumped-fn/lite-extension-scheduler"
import { sweepExpired } from "./flows"

const nightlySweep = scheduler.schedule({
  name: "nightly-sweep",
  cadence: { cron: "0 2 * * *" },
  flow: sweepExpired,
  input: () => undefined,
})

const scope = createScope({ tags: [scheduler.backend(scheduler.inProcess())] })
const registration = await scope.resolve(nightlySweep)
registration.next() // next scheduled Date, or undefined
await registration.trigger() // run one tick immediately, awaiting it
await scope.dispose() // stops the registration