taskscheduler-byouida
v1.0.1
Published
by ouida spencer
Downloads
2
Readme
Task Scheduler
A simple Task Scheduler package for Node.js applications.
Installation
npm install task-schedulerUsage
const TaskScheduler = require('task-scheduler');
// Create a new instance of TaskScheduler
const taskScheduler = new TaskScheduler();
// Define a task function
const exampleTask = () => {
console.log('Executing example task');
};
// Schedule the task to run after 5 seconds
const scheduledTask = taskScheduler.scheduleTask(exampleTask, 5000);
// Cancel the scheduled task after 3 seconds
setTimeout(() => {
taskScheduler.cancelTask(scheduledTask);
console.log('Cancelled example task');
}, 3000);API
scheduleTask(task, delay)
Schedules a task to run after a specified delay in milliseconds.
task: A function to be executed when the scheduled time is reached.delay: The delay in milliseconds before the task should be executed.
Returns an object representing the scheduled task.
cancelTask(scheduledTask)
Cancels a scheduled task.
scheduledTask: The object returned byscheduleTask()representing the task to be cancelled.
License
This project is licensed under the MIT License - see the LICENSE file for details.
