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-js-parser

v1.1.0

Published

Cron expression parser to human readable format from Expression as well as Individual values

Downloads

1,028

Readme

Hey there! Would you take a quick second to ⭐️ star this repo?

cron-js-parser

📢Support for Unix scheduler coming soon

Contents

Introduction

Cron expressions are powerful, but can be pretty confusing. The aim of this library is to standardize javascript logic for handling cron expressions.

✨ Introducing JCON - Javascript Cron Object Notation

Supported Schedulers

JCON

Overview

ℹ️ More on mode objects can be found here

{
  seconds: <Mode Object>,
  minutes: <Mode Object>
  hours: <Mode Object>,
  daysOfMonth?: <Mode Object>,
  months: <Mode Object>,
  daysOfWeek?: <Mode Object>,
  years?: <Mode Object>
}

Mandatory Fields - seconds, minutes, hours, months Optional Fields - daysOfMonth, daysOfWeek, years

Mode Object

These constants define the allowed string literal values for the mode property in the respective types.

Types

1. Cycle

Represents an object with a fixed mode indicating a cycle.

type Cycle = {
  mode: typeof cycle;
};

2. At

Represents an object with a mode 'at' and an array of numeric values.

type At = {
  mode: typeof at;
  value: number[];
};

3. StartAtRepeatCycleEvery

Represents an object with a mode 'StartAtRepeatCycleEvery' and a StartAt object as its value.

type StartAtRepeatCycleEvery = {
  mode: typeof startAtRepeatCycleEvery;
  value: StartAt;
};

4. StartCycleInRange

Represents an object with a mode 'startCycleInRange' and an InRange object as its value.

type StartCycleInRange = {
  mode: typeof startCycleInRange;
  value: InRange;
};

Summary

Type| Property | Type | Description | ----| -------- | -------------- | ----------------------------| cycle| mode | typeof cycle | Must be the literal string 'cycle' | At| mode | typeof at | Must be the literal string 'at' | At| value | number[] | An array of numbers specifying values | StartAtRepeatCycleEvery| mode | typeof startAtRepeatCycleEvery | Must be the literal string 'startAtRepeatCycleEvery' | StartAtRepeatCycleEvery| value | StartAt | An object containing startAt and every numbers | StartCycleInRange| mode | typeof startCycleInRange | Must be the literal string 'startCycleInRange' | StartCycleInRange| value | InRange | An object defining a range with from and to |

Quartz Scheduler

Methods Overview

Parsers

parseCronExpression
export const parseCronExpression = (cronValues: QuartzCronObj): string
Description

Converts a structured QuartzCronObj back into a cron expression string.

Input
  • cronValues (QuartzCronObj): An object representing the components of a cron expression.
Output
  • Returns a string representing the cron expression generated from the input object.
parseHumanReadable
export const parseHumanReadable = (
  cronExpr: string,
  cronValues: QuartzCronObj,
  language: string
): string
Description

Generates a human-readable description of a cron expression in the specified language.

Inputs
  • cronExpr (string): The cron expression string. If empty or falsy, the function will generate the expression from cronValues.
  • cronValues (QuartzCronObj): An object representing the cron expression components.
  • language (string): The locale/language code (e.g., 'en', 'fr', 'de') to format the description.
Output
  • Returns a string containing a verbose, human-readable description of the cron schedule in the specified language.

Deparser

deparseCronExpression
Description

Converts a cron expression string into a structured QuartzCronObj representation.

Input
  • cronExpr (string): A valid cron expression string in Quartz format.
Output
  • Returns a QuartzCronObj — an object representing the parsed components of the cron expression.

Example for Quartz

Input

const { 
  parseCronExpression, parseHumanReadable, deparseCronExpression
} = require('./cron-js-parser.quartz');

let obj = {
  seconds: {
    mode: 'at',
    value: [1, 5, 10]
  },
  minutes: {
    mode: 'StartAtRepeatCycleEvery',
    value: {
      startAt: 1,
      every: 10
    }
  },
  hours: {
    mode:'startCycleInRange',
    value: {
      from: 2,
      to: 20
    }
  },
  daysOfMonth: {
    mode: 'cycle'
  },
  months: {
    mode: 'cycle'
  },
  years: {
    mode: 'at',
    value: [2020, 2022]
  },
  daysOfWeek: {
    mode: 'on',
    value: {
      isLastWeek: false,
      dayIndex: 6,
      weekIndex: 3
    } 
  }
};
const cron = parseCronExpression(obj); 
console.log(cron);
lang = 'fr' //French
console.log(parseHumanReadable(cron,{},lang))
const deparsed = deparseCronExpression(cron)
console.log(deparsed)
console.log(parseCronExpression(deparsed))

Output

1,5,10 1/10 2-20 ? * ? 2020,2022
1, 5, et 10 secondes après la minute, toutes les 10 minutes, à partir de 1 minutes après l'heure, de 02:00 à 20:59, tous les jours, uniquement en 2020 et 2022
{
  seconds: { mode: 'at', value: [ 1, 5, 10 ] },
  minutes: { mode: 'StartAtRepeatCycleEvery', value: { startAt: 1, every: 10 } },
  hours: { mode: 'startCycleInRange', value: { from: 2, to: 20 } },
  daysOfMonth: undefined,
  months: { mode: 'cycle' },
  years: { mode: 'at', value: [ 2020, 2022 ] }
}
1,5,10 1/10 2-20 ? * ? 2020,2022

Cron Trigger Standards

Days of Week

  • 1 - SUN - Sunday
  • 2 - MON - Monday
  • 3 - TUE - Tuesday
  • 4 - WED - Wednesday
  • 5 - THU - Thursday
  • 6 - FRI - Friday
  • 7 - SAT - Saturday

Support

  • Javascript
  • Typescript
  • Nodejs
  • Browser

Important Links

  • https://www.freeformatter.com/cron-expression-generator-quartz.html