Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ttrentsou-task-queue
Advanced tools
Build a package that provides a lightweight task queue system for Node.js applications. This could include features like task prioritization, concurrency control, and support for distributed task processing using technologies like Redis or RabbitMQ
# Task Queue Package
Task Queue Package is a simple Node.js package that provides functionality to create and manage a queue of tasks with a specified concurrency level.
## Installation
You can install the package via npm:
```bash
npm install task-queue-package
```
## Usage
```javascript
const TaskQueue = require('task-queue-package');
// Create an instance of TaskQueue with the desired concurrency level
const taskQueue = new TaskQueue(2);
// Define some example tasks
const tasks = [
(callback) => {
console.log('Task 1 started');
setTimeout(() => {
console.log('Task 1 completed');
callback();
}, 2000);
},
(callback) => {
console.log('Task 2 started');
setTimeout(() => {
console.log('Task 2 completed');
callback();
}, 1000);
},
(callback) => {
console.log('Task 3 started');
setTimeout(() => {
console.log('Task 3 completed');
callback();
}, 3000);
}
];
// Push tasks into the queue
tasks.forEach(task => {
taskQueue.pushTask(task);
});
```
## API
### `TaskQueue(concurrency)`
Creates a new instance of TaskQueue with the specified concurrency level.
- `concurrency` (number): The maximum number of tasks that can run concurrently.
### `pushTask(task)`
Pushes a task into the queue.
- `task` (function): A function representing the task to be executed. It should accept a callback function as its argument, which should be called once the task is complete.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
FAQs
Build a package that provides a lightweight task queue system for Node.js applications. This could include features like task prioritization, concurrency control, and support for distributed task processing using technologies like Redis or RabbitMQ
We found that ttrentsou-task-queue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.