Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
pending-queue
Advanced tools
pending-queue ensures a certain asynchronous method only run once, and queues listeners which are registered to it.
pending-queue
ensures a certain asynchronous method only run once, and queues listeners which are registered to it.
$ npm install pending-queue --save
const Queue = require('pending-queue')
let counter = 0
const queue = new Queue({
load: (a, b) => {
return new Promise((resolve) => {
counter ++
setTimeout(() => {
resolve(a + b)
}, 100)
})
}
})
function run () {
queue.add(1, 2).then((value) => {
console.log(value, counter)
})
}
run()
run()
run()
// 3, 1
// 3, 1
// 3, 1
// So the load function ran only once.
function(...params)
the method to get the valuefunction(params)=JSON.stringify
stringify the parameters as the key to queue all asynchronous requests.Returns EventEmitter
, and key
as the event name, so you can use queue.listenerCount(key)
to see if there are pending tasks.
Arguments
which will be passed into load
Returns Promise
String
Return Promise
Specifies the key ourself, and avoid using options.stringify
to serialize the key from params
.
But pay attension that there should be a consistent one-to-one match between key
and params
, or make sure that you exactly know what you are doing.
MIT
FAQs
pending-queue ensures a certain asynchronous method only run once, and queues listeners which are registered to it.
The npm package pending-queue receives a total of 5,915 weekly downloads. As such, pending-queue popularity was classified as popular.
We found that pending-queue demonstrated a not healthy version release cadence and project activity because the last version was released 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.