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

@j13b/scheduler

v0.1.1

Published

A timezone-aware recurrence and dispatch engine: a pure-data rule DSL, IANA timezones, DST-aware generators and a cron-style dispatcher.

Readme

@j13b/scheduler

A timezone-aware recurrence and dispatch engine. Pure-data rule DSL, IANA timezone support, DST-aware generators, and a cron-style dispatcher.

Install

npm install @j13b/scheduler

Quick start

import {
  Scheduler,
  InMemorySchedulerPort,
  Dispatcher,
  InMemoryDispatcherStore,
  Day,
} from "@j13b/scheduler";

const port = new InMemorySchedulerPort();
const scheduler = new Scheduler(port);

await scheduler.add({
  id: "standup",
  timezone: "America/Denver",
  rule: {
    kind: "daysOfWeek",
    days: [Day.Monday, Day.Tuesday, Day.Wednesday, Day.Thursday, Day.Friday],
    timeOfDay: 9 * 60 * 60 * 1000, // 9:00 wall-clock
    weekInterval: 1,
    seriesStart: Date.UTC(2026, 0, 1),
    seriesEnd: null, // open-ended
  },
  payload: { type: "standup" },
});

const dispatcher = new Dispatcher({
  scheduler,
  store: new InMemoryDispatcherStore(),
  fire: async (event) => {
    console.log(`Fire ${event.templateId} at ${new Date(event.startTimestamp).toISOString()}`);
  },
});

await dispatcher.start();

What's in the box

  • Recurrence rules — InstantRule, LocalDateTimeRule, AnchoredRule, DaysOfWeekRule, WeeksOfMonthRule, MonthsOfYearRule, YearlyRule, DaysOfMonthRule, DaysOfYearRule. Pure-data, JSON-serializable, exhaustive TypeScript union. The two single-occurrence kinds: InstantRule fires at an absolute UTC instant (timezone-independent); LocalDateTimeRule fires once at a wall-clock date/time resolved (DST-aware) in the template's timezone.
  • TimeSpan — two flavors of "how long does an occurrence last":
    • { type: "duration", ms } — fixed real-elapsed time (payroll-correct, ignores DST jumps).
    • { type: "hourSpan", hours } — wall-clock hours (calendar-correct, flexes with DST).
  • Timezone math — built on Intl.DateTimeFormat over IANA zones, zero deps for date logic. Spring-forward gaps and fall-back overlaps are resolved by a configurable per-template disambiguation policy ("compatible" default, plus "earlier", "later", "reject", and "skip"), mirroring the Temporal proposal.
  • Alterations — per-occurrence overrides (skip, reschedule, replace).
  • Dispatcher — drives a Scheduler in real time; catch-up pass for missed events, resumes early when the schedule changes.

API surface

See src/index.ts for the full export list. Notable types:

  • RecurrenceRule — discriminated union over the nine rule kinds.
  • ScheduleTemplate — { id, rule, timezone, disambiguation?, payload }. timezone is required and validated at write time (use "UTC" for zone-free scheduling; it's ignored by the absolute instant/anchored rules).
  • validateRule(rule) — checks a rule's whole shape (every required field present, typed and in range; no fields its kind lacks) and throws an Error naming the field and the form it expects. Scheduler.add/update run it, so a rule from JSON or an LLM fails with a clear message instead of crashing a generator. validateTimeSpan and RULE_KINDS are exported too.
  • ScheduledEvent — { templateId, occurrenceKey, startTimestamp, endTimestamp, payload, alterationId? }.
  • Disambiguation — DST-edge resolution policy: "compatible" | "earlier" | "later" | "reject" | "skip".
  • SchedulerPort — async storage interface; an InMemorySchedulerPort ships with the package.
  • DispatcherStore — durable record of the dispatcher's catch-up cursor.

License

MIT