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

croner

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

croner - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

33

lib/croner.js

@@ -10,26 +10,2 @@

Installation:
Node.js
```npm install croner```
Browser (AMD and regular usage)
Download croner.js and import with script-tag or AMD.
Usage:
```javascript
// Parse 14:00:00 at next sunday
var scheduler = cron('0 0 14 * * 7');
// Log the actual date object of next run
console.log(scheduler.next());
// Log number of milliseconds to next run
console.log(scheduler.msToNext());`
```
------------------------------------------------------------------------------------
Pattern:

@@ -341,4 +317,4 @@ ```

opts.stopAt = opts.stopAt || this.schedulerDefaults.stopAt;
opts.maxRuns = opts.maxRuns || this.schedulerDefaults.maxRuns;
opts.kill = opts.kill || this.schedulerDefaults.kill;
if ( opts.maxRuns === undefined ) opts.maxRuns = this.schedulerDefaults.maxRuns;

@@ -387,3 +363,3 @@ // One-timer

if(false) {
var scheduler = new Cron('* * * * * *');

@@ -415,2 +391,7 @@

// Start a job that run five times
scheduler.schedule({maxRuns: 5}, function () {
console.log('This will run five times');
});
}
{
"name": "croner",
"version": "1.0.2",
"version": "1.0.3",
"description": "Isomorphic JavaScript cron parser and scheduler.",

@@ -5,0 +5,0 @@ "author": "Hexagon <github.com/hexagon>",

@@ -17,3 +17,3 @@

Download croner.js and import with script-tag or AMD.
Download lib/croner.js and import with script-tag or AMD as usual.

@@ -23,23 +23,59 @@

```javascript
var o = cron( <string pattern> );
o.next( [ <date previous> ] );
o.msToNext();
o.schedule( [ { startAt: <date>, stopAt: <date>, maxRuns: <integer> } ,] callback);
```
# Examples
# Parsing only
```javascript
// Parse 14:00:00 at next sunday
var scheduler = cron('0 0 14 * * 7');
var parser = cron('0 0 14 * * 7');
// Log the actual date object of next run
console.log(scheduler.next());
console.log(parser.next());
// Log number of milliseconds to next run
console.log(scheduler.msToNext());`
console.log(parser.msToNext());`
```
## Basic scheduling
```javascript
// Run every minute
var scheduler = cron('0 * * * * *');
scheduler.schedule(function() {
console.log('This will run every minute.');
});
```
## Scheduling with options
```javascript
// Run every minute
var scheduler = cron('0 * * * * *');
// Schedule with options (all options are optional)
scheduler.schedule({ maxRuns: 5 }, function() {
console.log('This will run every minute.');
});
```
# Pattern
```
┌──────────────── sec (0 - 59)
| ┌────────────── min (0 - 59)
| │ ┌──────────── hour (0 - 23)
| │ │ ┌────────── day of month (1 - 31)
| │ │ │ ┌──────── month (1 - 12)
| │ │ │ │ ┌────── day of week (0 - 6)
| │ │ │ │ │ (0 to 6 are Sunday to Saturday; 7 is Sunday, the same as 0)
| │ │ │ │ │
│ ┌────────────── min (0 - 59)
│ │ ┌──────────── hour (0 - 23)
│ │ │ ┌────────── day of month (1 - 31)
│ │ │ │ ┌──────── month (1 - 12)
│ │ │ │ │ ┌────── day of week (0 - 6)
│ │ │ │ │ │ (0 to 6 are Sunday to Saturday; 7 is Sunday, the same as 0)
│ │ │ │ │ │
* * * * * *

@@ -46,0 +82,0 @@ ```

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