Zizwar / scheduly

scheduly is a simple JavaScript library for scheduling function executions based on specific timings and various time zones.

Home Page:https://github.com/Zizwar/scheduly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scheduly

scheduly is a simple JavaScript library for scheduling function executions based on specific timings and various time zones.

Installation

To install scheduly, use the following command:

npm install scheduly

Features

  • Easy scheduling of functions.
  • Support for multiple time zones.
  • Customizable scheduling intervals.

Usage

First, import scheduly into your project:

const ScheduleFunction = require(scheduly);

Then, create a new ScheduleFunction instance, specifying the interval and time zone. For example, to run a function every 4 hours and 1 minute:

const schedule = new ScheduleFunction("4h01m", "Europe/London");

Now, you can schedule your function:

schedule.schedule(() => {
    // Your function logic here
});

To stop the scheduled function:

schedule.stop();

Examples

Scheduling a Function in GMT:

const gmtSchedule = new ScheduleFunction("2h30m", "GMT");
gmtSchedule.schedule(() => {
    console.log("This function runs every 2 hours and 30 minutes in GMT.");
});

Scheduling a Function in New York Time:

const nySchedule = new ScheduleFunction("1h", "America/New_York");
nySchedule.schedule(() => {
    console.log("This function runs every hour in New York time."");
});

Scheduling a Function in Tokyo Time:

const tokyoSchedule = new ScheduleFunction("3h45m", "Asia/Tokyo");
tokyoSchedule.schedule(() => {
    console.log("This function runs every 3 hours and 45 minutes in Tokyo time."");
});

About

scheduly is a simple JavaScript library for scheduling function executions based on specific timings and various time zones.

https://github.com/Zizwar/scheduly

License:MIT License


Languages

Language:JavaScript 100.0%