node-schedule
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -14,3 +14,4 @@ | ||
lt = require('long-timeout'), | ||
sorted = require('sorted-array-functions'); | ||
sorted = require('sorted-array-functions'), | ||
nodeVersionUtils = require('./nodeVersionUtils') | ||
@@ -20,2 +21,3 @@ /* Job object */ | ||
var scheduledJobs = {}; | ||
var promisesSupported = nodeVersionUtils.arePromisesSupported(nodeVersionUtils.getNodeVersion(nodeVersionUtils.nodeVersionString)) | ||
@@ -130,3 +132,3 @@ function isValidDate(date) { | ||
if (reschedule && (nextInv.recurrenceRule.recurs || nextInv.recurrenceRule.next)) { | ||
if (reschedule && (nextInv.recurrenceRule.recurs || nextInv.recurrenceRule.next)) { | ||
newInv = scheduleNextRecurrence(nextInv.recurrenceRule, this, nextInv.fireDate, nextInv.endDate); | ||
@@ -176,3 +178,3 @@ if (newInv !== null) { | ||
this.setTriggeredJobs(this.triggeredJobs() + 1); | ||
this.job(fireDate); | ||
return this.job(fireDate); | ||
} else { | ||
@@ -556,4 +558,14 @@ this.job.execute(fireDate); | ||
job.invoke(cinv.fireDate instanceof CronDate ? cinv.fireDate.toDate() : cinv.fireDate); | ||
job.emit('run'); | ||
try { | ||
var result = job.invoke(cinv.fireDate instanceof CronDate ? cinv.fireDate.toDate() : cinv.fireDate); | ||
job.emit('run'); | ||
if (promisesSupported && result instanceof Promise) { | ||
result.catch(function (err) { | ||
job.emit('error', err); | ||
}); | ||
} | ||
} catch (err) { | ||
job.emit('error', err); | ||
} | ||
}); | ||
@@ -560,0 +572,0 @@ } |
{ | ||
"name": "node-schedule", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "A cron-like and not-cron-like job scheduler for Node.", | ||
@@ -9,3 +9,4 @@ "keywords": [ | ||
"job", | ||
"cron" | ||
"cron", | ||
"in-memory" | ||
], | ||
@@ -16,3 +17,6 @@ "license": "MIT", | ||
"test": "nodeunit", | ||
"lint": "eslint lib test" | ||
"test:coverage": "istanbul cover ./node_modules/.bin/nodeunit test", | ||
"test:coverage-win": "istanbul cover ./node_modules/nodeunit/bin/nodeunit test", | ||
"lint": "eslint lib test", | ||
"lint:fix": "eslint --fix lib test" | ||
}, | ||
@@ -24,2 +28,8 @@ "author": { | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Igor Savin", | ||
"email": "kibertoad@gmail.com" | ||
} | ||
], | ||
"repository": { | ||
@@ -30,13 +40,17 @@ "type": "git", | ||
"dependencies": { | ||
"cron-parser": "^2.7.3", | ||
"cron-parser": "^2.18.0", | ||
"long-timeout": "0.1.1", | ||
"sorted-array-functions": "^1.0.0" | ||
"sorted-array-functions": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"eslint": "^3.19.0", | ||
"eslint": "^7.18.0", | ||
"istanbul": "^0.4.5", | ||
"nodeunit": "^0.10.2", | ||
"sinon": "^1.14.1" | ||
} | ||
"nodeunit": "~0.10.2", | ||
"sinon": "^2.4.1" | ||
}, | ||
"files": [ | ||
"README.md", | ||
"LICENSE", | ||
"lib/*" | ||
] | ||
} |
@@ -5,3 +5,4 @@ # Node Schedule | ||
[![Downloads](https://img.shields.io/npm/dm/node-schedule.svg)](https://www.npmjs.com/package/node-schedule) | ||
[![Build Status](https://travis-ci.org/node-schedule/node-schedule.svg?branch=master)](https://travis-ci.org/node-schedule/node-schedule) | ||
[![Build Status](https://github.com/node-schedule/node-schedule/workflows/ci/badge.svg)](https://github.com/node-schedule/node-schedule/actions) | ||
[![Coverage Status](https://coveralls.io/repos/node-schedule/node-schedule/badge.svg?branch=master)](https://coveralls.io/r/node-schedule/node-schedule?branch=master) | ||
[![Join the chat at https://gitter.im/node-schedule/node-schedule](https://img.shields.io/badge/gitter-chat-green.svg)](https://gitter.im/node-schedule/node-schedule?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
@@ -47,11 +48,16 @@ | ||
`Job` objects are `EventEmitter`'s, and emit a `run` event after each execution. | ||
They also emit a `scheduled` event each time they're scheduled to run, and a | ||
`canceled` event when an invocation is canceled before it's executed (both events | ||
receive a JavaScript date object as a parameter). Note that jobs are scheduled the | ||
first time immediately, so if you create a job using the `scheduleJob()` | ||
convenience method, you'll miss the first `scheduled` event, but you can query the | ||
invocation manually (see below). Also note that `canceled` is the single-L American | ||
spelling. | ||
`Job` objects are `EventEmitter`s, and emit the following events: | ||
* A `run` event after each execution. | ||
* A `scheduled` event each time they're scheduled to run. | ||
* A `canceled` event when an invocation is canceled before it's executed. | ||
Note that `canceled` is the single-L American spelling. | ||
* An `error` event when a job invocation triggered by a schedule throws or returns | ||
a rejected `Promise`. | ||
(Both the `scheduled` and `canceled` events receive a JavaScript date object as | ||
a parameter). | ||
Note that jobs are scheduled the first time immediately, so if you create a job | ||
using the `scheduleJob()` convenience method, you'll miss the first `scheduled` | ||
event, but you can query the invocation manually (see below). | ||
### Cron-style Scheduling | ||
@@ -103,5 +109,5 @@ | ||
Currently, `W` (nearest weekday), `L` (last day of month/week), and `#` (nth weekday | ||
of the month) are not supported. Most other features supported by popular cron | ||
implementations should work just fine. | ||
Currently, `W` (nearest weekday) and `L` (last day of month/week) are not supported. | ||
Most other features supported by popular cron implementations should work just fine, | ||
including `#` (nth weekday of the month). | ||
@@ -169,2 +175,16 @@ [cron-parser] is used to parse crontab instructions. | ||
Timezones are also supported. Here is an example of executing at the start of every day in the UTC timezone. | ||
```js | ||
var rule = new schedule.RecurrenceRule(); | ||
rule.hour = 0; | ||
rule.tz = 'Etc/UTC'; | ||
var j = schedule.scheduleJob(rule, function(){ | ||
console.log('A new day has begun in the UTC timezone!'); | ||
}); | ||
``` | ||
A list of acceptable tz (timezone) values can be found at <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> | ||
#### RecurrenceRule properties | ||
@@ -179,3 +199,5 @@ | ||
- `dayOfWeek (0-6) Starting with Sunday` | ||
- `tz` | ||
> **Note**: It's worth noting that the default value of a component of a recurrence rule is | ||
@@ -239,5 +261,6 @@ > `null` (except for second, which is 0 for familiarity with cron). *If we did not | ||
This module was originally developed by [Matt Patenaude], and is now maintained by | ||
[Tejas Manohar] and [other wonderful contributors]. | ||
This module was originally developed by [Matt Patenaude] who eventually passed over maintainer's mantle over to [Tejas Manohar]. | ||
Currently it is being maintained by [Igor Savin] and [our amazing community]. | ||
We'd love to get your contributions. Individuals making significant and valuable | ||
@@ -259,5 +282,6 @@ contributions are given commit-access to the project to contribute as they see fit. | ||
[Tejas Manohar]: http://tejas.io | ||
[Igor Savin]: https://twitter.com/kibertoad | ||
[license]: https://github.com/node-schedule/node-schedule/blob/master/LICENSE | ||
[Tejas Manohar]: https://github.com/tejasmanohar | ||
[other wonderful contributors]: https://github.com/node-schedule/node-schedule/graphs/contributors | ||
[our amazing community]: https://github.com/node-schedule/node-schedule/graphs/contributors | ||
[cron-parser]: https://github.com/harrisiirak/cron-parser |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
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
4
281
0
30321
5
592
2
Updatedcron-parser@^2.18.0