Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minicron

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minicron

Simple utility for scheduling functions at fixed intervals

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Minicron

A simple utility for scheduling functions at fixed intervals (seconds, minutes, hours, days) using setInterval().

Installation

Include the module in your project:

npm install minicron

API

All methods return a Timer object that clearInterval can use as ID to cancel the cron execution.

const cronID = cron.seconds(amount, fn, ...args)

Run a function every amount seconds.

cron.seconds(5, () => {
  console.log('Runs every 5 seconds');
});

const cronID = cron.minutes(amount, fn, ...args)

Run a function every amount minutes.

cron.minutes(2, () => {
  console.log('Runs every 2 minutes');
});

const cronID = cron.hours(amount, fn, ...args)

Run a function every amount hours.

cron.hours(1, () => {
  console.log('Runs every 1 hour');
});

const cronID = cron.days(amount, fn, ...args)

Run a function every amount days.

cron.days(1, () => {
  console.log('Runs every 1 day');
});

Example

const cron = require('minicron');

cron.seconds(10, () => console.log('Every 10 seconds'));
cron.minutes(1, () => console.log('Every minute'));
cron.hours(1, () => console.log('Every hour'));
cron.days(1, () => console.log('Every day'));

Notes

  • The methods use setInterval() and will run indefinitely.
  • You can manually stop the intervals using clearInterval(cronID) if needed.

License

Apache-2.0

FAQs

Package last updated on 22 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc