Task Scheduler is a simple Node.js package that allows you to schedule tasks to run at specified intervals within your applications.
You can install Task Scheduler via npm:
npm install task-scheduler
const TaskScheduler = require('task-scheduler');
// Create an instance of TaskScheduler
const scheduler = new TaskScheduler();
// Define a task function
function myTask() {
console.log('Running my task...');
}
// Schedule the task to run every 5 seconds
scheduler.scheduleTask(myTask, 5);
// To stop the scheduler (optional)
// scheduler.stop();
Initializes the TaskScheduler instance.
Schedules a task to run at a specified interval.
task
: A function representing the task to be scheduled.intervalInSeconds
: The interval in seconds at which the task should run.
Stops the task scheduler.
This project is licensed under the MIT License - see the LICENSE file for details.