npm croner 10.0.0

latest release: 10.0.1
7 hours ago

Changed

  • BREAKING: ? character now acts as wildcard alias (same as *) per OCPS 1.4, instead of substituting current time values (#293)
  • BREAKING: Minimum Deno version increased from 1.16 to 2.0
  • Renamed legacyMode option to domAndDow (backward compatible, legacyMode still works) (#309)
  • Improved error messages for timezone/date conversion failures (#307)
  • Unified implementations of nextRuns/previousRuns and findNext/findPrevious (#319)
  • Refactored to extract duplicate code patterns into helper methods (#322)
  • Consolidated duplicate tests across OCPS compliance and legacy test suites (#320)

Added

  • OCPS 1.2 Compliance: Year field support for 7-field patterns (range 1-9999) (#288)
  • OCPS 1.3 Compliance: W (weekday) modifier for nearest weekday scheduling (#288)
  • OCPS 1.4 Compliance: + (AND logic) modifier for explicit day matching (#288)
  • OCPS 1.4 Compliance: @midnight and @reboot pattern nicknames (#288)
  • previousRuns() method to enumerate past scheduled execution times (#315)
  • match() method to check if a date matches a cron pattern (#317)
  • getOnce() method to return original run-once date for date-based jobs (#332)
  • dayOffset option for scheduling before/after pattern matches (#308)
  • mode option for cron pattern precision control with enforcement and flexible modes (#294)
  • alternativeWeekdays option for Quartz-style weekday numbering (1=Sunday...7=Saturday) (#312)
  • domAndDow option to replace deprecated legacyMode (no breaking change) (#309)
  • sloppyRanges option to allow relaxed, backward-compatible non-standard range/stepping syntax (#327)
  • Support for leading/trailing whitespace and consecutive whitespace in patterns
  • Case-insensitive L and W modifiers in cron patterns (#328)
  • Comprehensive edge case tests for year stepping, nth weekday, W modifier, Quartz mode, and boundary conditions (#329)

Fixed

  • DST bugs causing rapid-fire execution during timezone transitions (Issue #286) (#285)
  • DST bug with UTC timezone causing hour skipping during local DST transitions (Issue #284) (#285)
  • Cron job stopping when catch callback throws with protect enabled (#337)
  • L modifier bug and documented W modifier edge cases (#306)
  • getPattern() returning wrong value for date-based jobs (#331)
  • Node.js timezone test failures caused by hour 24 midnight formatting (#291)
  • Unclear error messages for timezone/date conversion failures (#307)

Documentation

  • Complete OCPS 1.0-1.4 compliance documentation (#292)
  • Migration guide for v9.x to v10.0 upgrade path (#310)
  • Documented zero dependencies advantage over Luxon-dependent alternatives (#318)
  • Updated year field in README ASCII pattern diagram (#311)
  • Documented getOnce() and previousRuns() features (#333)

Upgrading from 9.x to 10.x

Version 10.x introduces new pattern syntax features and configuration options.

New pattern syntax:

  • Year field: 7-field patterns now supported. Example: 0 12 * * * * 2025 runs only in 2025.
  • W modifier: Nearest weekday to a date. Example: 0 12 15W * * runs on weekday closest to the 15th.
  • + modifier: Explicit AND logic for day matching. Example: 0 12 15 * +FRI runs only when 15th is Friday.

Changed pattern behavior:

  • ? character: Now acts as wildcard alias (same as *). Previously replaced with current time values.

Option renamed (backward compatible):

  • legacyMode is deprecated but still works. Use domAndDow instead.
  • domAndDow: false (default) uses OR logic - matches if day of month OR day of week matches.
  • domAndDow: true uses AND logic - matches only when both day of month AND day of week match.
  • Note: legacyMode: true equals domAndDow: false.

New options:

  • dayOffset - Offset scheduled dates by a number of days. Positive shifts forward, negative shifts backward. Example: dayOffset: -1 schedules one day before the pattern match.
  • mode - Specify the cron pattern mode: "auto" (default), "5-part", "6-part", "7-part", "5-or-6-parts", or "6-or-7-parts". Controls how many fields are expected and how seconds/years are handled.
  • alternativeWeekdays - Enable Quartz-style weekday numbering where Sunday=1, Monday=2, ..., Saturday=7. When false (default), uses standard cron format where Sunday=0, Monday=1, ..., Saturday=6. Example: new Cron("0 0 0 * * 1", { alternativeWeekdays: true }) runs on Sunday in Quartz mode.
  • sloppyRanges - Enable non-standard stepping formats for backward compatibility. When false (default), only wildcard (*/step) or range (min-max/step) formats are allowed, following strict vixie cron and cronie parsing rules. When true, allows legacy formats like /10, 5/5, 30/30. This option was added to maintain backward compatibility while enforcing OCPS compliance by default.

Pattern syntax strictness:
By default, Croner now follows strict range parsing rules as used by vixie cron and cronie (upcoming OCPS requirement):

  • ✅ Valid: */10, 0-59/10, 30-50/10 (wildcard or range with stepping)
  • ❌ Invalid: /10, 0/10, 30/30 (missing prefix or numeric prefix with stepping)
  • To allow the old behavior, use sloppyRanges: true option: new Cron("/10 * * * * *", { sloppyRanges: true })

New Contributors

Full Changelog: 9.1.0...10.0.0

Don't miss a new croner release

NewReleases is sending notifications on new releases.