UNPKG

@kingsworld/plugin-cron

Version:

A simple @sapphire/framework plugin that aims to make use of the croner package and allow users to make cron jobs within their Sapphire discord bot.

42 lines (40 loc) 929 B
import { __name } from '../../chunk-2JTKI4GS.mjs'; // src/lib/utils/normalizePattern.ts var predefined = { "@annually": "0 0 1 1 *", "@yearly": "0 0 1 1 *", "@monthly": "0 0 1 * *", "@weekly": "0 0 * * 0", "@daily": "0 0 * * *", "@hourly": "0 * * * *" }; var cronTokens = { jan: 1, feb: 2, mar: 3, apr: 4, may: 5, jun: 6, jul: 7, aug: 8, sep: 9, oct: 10, nov: 11, dec: 12, sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6 }; var tokensRegex = new RegExp(Object.keys(cronTokens).join("|"), "g"); function normalizePattern(pattern) { if (Reflect.has(predefined, pattern)) return Reflect.get(predefined, pattern); return pattern.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match))); } __name(normalizePattern, "normalizePattern"); export { normalizePattern }; //# sourceMappingURL=normalizePattern.mjs.map //# sourceMappingURL=normalizePattern.mjs.map