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

@monlite/cron

v0.3.3

Published

Cron-style job scheduling for monlite: persisted schedules, 5-field cron, multi-process safe — on SQLite (@monlite/core) or Postgres (@monlite/postgres).

Readme

@monlite/cron

Cron-style scheduling for monlite. Persisted schedules survive restarts, a zero-dependency 5-field cron parser, and atomic firing so multiple processes won't double-run the same occurrence.

  • SQLite (@monlite/core) — createCron(db), a synchronous API.
  • Postgres (@monlite/postgres) — createPgCron(db), same model with an async API (await cron.schedule(...)).
npm install @monlite/core @monlite/cron

Quick start

import { createDb } from "@monlite/core";
import { createCron } from "@monlite/cron";

const db = createDb("app.db");
const cron = createCron(db);

cron.schedule("cleanup", "0 3 * * *", async () => {
  await purgeOldRows(); // runs every day at 03:00 local time
});

cron.on("error", (err, name) => console.warn(name, err));

Cron syntax

Standard 5-field format: minute hour day-of-month month day-of-week

| Pattern | Meaning | |---|---| | * * * * * | Every minute | | */15 * * * * | Every 15 minutes | | 0 9 * * 1 | Monday 09:00 | | 0 9-17 * * * | Hourly, 9am–5pm | | 0 0 1,15 * * | 1st and 15th at midnight |

Day-of-week is 0–6 (0 = Sunday). Times are local. When both day-of-month and day-of-week are restricted, either match fires (POSIX behavior).

API

const cron = createCron(db, {
  checkInterval: 1000, // poll cadence in ms (default: 1000)
});

cron.schedule(name, cronExpr, handler); // register or update a schedule, start firing
cron.unschedule(name);                  // remove a schedule
cron.next(name);                        // next run as epoch ms, or undefined
cron.on("error", (err, name) => {});
cron.stop();                            // stop firing (schedules remain in the db)

// Utility
import { nextCronRun } from "@monlite/cron";
nextCronRun("0 9 * * 1"); // → Date of the next Monday 09:00

Firing is atomic — each occurrence is claimed from the schedule row, so running the same schedule in multiple processes fires each occurrence exactly once.

Composing with @monlite/queue

A cron handler runs in-process. For durable work that survives crashes and gets retried, have the handler enqueue a job into @monlite/queue instead of doing the work directly:

import { createQueue } from "@monlite/queue";

const queue = createQueue(db);
queue.process("report", async (job) => generateReport(job.payload));

cron.schedule("nightly-report", "0 0 * * *", () => {
  queue.add("report", { day: new Date().toISOString() });
});

The schedule is persisted; the work is durable and retried.

License

MIT