Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Socket
Sign inDemoInstall

node-cron

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cron - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

test/validate-test.js

2

package.json
{
"name": "node-cron",
"version": "1.1.3",
"version": "1.2.0",
"description": "A simple cron-like task scheduler for Node.js",

@@ -5,0 +5,0 @@ "author": "Lucas Merencia",

@@ -13,3 +13,5 @@ # Node Cron

[![NPM](https://nodei.co/npm/node-cron.png?downloads=true&downloadRank=true&stars=false)](https://nodei.co/npm/node-cron/)
## Getting Started

@@ -177,2 +179,13 @@

### Validate
Validate that the given string is a valid cron expression.
```javascript
var cron = require('node-cron');
var valid = cron.validate('59 * * * *');
var invalid = cron.validate('60 * * * *');
```
## Issues

@@ -179,0 +192,0 @@

'use strict';
module.exports = (function() {
function replaceWithRange(expression, text, init, end) {
var numbers = [];
var last = parseInt(end);
for(var i = parseInt(init); i <= last; i++) {
var first = parseInt(init);
if(first > last){
last = parseInt(init);
first = parseInt(end);
}
for(var i = first; i <= last; i++) {
numbers.push(i);
}
return expression.replace(new RegExp(text, 'gi'), numbers.join());

@@ -10,0 +19,0 @@ }

'use strict';
var Task = require('./task'),
ScheduledTask = require('./scheduled-task');
ScheduledTask = require('./scheduled-task'),
validation = require('./pattern-validation');

@@ -23,5 +24,16 @@ module.exports = (function() {

function validate(expression) {
try {
validation(expression);
} catch(e) {
return false;
}
return true;
}
return {
schedule: createTask
schedule: createTask,
validate: validate
};
}());

@@ -47,3 +47,15 @@ 'use strict';

});
it('should not fail with Monday-Sunday for week day', function(){
expect(function(){
validate('* * * * Monday-Sunday');
}).to.not.throwException();
});
it('should not fail with 1-7 for week day', function(){
expect(function(){
validate('0 0 1 1 1-7');
}).to.not.throwException();
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc