1.0.1 • Published 25 days ago

thideyetask v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
25 days ago

Task Scheduler

Description

Task Scheduler is a simple JavaScript package that allows you to schedule and manage recurring tasks within your Node.js applications. It provides an easy-to-use interface for scheduling tasks to run at specified intervals.

Installation

To install the Task Scheduler package, you can use npm:

npm install thideyetask

Usage

  1. Import the thideyetask class into your Node.js application:
const TaskScheduler = require('task-scheduler');
  1. Create a new instance of TaskScheduler:
const scheduler = new TaskScheduler();
  1. Define your tasks as functions:
const task1 = () => {
  console.log('Task 1 executed at', new Date());
};

const task2 = () => {
  console.log('Task 2 executed at', new Date());
};
  1. Schedule tasks to run at specified intervals using the scheduleTask method:
scheduler.scheduleTask(task1, 2000); // Task 1 every 2 seconds
scheduler.scheduleTask(task2, 5000); // Task 2 every 5 seconds
  1. Tasks will run indefinitely until explicitly cancelled. To cancel all tasks, use the cancelAllTasks method:
scheduler.cancelAllTasks();

Example

const TaskScheduler = require('task-scheduler');

const scheduler = new TaskScheduler();

const task1 = () => {
  console.log('Task 1 executed at', new Date());
};

const task2 = () => {
  console.log('Task 2 executed at', new Date());
};

scheduler.scheduleTask(task1, 2000);
scheduler.scheduleTask(task2, 5000);

// Tasks will run indefinitely until explicitly cancelled
// To cancel all tasks
// scheduler.cancelAllTasks();

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.1

25 days ago

1.0.0

25 days ago