@atri-bot/lib-cron 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ declare class Cron {
16
16
  cronJobs: Record<string, CronJob<null, null>>;
17
17
  constructor(config: CronConfig);
18
18
  add(options: AddCronOptions): CronJob;
19
+ remove(name: string): void;
19
20
  }
20
21
 
21
22
  export { Cron };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Logger as i,LogLevel as s}from"@huan_kong/logger";import{CronJob as g}from"cron";var r=class extends Error{constructor(o){super(o),this.name="CronJobNameExistsError"}};var c={},e=class{config;logger;cronJobs=c;constructor(o){this.config=o,this.logger=new i({title:"Cron",level:o.logLevel??(o.debug?s.DEBUG:void 0)})}add(o){if(this.cronJobs[o.name])throw new r;"timeZone"in o||(o.timeZone="Asia/Shanghai"),o.onTick=async()=>{this.logger.DEBUG("\u5B9A\u65F6\u4EFB\u52A1\u89E6\u53D1!"),await o.onTick()};let n=g.from(o);return this.cronJobs[o.name]=n,n}};export{e as Cron};
1
+ import{Logger as i,LogLevel as g}from"@huan_kong/logger";import{CronJob as c}from"cron";var e=class extends Error{constructor(o){super(o),this.name="CronJobNameExistsError"}};var l={},n=class{config;logger;cronJobs=l;constructor(o){this.config=o,this.logger=new i({title:"Cron",level:o.logLevel??(o.debug?g.DEBUG:void 0)})}add(o){if(this.cronJobs[o.name])throw new e;"timeZone"in o||(o.timeZone="Asia/Shanghai"),o.onTick=(s=>async()=>{this.logger.DEBUG("\u5B9A\u65F6\u4EFB\u52A1\u89E6\u53D1!"),await s()})(o.onTick);let r=c.from(o);return this.cronJobs[o.name]=r,r}remove(o){let r=this.cronJobs[o];r?(r.stop(),delete this.cronJobs[o],this.logger.DEBUG(`\u5B9A\u65F6\u4EFB\u52A1 ${o} \u5DF2\u79FB\u9664`)):this.logger.WARN(`\u5B9A\u65F6\u4EFB\u52A1 ${o} \u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u79FB\u9664`)}};export{n as Cron};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atri-bot/lib-cron",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "cron lib for atri framework",
5
5
  "author": "huan_kong",
6
6
  "license": "MIT",