UNPKG

@cmmv/core

Version:

CMMV core module for contract and application management

17 lines (16 loc) 707 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CRON_METADATA = void 0; exports.Cron = Cron; const scope_1 = require("../lib/scope"); exports.CRON_METADATA = Symbol('CRON_METADATA'); function Cron(cronTime) { return (target, propertyKey, descriptor) => { const method = descriptor.value; Reflect.defineMetadata(exports.CRON_METADATA, cronTime, method); const crons = scope_1.Scope.getArray('__crons') || []; const existingCronIndex = crons.findIndex((cron) => cron.target === target && cron.method === method); if (existingCronIndex < 0) scope_1.Scope.addToArray('__crons', { target, method, cronTime }); }; }