New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pc-queue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pc-queue

A queue for producer-consumer model

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Welcome to pc-queue 👋

Version Documentation Maintenance License: MIT

A queue for producer-consumer model

Example

create one Queue with one consumer and two producer

const Queue = require('./index')

// 1. define queue instance
const queue = new Queue(2) //concurrency=2

// 2. consumer do something
var doSth=function(data,i){
    console.log(`consume${i}: `,data)
}

// 3. begin consume
queue.run(doSth)

setInterval(function(){
    // 4. begin produce
    queue.push(Math.random())
},1000)

output

consume0:  0.8152931321636179
consume1:  0.10340654794346626
consume0:  0.7497420856391879
consume1:  0.7854904441673309
consume0:  0.9786641059681527

Install

npm install

Run tests

npm run test

Author

👤 selenium39

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 selenium39.
This project is MIT licensed.

This README was generated with ❤️ by readme-md-generator

Keywords

queue

FAQs

Package last updated on 28 Jul 2021

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