cron-time-generator

Zero-dependency TypeScript builder for readable, valid cron expressions

Library
npm
v2.0.3
113stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance20
Community52
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture76
Code Quality80
Innovation70
Learning Curve90

cron-time-generator is a zero-dependency TypeScript library that generates valid cron expressions from a fluent, human-readable API. Instead of hand-writing terse cron strings, you call methods like CronTime.everyDay(), CronTime.everyDayAt(6, 15), or CronTime.everyWeekDayAt(1, 30) and get back the correct expression.

It covers common scheduling patterns — every minute, hour, day, weekday, weekend, and specific days of the week at chosen times — with options to adjust the starting day. The generated strings are tested against crontab.guru and ship with full TypeScript types.

What You Get

  • A CronTime class with methods for every minute, hour, day, week, and weekend
  • Time-specific helpers like everyDayAt(hour, minute) and everyWeekDayAt
  • Weekday and weekend generators with configurable starting day
  • Zero runtime dependencies and full TypeScript type definitions
  • Output validated against crontab.guru semantics

Common Use Cases

  • Generating cron strings for node-cron or similar schedulers
  • Building schedules dynamically from user-selected intervals
  • Avoiding hand-written cron syntax errors in application code
  • Producing readable schedule configuration in TypeScript projects

Under The Hood

Architecture — The library is small and flat: index.ts defines the CronTime class as the default and named export, EveryTime.ts holds the interval-building logic, and helpers.ts provides shared formatting utilities that assemble the five cron fields (minute, hour, day-of-month, month, day-of-week). Each public method composes these fields and returns the joined string, so there is no runtime state beyond the produced expression.

Tech Stack — Written in TypeScript and compiled with tsc to dist/, with no runtime dependencies. Development uses the japa test runner and cron-validator to assert generated strings are valid, Prettier for formatting, and the package ships bundled .d.ts type definitions.

Code Quality — For its size the project is well kept: a dedicated test.ts suite validates generated expressions with cron-validator, code is Prettier-formatted, and the single-responsibility split between class, builder, and helpers keeps the logic easy to follow. Naming is explicit and self-documenting.

API Design — The API is its main strength: static methods read like plain English (everyDayAt, everyWeekDayAt, everyWeekendAt) and map one-to-one to cron output, with optional arguments for times and starting days. The dual default/named export and TypeScript types make importing frictionless, giving the library a very gentle learning curve.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search