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.
@chalker/queue
Advanced tools
A trivial Queue / Lock implementation that I used in my personal projects.
Example: https://github.com/nodejs/Gzemnid/blob/main/src/queue.js
Usage:
import { Queue } from '@chalker/queue'
const queue = new Queue(10) // concurrency
async function run() {
await queue.claim()
// do async stuff with controlled maximum concurrency
queue.release()
}
new Lock()
is just an alias to new Queue(1)
, which can be used
import { Queue } from '@chalker/queue'
const lock = new Lock()
async function run() {
await lock.claim()
// do async stuff with maximum concurrency = 1
lock.release()
}
import { Queue } from '@chalker/queue'
const queue = new Queue(3)
let concurrency = 0 // Just for testing purposes
async function run(x) {
await queue.claim()
console.log(`Start #${x}, concurrency: ${++concurrency}`)
await new Promise(resolve => setTimeout(resolve, 1))
console.log(`End #${x}, concurrency: ${concurrency--}`)
queue.release()
}
const args = new Array(6).fill(0).map((_, i) => i + 1)
await Promise.all(args.map(run))
Output:
Start #1, concurrency: 1
Start #2, concurrency: 2
Start #3, concurrency: 3
End #1, concurrency: 3
Start #4, concurrency: 3
End #2, concurrency: 3
Start #5, concurrency: 3
End #3, concurrency: 3
Start #6, concurrency: 3
End #4, concurrency: 3
End #5, concurrency: 2
End #6, concurrency: 1
FAQs
A trivial queue / mutex lock implementation
We found that @chalker/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
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.