Socket
Socket
Sign inDemoInstall

cronstrue

Package Overview
Dependencies
0
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cronstrue

Convert cron expressions into human readable descriptions


Version published
Weekly downloads
735K
decreased by-20.43%
Maintainers
1
Install size
53.9 kB
Created
Weekly downloads
 

Package description

What is cronstrue?

The cronstrue npm package is used to convert cron expressions into human-readable strings. This can be particularly useful for displaying cron schedules in a more understandable format for users who may not be familiar with cron syntax.

What are cronstrue's main functionalities?

Basic Conversion

This feature converts a basic cron expression into a human-readable string. For example, the cron expression '*/5 * * * *' is converted to 'Every 5 minutes'.

const cronstrue = require('cronstrue');
console.log(cronstrue.toString('*/5 * * * *'));

Localized Conversion

This feature allows for the conversion of cron expressions into human-readable strings in different languages. For example, the cron expression '*/5 * * * *' is converted to 'Cada 5 minutos' in Spanish.

const cronstrue = require('cronstrue');
console.log(cronstrue.toString('*/5 * * * *', { locale: 'es' }));

Verbose Conversion

This feature provides a more detailed, verbose description of the cron expression. For example, the cron expression '*/5 * * * *' is converted to 'Every 5 minutes, every hour, every day, every month, every day of the week'.

const cronstrue = require('cronstrue');
console.log(cronstrue.toString('*/5 * * * *', { verbose: true }));

Other packages similar to cronstrue

Readme

Source

cronstrue Build Status

cronstrue is a JavaScript library that parses a cron expression and outputs a human readable description of the cron schedule. For example, given the expression "*/5 * * * *" it will output "Every 5 minutes".

This library was ported from the original C# implemenation called cron-expression-descriptor and is also available in a few other languages.

Features

  • Zero dependencies
  • Supports all cron expression special characters including * / , - ? L W, #
  • Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions
  • (i18n support with 14 languages coming soon)

Installation

cronstrue is exported as an UMD module so it will work in an AMD, CommonJS or browser global context.

Node

npm install cronstrue
var cronstrue = require('cronstrue');

Browser

The cronstrue.min.js file from the /dist folder in the npm package should be served to the browser. There are no dependencies so you can simply include the library in a <script> tag.

<script src="cronstrue.min.js" type="text/javascript"></script>
var cronstrue = window.cronstrue;

Usage

cronstrue.toString("* * * * *");
> "Every minute"

cronstrue.toString("0 23 ? * MON-FRI");
> "At 11:00 PM, Monday through Friday"

cronstrue.toString("23 12 * * SUN#2");
> "At 12:23 PM, on the second Sunday of the month"

For more usage examples, including a demonstration of how cronstrue can handle some very complex cron expressions, you can reference the unit tests.

License

cronstrue is freely distributable under the terms of the MIT license.

Keywords

FAQs

Last updated on 28 Jul 2016

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