
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@hazae41/mutex
Advanced tools
Rust-like Mutex and Semaphore for TypeScript
npm install @hazae41/mutex
deno install jsr:@hazae41/mutex
import { Mutex } from "@hazae41/mutex"
const mutex = new Mutex(123)
/**
* You can queue a callback
*/
async function runOrWait() {
await mutex.runOrWait((x) => /* do (async) stuff with x */)
}
/**
* You can throw if the mutex is already locked
*/
async function runOrThrow() {
await mutex.runOrThrow((x) => /* do stuff with x */)
}
/**
* You can return something from the callback
*/
async function runOrWait2() {
const y = await mutex.runOrWait((x) => x * 2)
}
/**
* You can use async code
*/
async function runOrWait3() {
const y = await mutex.runOrWait(async (x) => await f(x))
}
/**
* You can acquire and release when you want
*/
async function getOrWait() {
const x = await mutex.getOrWait()
const y = x.get() * 2
x.release()
}
/**
* You can acquire and release with `using`
*/
async function getOrWait2() {
using x = await mutex.getOrWait()
const y = x.get() * 2
}
Same functions as Mutex but you can specify a capacity
const semaphore = new Semaphore(123, 3)
const a = await semaphore.getOrThrow()
const b = await semaphore.getOrThrow()
const c = await semaphore.getOrThrow()
const d = await semaphore.getOrThrow() // will throw
You can see it like Mutex<T> = Semaphore<T, 1>
FAQs
Rust-like Mutex for TypeScript
The npm package @hazae41/mutex receives a total of 126 weekly downloads. As such, @hazae41/mutex popularity was classified as not popular.
We found that @hazae41/mutex 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
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.