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

cron.js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron.js

Cron (weekly) expressions parser and generator for JavaScript (browser and server)

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cron.js

Weekly Cron expressions parser and generator

Setup

Browser:
<script src="cron.min.js"></script>
Node:
npm i cron.js --save
import Cron from 'cron.js'

or

var Cron = require('cron.js')

Usage

Days map reference:

1: 'SUN'
2: 'MON'
3: 'TUE'
4: 'WED'
5: 'THU'
6: 'FRI'
7: 'SAT'

Examples:

let data = {
  days: [1, 2, 3, 4, 5, 6],
  startTime: '18:30:00'
};

/* make */
new Cron( data, { shorten: true } ).expression;        //  '* 30 18 * * 1-6 *'
new Cron( data, { numeric: false } ).expression;        //  '* 30 18 * * SUN,MON,TUE,WED,THU,FRI *'
new Cron( { days: ['FRI', 'SAT'] } ).expression;        //  '* * * * * 6,7 *'
Cron.make( data, { numeric: false, shorten: true } );  //  '* 30 18 * * SUN-FRI *'

/* parse */
Cron.parse('* 30 18 * * 1-3');    // { days: [1, 2, 3], startTime: '18:30:00' }
Cron.parse('* 30 18 * * 1,3,6');  // { days: [1, 3, 6], startTime: '18:30:00' }
Cron.parse('* * 12 * * SUN-SAT'); // { days: [1, 2, 3, 4, 5, 6, 7], startTime: '12:00:00' }

Default options
{
  numeric: true,  // If days of week in output expression should be integers instead of strings (e.g.: 1,2 <- SUN,MON)
  optimize: false // If days of week should be represented in ranges wherever possible (e.g.: 1-6 instead of 1,2,3,4,5,6)
}
Development - Contribute!

Source code inside src folder, written in ES6, that gets loaded by babel and transpiled to ES5. Build and minified versions in dist folder. Tests can be found in test folder.

npm i     // Installs npm dependencies
npm start // Compiles and minifies source code
npm test  // Runs test suite

Keywords

FAQs

Package last updated on 15 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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