Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@types/cron
Advanced tools
TypeScript definitions for cron
@types/cron provides TypeScript type definitions for the cron package, which is used for scheduling jobs in Node.js applications. It allows developers to define and manage cron jobs with type safety.
Creating a Cron Job
This feature allows you to create a cron job that runs a specified function at a scheduled time. In this example, the job is scheduled to run every day at midnight.
const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob('0 0 * * *', function() {
console.log('You will see this message every day at midnight');
});
job.start();
Stopping a Cron Job
This feature allows you to stop a running cron job. In this example, the job is stopped after 10 seconds.
const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob('0 0 * * *', function() {
console.log('You will see this message every day at midnight');
});
job.start();
// Stop the job after some time
setTimeout(() => {
job.stop();
console.log('Job stopped');
}, 10000);
Specifying Time Zones
This feature allows you to specify the time zone for the cron job. In this example, the job is scheduled to run every day at midnight in the 'America/Los_Angeles' time zone.
const cron = require('cron');
const CronJob = cron.CronJob;
const job = new CronJob({
cronTime: '0 0 * * *',
onTick: function() {
console.log('You will see this message every day at midnight in the specified time zone');
},
timeZone: 'America/Los_Angeles'
});
job.start();
node-cron is a lightweight npm package for scheduling tasks in Node.js using cron syntax. It is similar to cron but does not require any external dependencies. It is simpler and more lightweight compared to cron.
agenda is a light-weight job scheduling library for Node.js. It offers more advanced features like job persistence in MongoDB, job priority, and concurrency control. It is more feature-rich compared to cron.
bree is a job scheduler for Node.js with support for cron syntax, human-readable intervals, and worker threads. It is designed to be simple and fast, with additional features like graceful shutdown and job retries. It offers more modern features compared to cron.
npm install --save @types/cron
This package contains type definitions for cron (https://www.npmjs.com/package/cron).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cron.
These definitions were written by Hiroki Horiuchi, Lundarl Gholoi, and koooge.
FAQs
Stub TypeScript definitions entry for cron, which provides its own types definitions
The npm package @types/cron receives a total of 273,332 weekly downloads. As such, @types/cron popularity was classified as popular.
We found that @types/cron 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.