Socket
Socket
Sign inDemoInstall

cron

Package Overview
Dependencies
0
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

test.js

40

lib/cron.js
var CronDate;
var exports;
var timeUnits = ['second', 'minute', 'hour', 'dayOfMonth', 'month', 'dayOfWeek'];
var loadedTimeModule = false;

@@ -7,2 +9,3 @@ try {

exports = module.exports;
loadedTimeModule = true;
} catch (e) {

@@ -16,8 +19,6 @@ CronDate = Date;

this.second = {};
this.minute = {};
this.hour = {};
this.dayOfWeek = {};
this.dayOfMonth = {};
this.month = {};
var that = this;
timeUnits.map(function(timeUnit){
that[timeUnit] = {};
});

@@ -32,3 +33,2 @@ if ((this.source instanceof Date) || (this.source instanceof CronDate)) {

CronTime.map = ['second', 'minute', 'hour', 'dayOfMonth', 'month', 'dayOfWeek'];
CronTime.constraints = [

@@ -102,10 +102,6 @@ [0, 59],

toJSON: function() {
return [
this._wcOrAll('second'),
this._wcOrAll('minute'),
this._wcOrAll('hour'),
this._wcOrAll('dayOfMonth'),
this._wcOrAll('month'),
this._wcOrAll('dayOfWeek')
];
var that = this;
return timeUnits.map(function(timeName){
return that._wcOrAll(timeName);
});
},

@@ -120,3 +116,3 @@

if (this.zone && date.setTimezone)
date.setTimezone(start.getTimezone());
date.setTimezone(this.zone);
if (this.realDate && start < new Date())

@@ -224,3 +220,3 @@ console.log("WARNING: Date in past. Will never be fired.");

_hasAll: function(type) {
var constrain = CronTime.constraints[CronTime.map.indexOf(type)];
var constrain = CronTime.constraints[timeUnits.indexOf(type)];

@@ -251,5 +247,5 @@ for (var i = constrain[0], n = constrain[1]; i < n; i++) {

cur, i = 0,
len = CronTime.map.length;
len = timeUnits.length;
for (; i < CronTime.map.length; i++) {
for (; i < timeUnits.length; i++) {
// If the split source string doesn't contain all digits,

@@ -259,3 +255,3 @@ // assume defaults for first n missing digits.

cur = split[i - (len - split.length)] || CronTime.parseDefaults[i];
this._parseField(cur, CronTime.map[i], CronTime.constraints[i]);
this._parseField(cur, timeUnits[i], CronTime.constraints[i]);
}

@@ -287,3 +283,3 @@ },

// Positive integer higher than constraints[0]
lower = Math.max(low, ~~Math.abs(lower));
lower = Math.min(Math.max(low, ~~Math.abs(lower)), high);

@@ -322,3 +318,3 @@ // Positive integer lower than constraints[1]

if (timeZone && !(CronDate.prototype.setTimezone)) console.log('You specified a Timezone but have not included the `time` module. Timezone functionality is disabled. Please install the `time` module to use Timezones in your application.');
if (timeZone && !loadedTimeModule) console.log('You specified a Timezone but have not included the `time` module. Timezone functionality is disabled. Please install the `time` module to use Timezones in your application.');

@@ -325,0 +321,0 @@ this.context = (context || this);

{
"name": "cron",
"description": "Cron jobs for your node",
"version": "1.0.4",
"version": "1.0.5",
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)",

@@ -6,0 +6,0 @@ "bugs" : {

@@ -5,2 +5,3 @@ node-cron

[![Build Status](https://secure.travis-ci.org/ncb000gt/node-cron.png)](http://travis-ci.org/#!/ncb000gt/node-cron)
[![wercker status](https://app.wercker.com/status/0cadfe5d45ad7bc819efb636026cf230/s "wercker status")](https://app.wercker.com/project/bykey/0cadfe5d45ad7bc819efb636026cf230)

@@ -37,4 +38,4 @@ Originally this project was a NodeJS fork of [James Padolsey's][jamespadolsey] [cron.js](http://github.com/padolsey/cron.js).

var cronJob = require('cron').CronJob;
new cronJob('* * * * * *', function(){
var CronJob = require('cron').CronJob;
new CronJob('* * * * * *', function(){
console.log('You will see this message every second');

@@ -68,4 +69,4 @@ }, null, true, "America/Los_Angeles");

var cronJob = require('cron').CronJob;
var job = new cronJob('00 30 11 * * 1-5', function(){
var CronJob = require('cron').CronJob;
var job = new CronJob('00 30 11 * * 1-5', function(){
// Runs every weekday (Monday through Friday)

@@ -84,4 +85,4 @@ // at 11:30:00 AM. It does not run on Saturday

var cronJob = require('cron').CronJob;
var job = new cronJob(new Date(), function(){
var CronJob = require('cron').CronJob;
var job = new CronJob(new Date(), function(){
//runs once at the specified date.

@@ -98,4 +99,4 @@ }, function () {

var cronJob = require('cron').CronJob;
var job = new cronJob({
var CronJob = require('cron').CronJob;
var job = new CronJob({
cronTime: '00 30 11 * * 1-5',

@@ -117,3 +118,3 @@ onTick: function() {

try {
new cronJob('invalid cron pattern', function() {
new CronJob('invalid cron pattern', function() {
console.log('this should not be printed');

@@ -140,3 +141,3 @@ })

Parameter Based
Parameter Based

@@ -149,3 +150,3 @@ `CronJob`

* `onComplete` - [OPTIONAL] - A function that will fire when the job is complete, when it is stopped.
* `start` - [OPTIONAL] - Specifies whether to start the job after just before exiting the constructor.
* `start` - [OPTIONAL] - Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call `job.start()` in order to start the job (assuming `job` is the variable you set the cronjob to).
* `timeZone` - [OPTIONAL] - Specify the timezone for the execution. This will modify the actual time relative to your timezone.

@@ -152,0 +153,0 @@ * `context` - [OPTIONAL] - The context within which to execute the onTick method. This defaults to the cronjob itself allowing you to call `this.stop()`. However, if you change this you'll have access to the functions and values within your context object.

@@ -298,3 +298,3 @@ var testCase = require('nodeunit').testCase,

assert.ok(true);
}, null, true, zone);
}, null, false, zone);
setTimeout(function() {

@@ -304,2 +304,3 @@ c.stop();

}, 2250);
c.start();
}

@@ -306,0 +307,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc