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

cron-bomb

v3.1.0

Published

A TypeScript-first library for generating recurring events from cron expressions.

Readme

cron-bomb

npm version License: ISC

TypeScript-first helper for turning recurring event objects (described by cron expressions) into concrete occurrences over a date range.

Store a single crontab on your event (opening hours, bookings, reminders) and expand it only when you need a finite list — including cancellations (exclude) and schedule overlap checks (intersection).

Install

npm install cron-bomb
pnpm add cron-bomb
yarn add cron-bomb

Requires Node.js 18+ (required by cron-parser v5).

Quick start

import { explode } from "cron-bomb";

const start = new Date("2020-01-01T00:00:00.000Z");
const end = new Date("2020-01-08T00:00:00.000Z");

const occurrences = explode(
  {
    title: "Weekday standup",
    cron: "0 9 * * 1-5",
  },
  { start, end },
);

// [
//   { title: "Weekday standup", cron: "2020-01-01T09:00:00.000Z" },
//   { title: "Weekday standup", cron: "2020-01-02T09:00:00.000Z" },
//   ...
// ]

Cron evaluation defaults to "UTC". Pass an IANA tz (e.g. "Australia/Sydney") when you need another zone.

API

import {
  explode,
  intersection,
  type ExplodeCompareFn,
  type ExplodeOptions,
  type ExplodedEvent,
  type IntersectionOptions,
} from "cron-bomb";

explode(data, options?)

Expand one event object (or an array of them) into occurrence rows for (start, end].

Each input must include a crontab string (default field name "cron"). Every other property is copied onto each result. The crontab field is replaced with an ISO 8601 timestamp (Date#toISOString()) per occurrence.

explode(data, {
  start?: Date; // default: new Date()
  end?: Date; // default: new Date()
  field?: string; // crontab property name; default: "cron"
  exclude?: Array<Date | string>; // exact-ms cancellations
  tz?: string; // IANA timezone; default: "UTC"
  compareFn?: (a, b) => number; // optional; Array.prototype.sort contract
});

Behavior notes

| Topic | Behavior | | --- | --- | | Array input | Events are expanded in input order and concatenated (all of A, then all of B). Not interleaved by date unless you pass compareFn. | | compareFn | Applied to the full result after expansion. Same contract as Array.prototype.sort. Omit to keep concat order. | | exclude | Date and/or ISO strings; compared by exact epoch millisecond. | | Custom field | Reads that property for the crontab and writes ISO timestamps back to the same key. | | Timezone | tz is passed to cron-parser (default "UTC"). Use an IANA name for other zones. | | Range bounds | An occurrence exactly equal to start is skipped (iteration starts after currentDate). An occurrence exactly equal to end is included. | | Errors | RangeError if start > end; ReferenceError if the crontab field is missing; invalid cron throws from cron-parser. |

Custom field

explode(
  { title: "Shift", schedule: "10 0 * * 1-5" },
  { start, end, field: "schedule" },
);
// => [{ title: "Shift", schedule: "2020-01-01T00:10:00.000Z" }, ...]

Cancellations

explode(event, {
  start,
  end,
  exclude: [
    "2020-01-02T00:10:00.000Z",
    new Date("2020-01-03T00:10:00.000Z"),
  ],
});

Sorting multipass output

explode([eventA, eventB], {
  start,
  end,
  // ISO timestamps sort lexicographically; tie-break on title if you want
  compareFn: (a, b) =>
    a.cron.localeCompare(b.cron) ||
    String(a.title).localeCompare(String(b.title)),
});

intersection(options)

Return ISO timestamps that appear in both crontab schedules within a range. Useful for clash detection (e.g. recurring booking vs public holiday).

intersection({
  cron1: string;
  cron2: string;
  start?: Date;
  end?: Date;
  tz?: string; // default: "UTC"
}): string[];
const overlaps = intersection({
  cron1: "0 9 * * 1-5",
  cron2: "0 9 * * 1", // Mondays
  start: new Date("2020-01-01T00:00:00.000Z"),
  end: new Date("2020-01-31T00:00:00.000Z"),
});
// => ["2020-01-06T09:00:00.000Z", "2020-01-13T09:00:00.000Z", ...]

Results follow cron1’s expansion order. Returns only timestamp strings, not full event objects.

Cron syntax

Standard five-field cron expressions as understood by cron-parser. Helpful editor: crontab.guru.

Development

git clone https://github.com/Sam-Scheding/cron-bomb-js.git
cd cron-bomb-js
npm install
npm test
npm run build

| Script | Description | | --- | --- | | npm test | Run Jest + coverage | | npm run build | Emit dist/ (JS + typings) | | npm run lint | ESLint | | npm run format | Prettier |

License

ISC © Sam Scheding

Links