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

@qcksys/croncheck

v0.0.2

Published

Modern library for parsing and matching cron expressions

Readme

@qcksys/croncheck

A modern TypeScript library for parsing and matching cron expressions with timezone support.

Installation

npm install @qcksys/croncheck
# or
pnpm add @qcksys/croncheck
# or
yarn add @qcksys/croncheck

Usage

import { parse, getFutureMatches, isTimeMatch } from '@qcksys/croncheck';

// Parse a cron expression
const result = parse('0 9 * * 1-5');
if (result.success) {
  // Get the next 5 matching dates
  const matches = getFutureMatches(result.expression, {
    matchCount: 5,
    timezone: 'America/New_York'
  });
  console.log(matches);
}

// Check if a date matches a cron expression
const { expression } = parse('*/15 * * * *');
const matches = isTimeMatch(expression, new Date());

Cron Expression Format

Supports 4-5 field expressions:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12 or JAN-DEC)
│ │ │ │ ┌───────────── day of week (0-6 or SUN-SAT, optional)
│ │ │ │ │
* * * * *

Supported Syntax

| Symbol | Description | Example | |--------|-------------|---------| | * | Any value | * * * * * (every minute) | | ? | Omit field | 0 0 ? * 1 (Mondays at midnight) | | , | List | 0 9,17 * * * (9am and 5pm) | | - | Range | 0 9-17 * * * (every hour 9am-5pm) | | / | Step | */15 * * * * (every 15 minutes) | | L | Last day of month | 0 0 L * * (last day of month) | | LW | Last weekday of month | 0 0 LW * * | | nW | Nearest weekday to day n | 0 0 15W * * (nearest weekday to 15th) | | n#m | Nth occurrence of day | 0 0 ? * 5#3 (3rd Friday) | | nL | Last occurrence of weekday | 0 0 ? * 5L (last Friday) |

Predefined Macros

| Macro | Equivalent | |-------|------------| | @yearly | 0 0 1 1 * | | @monthly | 0 0 1 * * | | @weekly | 0 0 ? * 0 | | @daily | 0 0 * * * | | @hourly | 0 * * * * | | @minutely | * * * * * |

Month and Day Aliases

  • Months: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
  • Days: SUN, MON, TUE, WED, THU, FRI, SAT

API

parse(expression: string): ParsedCronExpression

Parses a cron expression string into a structured object.

const result = parse('0 9 * * 1-5');
// {
//   success: true,
//   pattern: '0 9 * * 1-5',
//   expression: { minute: {...}, hour: {...}, ... }
// }

getFutureMatches(expression: CronExpression, options?: MatchOptions): Date[]

Returns an array of future dates that match the cron expression.

const matches = getFutureMatches(expression, {
  startAt: new Date(),        // Start searching from this date (default: now)
  matchCount: 5,              // Number of matches to find (default: 2)
  timezone: 'UTC',            // Timezone for matching (default: 'UTC')
  maxLoopCount: 1000,         // Max iterations to prevent infinite loops
  matchValidator: (date) => { // Custom validation function
    return date.getHours() !== 12; // Skip noon
  }
});

isTimeMatch(expression: CronExpression, date: TZDate): boolean

Checks if a specific date matches a cron expression.

import { TZDate } from '@date-fns/tz';

const date = new TZDate(new Date(), 'America/New_York');
const matches = isTimeMatch(expression, date);

Day of Month / Day of Week Logic

When both day_of_month and day_of_week are specified (not * or ?), the match uses OR logic - either condition can satisfy the match. When only one is specified, only that constraint applies.

// Matches on the 15th OR on Fridays
parse('0 9 15 * 5');

// Matches only on the 15th (day_of_week is *)
parse('0 9 15 * *');

// Matches only on Fridays (day_of_month is ?)
parse('0 9 ? * 5');

License

MIT