
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@hazae41/mutex
Advanced tools
Rust-like Mutex and Semaphore for TypeScript
npm i @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
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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.