
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@hazae41/cleaner
Advanced tools
Helpers for Disposable
npm i @hazae41/cleaner
using d = new Disposer(something, () => { ... })
await using d = new AsyncDisposer(something, async () => { ... })
using d = new PromiseDisposer(doSomethingAsync(), () => { ... })
await d
await using d = new AsyncPromiseDisposer(doSomethingAsync(), async () => { ... })
await d
It will dispose both a and b once one of them settles
/**
* When a and b are Disposable
**/
await Disposable.raceSync([a, b])
/**
* When a and b are AsyncDisposable
**/
await Disposable.race([a, b])
This can be useful for waiting for multiple listeners, and remove all listeners when one of them is triggered
function waitA(): PromiseLike<"a"> & Disposable {
const future = new Future<"a">()
const onevent = () => future.resolve("a")
this.addEventListener("a", onevent)
const off = () => this.removeEventListener("a", onevent)
return new PromiseDisposer(future.promise, off)
}
function waitB(): PromiseLike<"b"> & Disposable {
const future = new Future<"b">()
const onevent = () => future.resolve()
this.addEventListener("b", onevent)
const off = () => this.removeEventListener("b", onevent)
return new PromiseDisposer(future.promise, off)
}
/**
* When one listener is triggered, the other is removed
**/
const x: "a" | "b" = await Disposable.raceSync([waitA(), waitB()])
FAQs
Helpers for Disposable
We found that @hazae41/cleaner 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.