CronFieldCollection constructor. Initializes the cron fields with the provided values.
The cron fields values
const cronFields = new CronFieldCollection({
second: new CronSecond([0]),
minute: new CronMinute([0, 30]),
hour: new CronHour([9]),
dayOfMonth: new CronDayOfMonth([15]),
month: new CronMonth([1]),
dayOfWeek: new CronDayOfTheWeek([1, 2, 3, 4, 5]),
})
console.log(cronFields.second.values); // [0]
console.log(cronFields.minute.values); // [0, 30]
console.log(cronFields.hour.values); // [9]
console.log(cronFields.dayOfMonth.values); // [15]
console.log(cronFields.month.values); // [1]
console.log(cronFields.dayOfWeek.values); // [1, 2, 3, 4, 5]
Returns the day of the month field.
Returns the day of the week field.
Returns the hour field.
Returns the minute field.
Returns the month field.
Returns the second field.
Returns a serialized representation of the cron fields values.
An object containing the cron field values
Returns a string representation of the cron field values.
Whether to include seconds in the output
The formatted cron string
Returns a string representation of the cron fields.
The cron field to stringify
Static
compactReturns a string representation of the cron fields.
The cron fields values
Static
fromCreates a new CronFieldCollection instance by partially overriding fields from an existing one.
The base CronFieldCollection to copy fields from
The fields to override, can be CronField instances or raw values
A new CronFieldCollection instance
const base = new CronFieldCollection({
second: new CronSecond([0]),
minute: new CronMinute([0]),
hour: new CronHour([12]),
dayOfMonth: new CronDayOfMonth([1]),
month: new CronMonth([1]),
dayOfWeek: new CronDayOfWeek([1])
});
// Using CronField instances
const modified1 = CronFieldCollection.from(base, {
hour: new CronHour([15]),
minute: new CronMinute([30])
});
// Using raw values
const modified2 = CronFieldCollection.from(base, {
hour: [15], // Will create new CronHour
minute: [30] // Will create new CronMinute
});
Represents a complete set of cron fields. CronFieldCollection