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 { build, or } from "jsr:@coven/expression@^0.3.3"; import type { KeyOf, ReadonlyArray } from "jsr:@coven/types@^0.3.3"; import type { FieldString } from "./FieldString.ts"; import { normalizeMap } from "./normalizeMap.ts"; const buildGIU = build("giu"); /** * Normalizes day and month 3 letter aliases into their number counterparts. * * @example * ```typescript * normalizeAliases("* * 13 oct fri"); // "* * 13 10 5" * ``` * @param expression String expression. * @returns Normalized expression */ export const normalizeAliases = (expression: string): FieldString => expression.replaceAll( buildGIU( or( ...(Object.keys(normalizeMap) as ReadonlyArray< KeyOf<typeof normalizeMap> >), ), ), (alias) => `${ normalizeMap[ alias.toLocaleLowerCase() as KeyOf<typeof normalizeMap> ] }`, ) as FieldString;