Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
d3dd03534a | |||
9b96779d19 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smarttime",
|
"name": "@pushrocks/smarttime",
|
||||||
"version": "3.0.45",
|
"version": "3.0.46",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smarttime",
|
"name": "@pushrocks/smarttime",
|
||||||
"version": "3.0.45",
|
"version": "3.0.46",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^5.0.4",
|
"@pushrocks/lik": "^5.0.4",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smarttime",
|
"name": "@pushrocks/smarttime",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.0.45",
|
"version": "3.0.46",
|
||||||
"description": "handle time in smart ways",
|
"description": "handle time in smart ways",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@pushrocks/smarttime',
|
||||||
|
version: '3.0.46',
|
||||||
|
description: 'handle time in smart ways'
|
||||||
|
}
|
@ -3,10 +3,10 @@ import { CronManager } from './smarttime.classes.cronmanager';
|
|||||||
|
|
||||||
import { CronParser } from './smarttime.classes.cronparser';
|
import { CronParser } from './smarttime.classes.cronparser';
|
||||||
|
|
||||||
export type TJobFunction = (() => void) | (() => Promise<any>);
|
export type TJobFunction = ((triggerTimeArg?: number) => void) | ((triggerTimeArg?: number) => Promise<any>);
|
||||||
|
|
||||||
export class CronJob {
|
export class CronJob {
|
||||||
public cronParser: CronParser | typeof plugins.croner;
|
public cronParser: typeof plugins.croner;
|
||||||
public status: 'started' | 'stopped' | 'initial' = 'initial';
|
public status: 'started' | 'stopped' | 'initial' = 'initial';
|
||||||
public cronExpression: string;
|
public cronExpression: string;
|
||||||
public jobFunction: TJobFunction;
|
public jobFunction: TJobFunction;
|
||||||
@ -26,7 +26,7 @@ export class CronJob {
|
|||||||
this.getNextExecutionTime();
|
this.getNextExecutionTime();
|
||||||
}
|
}
|
||||||
if (Date.now() > this.nextExecutionUnix) {
|
if (Date.now() > this.nextExecutionUnix) {
|
||||||
const maybePromise = this.jobFunction();
|
const maybePromise = this.jobFunction(this.nextExecutionUnix);
|
||||||
if (maybePromise instanceof Promise) {
|
if (maybePromise instanceof Promise) {
|
||||||
maybePromise.catch(e => console.log(e));
|
maybePromise.catch(e => console.log(e));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user