MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/Cron.ts:294–358  ·  view source on GitHub ↗
(values: {
  readonly seconds?: Iterable<number> | undefined
  readonly minutes: Iterable<number>
  readonly hours: Iterable<number>
  readonly days: Iterable<number>
  readonly months: Iterable<number>
  readonly weekdays: Iterable<number>
  readonly and?: boolean | undefined
  readonly tz?: DateTime.TimeZone | undefined
})

Source from the content-addressed store, hash-verified

292 * @since 2.0.0
293 */
294export const make = (values: {
295 readonly seconds?: Iterable<number> | undefined
296 readonly minutes: Iterable<number>
297 readonly hours: Iterable<number>
298 readonly days: Iterable<number>
299 readonly months: Iterable<number>
300 readonly weekdays: Iterable<number>
301 readonly and?: boolean | undefined
302 readonly tz?: DateTime.TimeZone | undefined
303}): Cron => {
304 const o: Mutable<Cron> = Object.create(CronProto)
305 o.seconds = restrictions.seconds(values.seconds ?? [0])
306 o.minutes = restrictions.minutes(values.minutes)
307 o.hours = restrictions.hours(values.hours)
308 o.days = restrictions.days(values.days)
309 o.months = restrictions.months(values.months)
310 o.weekdays = restrictions.weekdays(values.weekdays)
311 o.and = values.and === true
312 o.tz = Option.fromUndefinedOr(values.tz)
313
314 const seconds = Array.from(o.seconds)
315 const minutes = Array.from(o.minutes)
316 const hours = Array.from(o.hours)
317 const days = Array.from(o.days)
318 const months = Array.from(o.months)
319 const weekdays = Array.from(o.weekdays)
320
321 o.first = {
322 second: seconds[0] ?? 0,
323 minute: minutes[0] ?? 0,
324 hour: hours[0] ?? 0,
325 day: days[0] ?? 1,
326 month: (months[0] ?? 1) - 1,
327 weekday: weekdays[0] ?? 0
328 }
329
330 o.last = {
331 second: seconds[seconds.length - 1] ?? 59,
332 minute: minutes[minutes.length - 1] ?? 59,
333 hour: hours[hours.length - 1] ?? 23,
334 day: days[days.length - 1] ?? 31,
335 month: (months[months.length - 1] ?? 12) - 1,
336 weekday: weekdays[weekdays.length - 1] ?? 6
337 }
338
339 o.next = {
340 second: lookup.next.second(seconds),
341 minute: lookup.next.minute(minutes),
342 hour: lookup.next.hour(hours),
343 day: lookup.next.day(days),
344 month: lookup.next.month(months),
345 weekday: lookup.next.weekday(weekdays)
346 }
347
348 o.prev = {
349 second: lookup.prev.second(seconds),
350 minute: lookup.prev.minute(minutes),
351 hour: lookup.prev.hour(hours),

Callers 1

parseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected