FaasJS
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security

Documents / @faasjs/jobs / parseCronExpression

Function: parseCronExpression()

parseCronExpression(expression): CronMatcher[]

Parse a cron expression into an array of field matchers.

Accepts the standard 5-field format: minute hour dayOfMonth month dayOfWeek. Supports comma-separated values, ranges (-), steps (/), and wildcards (*). Day-of-week accepts both numeric (0–7) and abbreviated names (SUN–SAT).

Parameters

expression

string

A cron expression string.

Returns

CronMatcher[]

An array of five matcher functions, one per field.

Throws

If the expression is empty, has the wrong number of fields, or contains invalid values.

Example

parseCronExpression('0 9 * * 1-5')
// every weekday at 9:00