
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.
Advanced asynchronous utilities for TypeScript/JavaScript: promise barriers, mutex locks, read-write mutexes, latches, async filters, predicates (some/every/none), async generator utilities, microtasks, macrotasks, animation frames, and more for concurren
Lightweight TypeScript utilities for asynchronous concurrency control and task scheduling. Zero dependencies.
Mutex, MutexRW (read-write lock), Latch,
PromiseBarriertimeout, macrotask, microtask, animationFramefilter, pSome, pEvery, pNone, firstusing for automatic releasenpm install async-ts
Exclusive lock preventing race conditions in critical sections.
import { Mutex } from 'async-ts';
const mutex = new Mutex();
// Recommended: using syntax (auto-release)
{
using _ = await mutex.lock();
await updateSharedResource();
}
// Manual: obtain/release
const release = await mutex.obtain();
try {
await updateSharedResource();
} finally {
release();
}
// Conditional bypass
{
using _ = await mutex.lock(shouldBypass);
}
// Monitor contention
console.log(mutex.isLocked); // boolean
console.log(mutex.waitingCount); // number
Read-write lock allowing multiple concurrent readers but exclusive writers. Prevents writer starvation.
import { MutexRW } from 'async-ts';
const lock = new MutexRW();
// Read (concurrent)
{
using _ = await lock.lockRead();
const data = await readData();
}
// Write (exclusive)
{
using _ = await lock.lockWrite();
await writeData(newData);
}
// Monitor status
console.log(lock.activeReadCount); // number
console.log(lock.readWaitingCount); // number
console.log(lock.writeWaitingCount); // number
console.log(lock.isReadLocked); // boolean
console.log(lock.isWriteLocked); // boolean
Gate for coordinating asynchronous flows.
import { Latch } from 'async-ts';
const latch = new Latch(); // starts closed
// Wait in one place
await latch.gate;
// Open from another
latch.open();
// Reset
latch.close();
// Usage counting with disposable
{
using _ = latch.use(() => someCondition);
// Latch stays closed during scope
} // Opens when all uses disposed and condition met
Track and await multiple promises.
import { PromiseBarrier } from 'async-ts';
const barrier = new PromiseBarrier();
barrier.add(fetch('/api/a'));
barrier.add(fetch('/api/b'));
await barrier.free; // resolves when all settle
import { timeout, macrotask, microtask, animationFrame } from 'async-ts';
await timeout(1000); // delay ms
await macrotask(); // next event loop turn
await microtask(); // microtask queue (higher priority)
const time = await animationFrame(); // next repaint (browser-only)
import { filter, pSome, pEvery, pNone, first } from 'async-ts';
// Async filter (concurrent via Promise.all)
const evens = await filter([1, 2, 3, 4], async n => n % 2 === 0); // [2, 4]
// Async predicates (sequential, short-circuit)
await pSome([1, 2, 3], async n => n > 2); // true
await pEvery([2, 4, 6], async n => n % 2 === 0); // true
await pNone([1, 3, 5], async n => n % 2 === 0); // true
// First value from async generator
async function* gen() {
yield 1;
yield 2;
}
await first(gen()); // 1
| Member | Description |
|---|---|
obtain() | Acquire lock, returns release function |
lock() | Acquire lock, returns disposable |
isLocked | Whether mutex is currently held |
waitingCount | Number of tasks waiting to acquire |
| Member | Description |
|---|---|
obtainRead() | Acquire read lock, returns release fn |
obtainWrite() | Acquire write lock, returns release fn |
lockRead() | Acquire read lock, returns disposable |
lockWrite() | Acquire write lock, returns disposable |
activeReadCount | Number of active readers |
readWaitingCount | Tasks waiting for read lock |
writeWaitingCount | Tasks waiting for write lock |
isReadLocked | Whether read locks are held |
isWriteLocked | Whether write lock is held |
| Member | Description |
|---|---|
gate | Promise that resolves when latch is open |
open() | Release all waiters |
close() | Reset to closed state |
use() | Returns disposable for usage-counted gating |
| Member | Description |
|---|---|
add() | Track a promise |
free | Promise resolving when all tracked settle |
using syntax over manual obtain()/release() to prevent leaks.animationFrame requires a browser environment.Symbol.dispose — ensure your tsconfig includes
"lib": ["esnext.disposable"].MIT
FAQs
Advanced asynchronous utilities for TypeScript/JavaScript: promise barriers, mutex locks, read-write mutexes, latches, async filters, predicates (some/every/none), async generator utilities, microtasks, macrotasks, animation frames, and more for concurren
We found that async-ts 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
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.