node-schedule
Advanced tools
Comparing version 1.2.5 to 1.3.0
@@ -170,8 +170,8 @@ | ||
Job.prototype.invoke = function() { | ||
Job.prototype.invoke = function(fireDate) { | ||
if (typeof this.job == 'function') { | ||
this.setTriggeredJobs(this.triggeredJobs() + 1); | ||
this.job(); | ||
this.job(fireDate); | ||
} else { | ||
this.job.execute(); | ||
this.job.execute(fireDate); | ||
} | ||
@@ -495,6 +495,11 @@ }; | ||
function runOnDate(date, job) { | ||
var now = (new Date()).getTime(); | ||
var now = Date.now(); | ||
var then = date.getTime(); | ||
return lt.setTimeout(job, (then < now ? 0 : then - now)); | ||
return lt.setTimeout(function() { | ||
if (then > Date.now()) | ||
runOnDate(date, job); | ||
else | ||
job(); | ||
}, (then < now ? 0 : then - now)); | ||
} | ||
@@ -540,3 +545,3 @@ | ||
job.invoke(); | ||
job.invoke(cinv.fireDate instanceof CronDate ? cinv.fireDate.toDate() : cinv.fireDate); | ||
job.emit('run'); | ||
@@ -543,0 +548,0 @@ }); |
{ | ||
"name": "node-schedule", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"description": "A cron-like and not-cron-like job scheduler for Node.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -61,3 +61,3 @@ # Node Schedule | ||
┬ ┬ ┬ ┬ ┬ ┬ | ||
│ │ │ │ │ | | ||
│ │ │ │ │ │ | ||
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun) | ||
@@ -93,2 +93,9 @@ │ │ │ │ └───── month (1 - 12) | ||
You can also get when it is scheduled to run for every invocation of the job: | ||
```js | ||
var j = schedule.scheduleJob('0 1 * * *', function(fireDate){ | ||
console.log('This job was supposed to run at ' + fireDate + ', but actually ran at ' + new Date()); | ||
}); | ||
``` | ||
This is useful when you need to check if there is a delay of the job invocation when the system is busy, or save a record of all invocations of a job for audit purpose. | ||
#### Unsupported Cron Features | ||
@@ -95,0 +102,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
82237
17
2326
257
7
2