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 { parseDecimal } from "jsr:@coven/parsers@^0.3.3"; import type { Maybe } from "jsr:@coven/types@^0.3.3"; import { parseNumberTest } from "./parseNumberTest.ts"; /** * Parses a cron list into an array. * * @example * ```typescript * parseNumber("5"); // 5 * parseNumber("13"); // 13 * parseNumber("59"); // 59 * parseNumber("60"); // undefined (60 isn't valid for any cron field) * ``` * * @param value String that might be a list. * @returns Parsed list of `undefined` if it isn't a list string. */ export const parseNumber = (value: string): Maybe<number> => (parseNumberTest(value) ? parseDecimal(value) : undefined) as Maybe<number>;