Skip to content

Instantly share code, notes, and snippets.

View giano's full-sized avatar
☃️
In the Vault :)

Stefano Valicchia giano

☃️
In the Vault :)
View GitHub Profile
@dsherret
dsherret / Using.ts
Last active October 26, 2023 13:30
Typescript Disposable (using statement)
// NOTE: This is now rolled up in a package and supports more scenarios: https://github.com/dsherret/using-statement
interface IDisposable {
dispose();
}
function using<T extends IDisposable>(resource: T, func: (resource: T) => void) {
try {
func(resource);
} finally {