Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
cronstrue
Advanced tools
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.
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 }));
The cron-parser package is used for parsing and manipulating cron expressions. Unlike cronstrue, which focuses on converting cron expressions to human-readable strings, cron-parser provides more functionality for working with cron expressions programmatically, such as finding the next execution time.
The later package is a scheduling library that supports both cron and other types of schedules. It can be used to parse, manipulate, and execute schedules. While cronstrue focuses on converting cron expressions to human-readable strings, later provides a more comprehensive set of tools for working with schedules.
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.
cRonstrue is exported as an UMD module so it will work in an AMD, CommonJS or browser global context.
First, install the module:
npm install cronstrue
Then, depending upon your usage context, add a reference to it:
var cronstrue = require('cronstrue');
import cronstrue from 'cronstrue';
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>
<script>
var cronstrue = window.cronstrue;
</script>
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"
console.log(cronstrue.toString("* * * ? * 2-6/2", { dayOfWeekStartIndexZero: false}));
> "Every second, every 2 days of the week, Monday through Friday"
For more usage examples, including a demonstration of how cRonstrue can handle some very complex cron expressions, you can reference the unit tests.
A demo is available here: http://bradyholt.github.io/cRonstrue/
To use the i18n support cRonstrue provides, you must use the packaged library that contains the locale transalations. Once you do this, you can pass the name of a supported locale as an option to cronstrue.toString()
. For example, for the es (Spanish) locale, you would use: cronstrue.toString("* * * * *", { locale: "es" });
.
var cronstrue = require('cronstrue/i18n');
cronstrue.toString("*/5 * * * *", { locale: "fr" });
The cronstrue-i18n.min.js
file from the /dist
folder in the npm package should be served to the browser.
<script src="cronstrue-i18n.min.js" type="text/javascript"></script>
<script>
cronstrue.toString("*/5 * * * *", { locale: "fr" });
</script>
cRonstrue is freely distributable under the terms of the MIT license.
FAQs
Convert cron expressions into human readable descriptions
The npm package cronstrue receives a total of 842,251 weekly downloads. As such, cronstrue popularity was classified as popular.
We found that cronstrue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.