Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
async-await-mutex-lock
Advanced tools
Mutex locks for async functions with functionality to use keys for separate locks
Mutex locks for async functions with functionality to use keys for separate locks
import { Lock } from "async-await-mutex-lock";
let lock = new Lock();
async function serialTask() {
await lock.acquire();
try {
// Don't return a promise here as Promise may resolve after finally
// has executed
} finally {
lock.release();
}
}
All the keys will have their own separate locks and separate waiting lists. A key can have any type (eg. string, number, etc. or a custom type allowed by typescript as a Map key)
import { Lock } from "async-await-mutex-lock";
let lock = new Lock<string>();
async function serialTask() {
await lock.acquire("myKey");
try {
// Don't return a promise here as Promise may resolve after finally
// has executed
}
finally {
lock.release("myKey");
}
}
async function serialTaskTwo() {
await lock.acquire("myKeyTwo");
try {
// Don't return a promise here as Promise may resolve after finally
// has executed
}
finally {
lock.release("myKeyTwo");
}
}
import { Lock } from "async-await-mutex-lock";
let lock = new Lock();
async function serialTask() {
await lock.acquire();
console.log(lock.isAcquired()); // prints true
}
isAcquired()
with key
checks for the given key separately.
import { Lock } from "async-await-mutex-lock";
let lock = new Lock<string>();
async function serialTask() {
await lock.acquire("myKey");
console.log(lock.isAcquired("myKey")) // prints true
}
In case of any issues or bugs, please open a pull request here
FAQs
Mutex locks for async functions with functionality to use keys for separate locks
We found that async-await-mutex-lock demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.