Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
⏳ Fantastic cron parser and constructor.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
100%
Published
2 months ago (0.3.3)
import { map } from "jsr:@coven/iterables@^0.3.3"; import type { Maybe } from "jsr:@coven/types@^0.3.3"; import type { AllToken } from "./AllToken.ts"; import type { CronObject } from "./CronObject.ts"; import type { ListField } from "./ListField.ts"; import { parseField } from "./parseField.ts"; import type { RangeField } from "./RangeField.ts"; /** * Given an iterable of tuples with the name of a field and a field value, * run each field through {@linkcode parseField}. * * @example * ```typescript * parseFieldTuplesMap([["minute", "*"]]); // [["minute", "*"]] * parseFieldTuplesMap([["minute", "13"]]); // [["minute", 13]] * parseFieldTuplesMap([["minute", "10,11,13"]]); // [["minute", [10, 11, 13]]] * parseFieldTuplesMap([["minute", "1-10"]]); // [["minute", { from: 1, to: 10 }]] * ``` * @see {@linkcode parseField} */ export const parseFieldTuplesMap: ( fieldTuples: Iterable<readonly [name: keyof CronObject, field: string]>, ) => IterableIterator< readonly [ name: keyof CronObject, parsedField: | AllToken | Maybe<number> | RangeField<number> | ListField<number>, ] > = map( ([name, field]: readonly [name: keyof CronObject, field: string]) => [name, parseField(field)] as const, );