Nonsense Poetry Manager

    saturnus

    2.1.1 • Public • Published

    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

    Install

    npm i saturnus

    DownloadsWeekly Downloads

    0

    Version

    2.1.1

    License

    MIT

    Last publish

    Collaborators

    • malpercio