dispose
what is this?
A C# inspired helper function to allow for automatic disposing of objects.
how does it work
If a class implements the Disposable
interface, it will expose the (async)
function dispose
. An instance of this class cacn be passed to the using
helper function so that the dispose
method is automatically executed.
huh?
Ok, let me show you:
Without using:
const i = await DisposableClass;try // do stuff...finally await i;
With using (does exactly the same)
await ;
This is great for usage in test (cool) test-frameworks like tape with blue-tape.
exaple: