Socket
Socket
Sign inDemoInstall

saturnus

Package Overview
Dependencies
15
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    saturnus

Cron parser for ES6


Version published
Maintainers
1
Install size
7.61 MB
Created

Readme

Source

forthebadge

Stories in Progress Build Status Dependencies DevDependencies npm version GitHub license

Saturnus

Saturnus is a cron parser for ES6, using Moment.js to parse into manageable dates.

Installation

npm install saturnus

Introduction

You must know about cron and its expressions, well... sometimes it can be a pain parsing them by yourself. Specially if you only want to validate an ISO string. That's when Saturnus comes into play.

This library is under heavy development, because (guess what?) us, "the creators", are using it for many projects so... we might as well share part of our efforts with the Node community. ;)

Quickstart

const Saturnus = require('saturnus');

//Don't worry I'm bot asynchronous and I'm non-blocking
let chronos = new Saturnus('* * * * *');
//But if you need me on the fly...
let buildingCron = new Saturnus();
buildingCron.parse()
  .every().step(5).second()         //Every five seconds
  .at(15).minute()                  //At minute 15
  .between(12, 15).hours()          //From 12 to 3 p.m.
  .every.weekday()                  //Any day of the weekday
  .between(2,9).step(2).months()    //In February, April, June and August
  .exec()                           //Finish building

When returning a date, we use Moment.js, so it can be easier to manipulate.

And knowing that, just a glimpse at the methods and you're ready to go.

Configuration

When creating a parsed expression, you can use various options to change its behaviour. The defaults are shown below:

let options = {
  throw: false,                 //Throw errors in real time (bad for callbacks)
  startDate: Date.now(),        //When to start validating
  endDate: '3000-12-31T23:59',  //When to stop recognizing dates
  locale: 'en',                 //Locale for prettify
};
let chronos = new Saturnus('* * * * *');

If you use throw:false, be aware that the attibute isValid will be set to false.

let options = {
  throw: false,
};
let chronos = new Saturnus('*');
chronos.isValid                //false

For the complete docs be sure to visit the wiki.


NPM

Keywords

FAQs

Last updated on 02 Jan 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc