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

@darkeyedevelopers/natural-cron.js

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkeyedevelopers/natural-cron.js

Pure JavaScript library for converting natural English phrases into Cron expressions

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

natural-cron.js

Pure JS library for converting natural English phrases into Cron expressions.

demo.gif

Usage

Browser
<!-- link dist/natural-cron.min.js -->
<script src="pathToLibrary/natural-cron.min.js"></script>

<!-- call getCronString() from JS code whenever required-->
<script>
    btn.onclick = function(){
        let str = inputBox.value;
        res.value = getCronString(str);
    };
</script>
NodeJS
  • Install package with...

      npm install @darkeyedevelopers/natural-cron.js
    
  • Import with require() & call getCronString() whenever required...

      var getCronString = require('@darkeyedevelopers/natural-cron.js');
    
      var cron = getCronString('every day at 2:55pm');
    

Flexible outputs

Output result pattern can be specified while calling getCronString() function.

ParameterTypeDefault valueDescription
Input string      String   Required. English phrase that has to be
converted to corresponding Cron expression
Output pattern      String   'MIN HOR DOM MON WEK YER'Optional. Specifies the output pattern in
which cron expression should be generated.

MIN => Minutes
HOR => Hours
DOM => Day of Month
MON => Month(s)
WEK => Weekday(s)
YER => Year

Combine one or more of the above to form
result pattern. Checkout the examples
below to understand better.

Examples

  • getCronString('every 3rd day at 2:55 am from January to August');
    => 55 2 3 JAN-AUG ? *
  • getCronString('every 3rd day at 2:55 am from January to August', 'DOM MON YER');
    => 3 JAN-AUG *
  • getCronString('every 3rd day at 2:55 am from January to August', 'DOM YER MON HOR');
    => 3 * JAN-AUG 2
  • getCronString('every 3rd day at 2:55 am from January to August', '{DOM) some text MON :)');
    => {3) some text JAN-AUG :)

Implemented using Push Down Automata

design.png


Do you want to contribute ? Checkout CONTRIBUTING.md

Keywords

FAQs

Package last updated on 25 May 2021

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