Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ttrentsou-task-queue

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ttrentsou-task-queue

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

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source
# 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

Package last updated on 11 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc