Skip to content

Instantly share code, notes, and snippets.

View DannyPhlyme's full-sized avatar
🎯
Focusing

Daniel Olajumoke DannyPhlyme

🎯
Focusing
View GitHub Profile
@dsherret
dsherret / Using.ts
Last active November 28, 2025 12:54
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 {