croner 9.0.0-dev.0 → 9.0.0-dev.2
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/README.md +6 -6
- package/dist/croner.cjs +6 -0
- package/dist/croner.d.cts +4 -31
- package/dist/croner.d.ts +4 -31
- package/dist/croner.js +3 -0
- package/dist/croner.umd.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,21 +26,21 @@ Quick examples:
|
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
28
|
// Basic: Run a function at the interval defined by a cron expression
|
|
29
|
-
const job = Cron('*/5 * * * * *', () => {
|
|
29
|
+
const job = new Cron('*/5 * * * * *', () => {
|
|
30
30
|
console.log('This will run every fifth second');
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Enumeration: What dates do the next 100 sundays occur on?
|
|
34
|
-
const nextSundays = Cron('0 0 0 * * 7').nextRuns(100);
|
|
34
|
+
const nextSundays = new Cron('0 0 0 * * 7').nextRuns(100);
|
|
35
35
|
console.log(nextSundays);
|
|
36
36
|
|
|
37
37
|
// Days left to a specific date
|
|
38
|
-
const msLeft = Cron('59 59 23 24 DEC *').nextRun() - new Date();
|
|
38
|
+
const msLeft = new Cron('59 59 23 24 DEC *').nextRun() - new Date();
|
|
39
39
|
console.log(Math.floor(msLeft/1000/3600/24) + " days left to next christmas eve");
|
|
40
40
|
|
|
41
41
|
// Run a function at a specific date/time using a non-local timezone (time is ISO 8601 local time)
|
|
42
42
|
// This will run 2024-01-23 00:00:00 according to the time in Asia/Kolkata
|
|
43
|
-
Cron('2024-01-23T00:00:00', { timezone: 'Asia/Kolkata' }, () => { console.log('Yay!') });
|
|
43
|
+
new Cron('2024-01-23T00:00:00', { timezone: 'Asia/Kolkata' }, () => { console.log('Yay!') });
|
|
44
44
|
|
|
45
45
|
```
|
|
46
46
|
|
|
@@ -96,13 +96,13 @@ Cron takes three arguments
|
|
|
96
96
|
// - First: Cron pattern, js date object (fire once), or ISO 8601 time string (fire once)
|
|
97
97
|
// - Second: Options (optional)
|
|
98
98
|
// - Third: Function run trigger (optional)
|
|
99
|
-
const job = Cron("* * * * * *", { maxRuns: 1 }, () => {} );
|
|
99
|
+
const job = new Cron("* * * * * *", { maxRuns: 1 }, () => {} );
|
|
100
100
|
|
|
101
101
|
// If function is omitted in constructor, it can be scheduled later
|
|
102
102
|
job.schedule(job, /* optional */ context) => {});
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
The job will be sceduled to run at next matching time unless you supply option `{ paused: true }`. The `Cron(...)` constructor will return a Cron instance, later called `job`, which have a couple of methods and properties listed below.
|
|
105
|
+
The job will be sceduled to run at next matching time unless you supply option `{ paused: true }`. The `new Cron(...)` constructor will return a Cron instance, later called `job`, which have a couple of methods and properties listed below.
|
|
106
106
|
|
|
107
107
|
#### Status
|
|
108
108
|
|
package/dist/croner.cjs
CHANGED
|
@@ -20,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var croner_exports = {};
|
|
21
21
|
__export(croner_exports, {
|
|
22
22
|
Cron: () => Cron,
|
|
23
|
+
CronDate: () => CronDate,
|
|
24
|
+
CronOptions: () => CronOptions,
|
|
25
|
+
CronPattern: () => CronPattern,
|
|
23
26
|
default: () => croner_default,
|
|
24
27
|
scheduledJobs: () => scheduledJobs
|
|
25
28
|
});
|
|
@@ -1170,5 +1173,8 @@ var croner_default = Cron;
|
|
|
1170
1173
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1171
1174
|
0 && (module.exports = {
|
|
1172
1175
|
Cron,
|
|
1176
|
+
CronDate,
|
|
1177
|
+
CronOptions,
|
|
1178
|
+
CronPattern,
|
|
1173
1179
|
scheduledJobs
|
|
1174
1180
|
});
|
package/dist/croner.d.cts
CHANGED
|
@@ -334,33 +334,6 @@ declare module "croner" {
|
|
|
334
334
|
* An array containing all named cron jobs.
|
|
335
335
|
*/
|
|
336
336
|
const scheduledJobs: Cron[];
|
|
337
|
-
/**
|
|
338
|
-
* Encapsulate all internal states in the Cron instance.
|
|
339
|
-
* Duplicate all options that can change to internal states, for example maxRuns and paused.
|
|
340
|
-
*/
|
|
341
|
-
type CronState = {
|
|
342
|
-
kill: boolean;
|
|
343
|
-
blocking: boolean;
|
|
344
|
-
/**
|
|
345
|
-
* Start time of previous trigger, updated after each trigger
|
|
346
|
-
*
|
|
347
|
-
* Stored to use as the actual previous run, even while a new trigger
|
|
348
|
-
* is started. Used by the public funtion `.previousRun()`
|
|
349
|
-
*/
|
|
350
|
-
previousRun: CronDate | undefined;
|
|
351
|
-
/**
|
|
352
|
-
* Start time of current trigger, this is updated just before triggering
|
|
353
|
-
*
|
|
354
|
-
* This is used internally as "previous run", as we mostly want to know
|
|
355
|
-
* when the previous run _started_
|
|
356
|
-
*/
|
|
357
|
-
currentRun: CronDate | undefined;
|
|
358
|
-
once: CronDate | undefined;
|
|
359
|
-
currentTimeout: NodeJS.Timer | number | undefined;
|
|
360
|
-
maxRuns: number | undefined;
|
|
361
|
-
paused: boolean | undefined;
|
|
362
|
-
pattern: CronPattern;
|
|
363
|
-
};
|
|
364
337
|
/**
|
|
365
338
|
* Cron entrypoint
|
|
366
339
|
*
|
|
@@ -372,9 +345,9 @@ declare module "croner" {
|
|
|
372
345
|
class Cron {
|
|
373
346
|
name: string | undefined;
|
|
374
347
|
options: CronOptions;
|
|
375
|
-
_states
|
|
376
|
-
fn
|
|
377
|
-
constructor(pattern: string | Date, fnOrOptions1
|
|
348
|
+
private _states;
|
|
349
|
+
private fn?;
|
|
350
|
+
constructor(pattern: string | Date, fnOrOptions1?: CronOptions | Function, fnOrOptions2?: CronOptions | Function);
|
|
378
351
|
/**
|
|
379
352
|
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
380
353
|
*
|
|
@@ -483,5 +456,5 @@ declare module "croner" {
|
|
|
483
456
|
private _calculatePreviousRun;
|
|
484
457
|
}
|
|
485
458
|
export default Cron;
|
|
486
|
-
export { Cron, scheduledJobs };
|
|
459
|
+
export { Cron, CronDate, CronOptions, CronPattern, scheduledJobs };
|
|
487
460
|
}
|
package/dist/croner.d.ts
CHANGED
|
@@ -334,33 +334,6 @@ declare module "croner" {
|
|
|
334
334
|
* An array containing all named cron jobs.
|
|
335
335
|
*/
|
|
336
336
|
const scheduledJobs: Cron[];
|
|
337
|
-
/**
|
|
338
|
-
* Encapsulate all internal states in the Cron instance.
|
|
339
|
-
* Duplicate all options that can change to internal states, for example maxRuns and paused.
|
|
340
|
-
*/
|
|
341
|
-
type CronState = {
|
|
342
|
-
kill: boolean;
|
|
343
|
-
blocking: boolean;
|
|
344
|
-
/**
|
|
345
|
-
* Start time of previous trigger, updated after each trigger
|
|
346
|
-
*
|
|
347
|
-
* Stored to use as the actual previous run, even while a new trigger
|
|
348
|
-
* is started. Used by the public funtion `.previousRun()`
|
|
349
|
-
*/
|
|
350
|
-
previousRun: CronDate | undefined;
|
|
351
|
-
/**
|
|
352
|
-
* Start time of current trigger, this is updated just before triggering
|
|
353
|
-
*
|
|
354
|
-
* This is used internally as "previous run", as we mostly want to know
|
|
355
|
-
* when the previous run _started_
|
|
356
|
-
*/
|
|
357
|
-
currentRun: CronDate | undefined;
|
|
358
|
-
once: CronDate | undefined;
|
|
359
|
-
currentTimeout: NodeJS.Timer | number | undefined;
|
|
360
|
-
maxRuns: number | undefined;
|
|
361
|
-
paused: boolean | undefined;
|
|
362
|
-
pattern: CronPattern;
|
|
363
|
-
};
|
|
364
337
|
/**
|
|
365
338
|
* Cron entrypoint
|
|
366
339
|
*
|
|
@@ -372,9 +345,9 @@ declare module "croner" {
|
|
|
372
345
|
class Cron {
|
|
373
346
|
name: string | undefined;
|
|
374
347
|
options: CronOptions;
|
|
375
|
-
_states
|
|
376
|
-
fn
|
|
377
|
-
constructor(pattern: string | Date, fnOrOptions1
|
|
348
|
+
private _states;
|
|
349
|
+
private fn?;
|
|
350
|
+
constructor(pattern: string | Date, fnOrOptions1?: CronOptions | Function, fnOrOptions2?: CronOptions | Function);
|
|
378
351
|
/**
|
|
379
352
|
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
380
353
|
*
|
|
@@ -483,5 +456,5 @@ declare module "croner" {
|
|
|
483
456
|
private _calculatePreviousRun;
|
|
484
457
|
}
|
|
485
458
|
export default Cron;
|
|
486
|
-
export { Cron, scheduledJobs };
|
|
459
|
+
export { Cron, CronDate, CronOptions, CronPattern, scheduledJobs };
|
|
487
460
|
}
|
package/dist/croner.js
CHANGED
package/dist/croner.umd.js
CHANGED
|
@@ -21,6 +21,9 @@ var base64 = (() => {
|
|
|
21
21
|
var croner_exports = {};
|
|
22
22
|
__export(croner_exports, {
|
|
23
23
|
Cron: () => Cron,
|
|
24
|
+
CronDate: () => CronDate,
|
|
25
|
+
CronOptions: () => CronOptions,
|
|
26
|
+
CronPattern: () => CronPattern,
|
|
24
27
|
default: () => croner_default,
|
|
25
28
|
scheduledJobs: () => scheduledJobs
|
|
26
29
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "croner",
|
|
3
|
-
"version": "9.0.0-dev.
|
|
3
|
+
"version": "9.0.0-dev.2",
|
|
4
4
|
"description": "Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.",
|
|
5
5
|
"author": "Hexagon <github.com/hexagon>",
|
|
6
6
|
"homepage": "https://croner.56k.guru",
|