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.

45 lines (42 loc) 1.04 kB
'use strict'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // 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"); exports.normalizePattern = normalizePattern; //# sourceMappingURL=normalizePattern.cjs.map //# sourceMappingURL=normalizePattern.cjs.map