1.0.0 ā€¢ Published 3 years ago

pc-queue v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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