Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@types/cron
Advanced tools
Stub TypeScript definitions entry for cron, which provides its own types definitions
@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.
This is a stub types definition for @types/cron (https://github.com/kelektiv/node-cron#readme).
cron provides its own type definitions, so you don't need @types/cron installed!
FAQs
Stub TypeScript definitions entry for cron, which provides its own types definitions
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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.