taskscheduler1
v1.0.2
Published
by gold
Downloads
1
Readme
# Task Scheduler
Task Scheduler is a simple JavaScript library for scheduling and running tasks at specified intervals.
## Installation
You can install the Task Scheduler package via npm:
```bash
npm install task-scheduler-js
```
## Usage
```javascript
const TaskScheduler = require('task-scheduler-js');
// Create a new instance of TaskScheduler
const scheduler = new TaskScheduler();
// Define a task
const task = () => {
console.log("Task executed!");
};
// Schedule the task to run every 5 seconds
scheduler.scheduleTask(task, 5);
// Start the scheduler
scheduler.start();
// Stop the scheduler after 30 seconds
setTimeout(() => {
scheduler.stop();
}, 30000);
```
## API
### `scheduleTask(task: Function, interval: number)`
Schedules a task to run at the specified interval. The `task` parameter should be a function representing the task to be executed, and the `interval` parameter should be the time interval in seconds.
### `start()`
Starts the task scheduler. Once started, tasks will be executed at their specified intervals.
### `stop()`
Stops the task scheduler. No tasks will be executed after stopping the scheduler.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
````markdown
This README provides an overview of the package, installation instructions, usage examples, and API documentation. You can include it in your package repository to help users understand how to use your Task Scheduler library.