
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Cron (weekly) expressions parser and generator for JavaScript (browser and server)
Weekly Cron expressions parser and generator
<script src="cron.min.js"></script>
npm i cron.js --save
import Cron from 'cron.js'
or
var Cron = require('cron.js')
Days map reference:
1: 'SUN'
2: 'MON'
3: 'TUE'
4: 'WED'
5: 'THU'
6: 'FRI'
7: 'SAT'
Examples:
let data = {
days: [1, 2, 3, 4, 5, 6],
startTime: '18:30:00'
};
/* make */
new Cron( data, { shorten: true } ).expression; // '* 30 18 * * 1-6 *'
new Cron( data, { numeric: false } ).expression; // '* 30 18 * * SUN,MON,TUE,WED,THU,FRI *'
new Cron( { days: ['FRI', 'SAT'] } ).expression; // '* * * * * 6,7 *'
Cron.make( data, { numeric: false, shorten: true } ); // '* 30 18 * * SUN-FRI *'
/* parse */
Cron.parse('* 30 18 * * 1-3'); // { days: [1, 2, 3], startTime: '18:30:00' }
Cron.parse('* 30 18 * * 1,3,6'); // { days: [1, 3, 6], startTime: '18:30:00' }
Cron.parse('* * 12 * * SUN-SAT'); // { days: [1, 2, 3, 4, 5, 6, 7], startTime: '12:00:00' }
{
numeric: true, // If days of week in output expression should be integers instead of strings (e.g.: 1,2 <- SUN,MON)
optimize: false // If days of week should be represented in ranges wherever possible (e.g.: 1-6 instead of 1,2,3,4,5,6)
}
Source code inside src
folder, written in ES6, that gets loaded by babel and transpiled to ES5.
Build and minified versions in dist
folder.
Tests can be found in test
folder.
npm i // Installs npm dependencies
npm start // Compiles and minifies source code
npm test // Runs test suite
FAQs
Cron (weekly) expressions parser and generator for JavaScript (browser and server)
The npm package cron.js receives a total of 2 weekly downloads. As such, cron.js popularity was classified as not popular.
We found that cron.js demonstrated a not healthy version release cadence and project activity because the last version was released 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.