
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-async-semaphore
Advanced tools
A blazing-fast, perfectly typed JavaScript semaphore that manages real resources.
Node-Async-Semaphore is not just another counting mechanism. It's a highly optimized, TypeScript-based Semaphore solution that leverages a vector of resources instead of a mere permit count, making integration into projects both convenient and efficient. Whether you're designing pooling systems, rate limiters, or merely trying to regulate access, Semaphore has got you covered.
Using npm:
npm install node-async-semaphore
or
Using yarn:
yarn add node-async-semaphore
import { Semaphore, voidResource } from 'node-async-semaphore';
const counterSemaphore = new Semaphore({
permits: 3,
resource: voidResource,
});
async function performConcurrentOperation(index: number) {
await counterSemaphore.acquire();
console.log(`Operation ${index} is running`);
setTimeout(() => {
console.log(`Finishing operation ${index}`);
counterSemaphore.release();
}, 1000);
}
for (let i = 1; i <= 5; i++) {
performConcurrentOperation(i); // Only 3 operations will run concurrently due to the semaphore.
}
import { Semaphore } from 'node-async-semaphore';
import { createClient } from 'promise-redis';
const redisSemaphore = new Semaphore({
permits: 3,
resource: () => createClient(),
});
async function runRedisCommand() {
const client = await redisSemaphore.acquire();
console.log('Running Redis command...');
await client.set('key', 'value');
const result = await client.get('key');
console.log(`Retrieved value: ${result}`);
redisSemaphore.release(client);
}
for (let i = 0; i < 5; i++) {
runRedisCommand(); // Only 3 Redis commands will be active at once due to the semaphore.
}
import { SimpleRateLimiter } from 'node-async-semaphore';
const rateLimiter = new SimpleRateLimiter({
requests: 10, // Allow 10 tasks every 5 seconds.
interval: 5000, // 5 seconds interval.
uniformDistribution: false // Delay is not spread evenly across requests.
});
async function rateLimitedTask() {
await rateLimiter.acquire();
console.log("Task running at", new Date().toISOString());
// The task logic goes here...
}
for (let i = 0; i < 15; i++) {
rateLimitedTask(); // Only the first 10 tasks will run immediately. The next 5 will be queued with a delay.
}
This code is licensed under the MIT License.
FAQs
A blazing-fast, perfectly typed JavaScript semaphore that manages real resources.
We found that node-async-semaphore 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.